Ignore:
Timestamp:
Aug 2, 2001, 10:36:35 PM (24 years ago)
Author:
umoeller
Message:

Misc changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/gpih.c

    r81 r91  
    603603 *
    604604 *      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.
    606607 *
    607608 *      Call gpihUnlockLCIDs to unlock.
     
    612613BOOL gpihLockLCIDs(VOID)
    613614{
    614     BOOL brc = FALSE;
    615 
    616     if (G_hmtxLCIDs == NULLHANDLE)
     615    if (!G_hmtxLCIDs)
    617616        // 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));
    627624}
    628625
     
    741738        if (allcids)
    742739            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 types
    763                 PSTR8  aNames;   // font names
    764                 PLONG  allcids;  // local identifiers
    765 
    766                 arc = DosSubAllocMem((PVOID)pBase,
    767                                      (PPVOID)(&aNames),
    768                                      (ULONG)(lCount*(ULONG)sizeof(STR8)));
    769                                              // space is needed for an array of
    770                                              // lCount longs
    771                 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 of
    777                                                 // 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 of
    784                                                     // 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 one
    818                                         lcidNext++;
    819                                         fContinue = TRUE;
    820                                     }
    821                                     // else: return that one
    822                                 }
    823                             }
    824                         }
    825                     }
    826                 }
    827             }
    828 
    829             arc = DosFreeMem(pBase);
    830         }
    831         */
    832740    }
    833741
     
    1006914 *@@changed V0.9.4 (2000-08-08) [umoeller]: added fFamily
    1007915 *@@changed V0.9.9 (2001-04-01) [umoeller]: made this thread-safe, finally
     916 *@@changed V0.9.14 (2001-08-01) [umoeller]: some optimizations
    1008917 */
    1009918
     
    1012921                  BOOL fFamily,          // in: if TRUE, pszName specifies font family;
    1013922                                         //     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)
    1015924                  USHORT usFormat,       // in: none, one or several of:
    1016925                                         // -- FATTR_SEL_ITALIC
     
    1034943                                   sizeof(FONTMETRICS),
    1035944                                   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
    1039951
    1040952    // _Pmpf(("gpihFindFont: enumerating for %s, %d points", pszFaceName, lSize));
     
    1047959                                            // -- _not_ total buffer size!
    1048960                  pfm);
     961
    1049962    // now we have an array of FONTMETRICS
    1050963    // for EVERY font that is installed on the system...
     
    1066979    FontAttrs.fsSelection = usFormat; // changed later if better font is found
    1067980    FontAttrs.lMatch = 0L;             // closest match
    1068     strcpy(FontAttrs.szFacename, pszName);
     981    strcpy(FontAttrs.szFacename, pcszName);
    1069982    FontAttrs.idRegistry = 0;          // default registry
    1070983    FontAttrs.usCodePage = 0;          // default codepage
     
    10951008               pfm2->lAveCharWidth)); */
    10961009
    1097         PSZ pszCompare = (fFamily)
    1098                               ? pfm2->szFamilyname
    1099                               : 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))
    11021015        {
    11031016            /* _Pmpf(("  Found font %s; slope %d, usWeightClass %d",
     
    11171030                    // for bitmap fonts, there are always two versions:
    11181031                    // 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
    11241041                    if (    (pfm2->sXDeviceRes == alDevRes[0])
    11251042                         && (pfm2->sYDeviceRes == alDevRes[1])
     
    11511068                                 && (pfm2->usWeightClass == 7) // bold
    11521069                                )
    1153                             ||  (   ((usFormat & FATTR_SEL_BOLD) == 0)
     1070                            ||  (   (!(usFormat & FATTR_SEL_BOLD))
    11541071                                 && (pfm2->usWeightClass == 5) // regular
    11551072                                )
     
    11581075                                 && (pfm2->sCharSlope != 0) // italics
    11591076                                )
    1160                             ||  (   ((usFormat & FATTR_SEL_ITALIC) == 0)
     1077                            ||  (   (!(usFormat & FATTR_SEL_ITALIC))
    11611078                                 && (pfm2->sCharSlope == 0) // regular
    11621079                                )
     
    20751992 *      You can then use any GPI function on the memory
    20761993 *      PS to draw into the bitmap. Use the fields from
    2077  *      _XBITMAP for that.
     1994 *      XBITMAP for that.
    20781995 *
    20791996 *      The bitmap is created in RGB mode.
     
    21442061 *
    21452062 *      To be on the safe side, this sets the
    2146  *      bitmap pointer to NULL as well.
     2063 *      given XBITMAP pointer to NULL as well.
    21472064 *
    21482065 *@@added V0.9.12 (2001-05-20) [umoeller]
Note: See TracChangeset for help on using the changeset viewer.