Changeset 91 for trunk/src/helpers/gpih.c
- Timestamp:
- Aug 2, 2001, 10:36:35 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r81 r91 603 603 * 604 604 * gpihFindFont uses this mutex. If you call GpiCreateLogFont 605 * yourself somewhere, do this after you called this function. 605 * yourself somewhere, you should do this under the protection 606 * of this function. 606 607 * 607 608 * Call gpihUnlockLCIDs to unlock. … … 612 613 BOOL gpihLockLCIDs(VOID) 613 614 { 614 BOOL brc = FALSE; 615 616 if (G_hmtxLCIDs == NULLHANDLE) 615 if (!G_hmtxLCIDs) 617 616 // first call: create 618 brc = !DosCreateMutexSem(NULL, 619 &G_hmtxLCIDs, 620 0, 621 TRUE); // request! 622 else 623 // subsequent calls: request 624 brc = !WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT); 625 626 return (brc); 617 return (!DosCreateMutexSem(NULL, 618 &G_hmtxLCIDs, 619 0, 620 TRUE)); // request! 621 622 // subsequent calls: request 623 return (!WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT)); 627 624 } 628 625 … … 741 738 if (allcids) 742 739 free(allcids); 743 744 /*745 PLONG pBase;746 APIRET arc;747 748 // _Pmpf(("gpihQueryNextFontID: calling DosAllocMem"));749 750 arc = DosAllocMem((PPVOID)(&pBase),751 GQNCL_BLOCK_SIZE,752 // space is needed for an array of lCount longs.753 PAG_READ |754 PAG_WRITE);755 if (arc == NO_ERROR)756 {757 arc = DosSubSetMem(pBase,758 DOSSUB_INIT | DOSSUB_SPARSE_OBJ,759 GQNCL_BLOCK_SIZE);760 if (arc == NO_ERROR)761 {762 PLONG alTypes; // object types763 PSTR8 aNames; // font names764 PLONG allcids; // local identifiers765 766 arc = DosSubAllocMem((PVOID)pBase,767 (PPVOID)(&aNames),768 (ULONG)(lCount*(ULONG)sizeof(STR8)));769 // space is needed for an array of770 // lCount longs771 if (arc == NO_ERROR)772 {773 arc = DosSubAllocMem((PVOID)pBase,774 (PPVOID)(&allcids),775 (ULONG)lCount*sizeof(LONG));776 // space is needed for an array of777 // lCount longs.778 if (arc == NO_ERROR)779 {780 arc = DosSubAllocMem((PVOID)pBase,781 (PPVOID)(&alTypes),782 (ULONG)lCount*sizeof(LONG));783 // space is needed for an array of784 // lCount longs.785 if (arc == NO_ERROR)786 {787 if (GpiQuerySetIds(hps,788 lCount,789 alTypes,790 aNames,791 allcids))792 {793 // FINALLY we have all the lcids in use.794 BOOL fContinue = TRUE;795 lcidNext = 1;796 797 // now, check if this lcid is in use already:798 while (fContinue)799 {800 BOOL fFound = FALSE;801 ULONG ul;802 fContinue = FALSE;803 for (ul = 0;804 ul < lCount;805 ul++)806 {807 if (allcids[ul] == lcidNext)808 {809 fFound = TRUE;810 break;811 }812 }813 814 if (fFound)815 {816 // lcid found:817 // try next higher one818 lcidNext++;819 fContinue = TRUE;820 }821 // else: return that one822 }823 }824 }825 }826 }827 }828 829 arc = DosFreeMem(pBase);830 }831 */832 740 } 833 741 … … 1006 914 *@@changed V0.9.4 (2000-08-08) [umoeller]: added fFamily 1007 915 *@@changed V0.9.9 (2001-04-01) [umoeller]: made this thread-safe, finally 916 *@@changed V0.9.14 (2001-08-01) [umoeller]: some optimizations 1008 917 */ 1009 918 … … 1012 921 BOOL fFamily, // in: if TRUE, pszName specifies font family; 1013 922 // if FALSE, pszName specifies font face 1014 PSZ pszName,// in: font family or face name (without point size)923 const char *pcszName, // in: font family or face name (without point size) 1015 924 USHORT usFormat, // in: none, one or several of: 1016 925 // -- FATTR_SEL_ITALIC … … 1034 943 sizeof(FONTMETRICS), 1035 944 NULL); 1036 PFONTMETRICS pfm = (PFONTMETRICS)malloc(cFonts * sizeof(FONTMETRICS)), 1037 pfm2 = pfm, 1038 pfmFound = NULL; 945 PFONTMETRICS pfm = (PFONTMETRICS)malloc(cFonts * sizeof(FONTMETRICS)), 946 pfm2 = pfm, 947 pfmFound = NULL; 948 949 BOOL fQueriedDevice = FALSE; // V0.9.14 (2001-08-01) [umoeller] 950 LONG alDevRes[2]; // device resolution 1039 951 1040 952 // _Pmpf(("gpihFindFont: enumerating for %s, %d points", pszFaceName, lSize)); … … 1047 959 // -- _not_ total buffer size! 1048 960 pfm); 961 1049 962 // now we have an array of FONTMETRICS 1050 963 // for EVERY font that is installed on the system... … … 1066 979 FontAttrs.fsSelection = usFormat; // changed later if better font is found 1067 980 FontAttrs.lMatch = 0L; // closest match 1068 strcpy(FontAttrs.szFacename, p szName);981 strcpy(FontAttrs.szFacename, pcszName); 1069 982 FontAttrs.idRegistry = 0; // default registry 1070 983 FontAttrs.usCodePage = 0; // default codepage … … 1095 1008 pfm2->lAveCharWidth)); */ 1096 1009 1097 PSZ pszCompare = (fFamily)1098 ? pfm2->szFamilyname1099 : pfm2->szFacename;1100 1101 if ( strcmp(pszCompare, pszName) == 0)1010 const char *pcszCompare = (fFamily) 1011 ? pfm2->szFamilyname 1012 : pfm2->szFacename; 1013 1014 if (!strcmp(pcszCompare, pcszName)) 1102 1015 { 1103 1016 /* _Pmpf((" Found font %s; slope %d, usWeightClass %d", … … 1117 1030 // for bitmap fonts, there are always two versions: 1118 1031 // one for low resolutions, one for high resolutions 1119 LONG alDevRes[2]; 1120 DevQueryCaps(GpiQueryDevice(hps), 1121 CAPS_HORIZONTAL_FONT_RES, 1122 2L, 1123 alDevRes); 1032 if (!fQueriedDevice) 1033 { 1034 DevQueryCaps(GpiQueryDevice(hps), 1035 CAPS_HORIZONTAL_FONT_RES, 1036 2L, 1037 alDevRes); 1038 fQueriedDevice = TRUE; 1039 } 1040 1124 1041 if ( (pfm2->sXDeviceRes == alDevRes[0]) 1125 1042 && (pfm2->sYDeviceRes == alDevRes[1]) … … 1151 1068 && (pfm2->usWeightClass == 7) // bold 1152 1069 ) 1153 || ( ( (usFormat & FATTR_SEL_BOLD) == 0)1070 || ( (!(usFormat & FATTR_SEL_BOLD)) 1154 1071 && (pfm2->usWeightClass == 5) // regular 1155 1072 ) … … 1158 1075 && (pfm2->sCharSlope != 0) // italics 1159 1076 ) 1160 || ( ( (usFormat & FATTR_SEL_ITALIC) == 0)1077 || ( (!(usFormat & FATTR_SEL_ITALIC)) 1161 1078 && (pfm2->sCharSlope == 0) // regular 1162 1079 ) … … 2075 1992 * You can then use any GPI function on the memory 2076 1993 * PS to draw into the bitmap. Use the fields from 2077 * _XBITMAP for that.1994 * XBITMAP for that. 2078 1995 * 2079 1996 * The bitmap is created in RGB mode. … … 2144 2061 * 2145 2062 * To be on the safe side, this sets the 2146 * bitmappointer to NULL as well.2063 * given XBITMAP pointer to NULL as well. 2147 2064 * 2148 2065 *@@added V0.9.12 (2001-05-20) [umoeller]
Note:
See TracChangeset
for help on using the changeset viewer.