+ //
+ // Matching logic to find the right FM struct
+ //
+ nIndex = 0;
+ for(i = 0, nIs = 0; i < nNumFonts; i++)
+ {
+ int nEmHeight = 0;
+ int nXHeight = 0;
+
+ anDiff[0] = wxGpiStrcmp(pFM[i].szFamilyname, zFontFaceName);
+ anDiff[1] = abs(pFM[i].lEmHeight - nPointSize);
+ anDiff[2] = abs(pFM[i].usWeightClass - usWeightClass);
+ anDiff[3] = abs((pFM[i].fsSelection & 0x2f) - fsSelection);
+ if(anDiff[0] == 0)
+ {
+ nEmHeight = (int)pFM[i].lEmHeight;
+ nXHeight =(int)pFM[i].lXHeight;
+ if( (nIs & 0x01) == 0)
+ {
+ nIs = 1;
+ nIndex = i;
+ anMinDiff[1] = anDiff[1];
+ anMinDiff[2] = anDiff[2];
+ anMinDiff[3] = anDiff[3];
+ }
+ else if(anDiff[3] < anMinDiff[3])
+ {
+ nIndex = i;
+ anMinDiff[3] = anDiff[3];
+ }
+ else if(anDiff[2] < anMinDiff[2])
+ {
+ nIndex = i;
+ anMinDiff[2] = anDiff[2];
+ }
+ else if(anDiff[1] < anMinDiff[1])
+ {
+ nIndex = i;
+ anMinDiff[1] = anDiff[1];
+ }
+ anMinDiff[0] = 0;
+ }
+ else if(anDiff[0] < anMinDiff[0])
+ {
+ nIs = 2;
+ nIndex = i;
+ anMinDiff[3] = anDiff[3];
+ anMinDiff[2] = anDiff[2];
+ anMinDiff[1] = anDiff[1];
+ anMinDiff[0] = anDiff[0];
+ }
+ else if(anDiff[0] == anMinDiff[0])
+ {
+ if(anDiff[3] < anMinDiff[3])
+ {
+ nIndex = i;
+ anMinDiff[3] = anDiff[3];
+ nIs = 2;
+ }
+ else if(anDiff[2] < anMinDiff[2])
+ {
+ nIndex = i;
+ anMinDiff[2] = anDiff[2];
+ nIs = 2;
+ }
+ else if(anDiff[1] < anMinDiff[1])
+ {
+ nIndex = i;
+ anMinDiff[1] = anDiff[1];
+ nIs = 2;
+ }
+ }
+ }
+
+ //
+ // Fill in the FATTRS with the best match from FONTMETRICS
+ //
+ pFattrs->usRecordLength = sizeof(FATTRS); // sets size of structure
+ pFattrs->fsSelection = pFM[nIndex].fsSelection; // uses default selection
+ pFattrs->lMatch = pFM[nIndex].lMatch; // force match
+ pFattrs->idRegistry = pFM[nIndex].idRegistry; // uses default registry
+ pFattrs->usCodePage = pFM[nIndex].usCodePage; // code-page
+ pFattrs->lMaxBaselineExt = 0; // OUTLINE fonts need this set to 0 as they use other attributes to match
+ pFattrs->lAveCharWidth = 0; // OUTLINE fonts need this set to 0 as they use other attributes to match
+ pFattrs->fsType = 0;// pfm->fsType; /* uses default type */
+ pFattrs->fsFontUse = 0;
+
+ wxStrcpy(pFattrs->szFacename, pFM[nIndex].szFacename);
+ // Debug
+ strcpy(zFontFaceName, pFM[nIndex].szFacename);
+ strcpy(zFontFaceName, pFattrs->szFacename);
+
+ if(usWeightClass >= FWEIGHT_BOLD)
+ pFattrs->fsSelection |= FATTR_SEL_BOLD;
+ if(pFont->GetUnderlined())
+ pFattrs->fsSelection |= FATTR_SEL_UNDERSCORE;
+ if(fsSelection & FM_SEL_ITALIC)
+ pFattrs->fsSelection |= FATTR_SEL_ITALIC;
+} // end of wxOS2SelectMatchingFontByName
+
+wxFont wxCreateFontFromLogFont(
+ const LOGFONT* pLogFont
+, const PFONTMETRICS pFM
+, PFACENAMEDESC pFaceName
+)
+{
+ wxNativeFontInfo vInfo;
+
+ vInfo.fa = *pLogFont;
+ vInfo.fm = *pFM;
+ vInfo.fn = *pFaceName;
+ return wxFont(vInfo);
+} // end of wxCreateFontFromLogFont
+
+int wxGpiStrcmp(
+ char* s0
+, char* s1
+)
+{ int l0;
+ int l1;
+ int l;
+ int d;
+ int d1;
+ int i;
+ int rc;
+
+ rc = 0;
+ if(s0 == NULL)
+ {
+ if(s1 == NULL)
+ return 0;
+ else
+ return 32;