+ //
+ // 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].szFacename, 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->lMatch = pFM[nIndex].lMatch; // Force match
+ pFattrs->idRegistry = 0;
+ pFattrs->usCodePage = 0;
+ pFattrs->fsFontUse = 0;
+ pFattrs->fsType = 0;
+ pFattrs->lMaxBaselineExt = 0;
+ pFattrs->lAveCharWidth = 0;
+ wxStrcpy(pFattrs->szFacename, pFM[nIndex].szFacename);
+ if (pFont->GetWeight() == wxNORMAL)
+ pFattrs->fsSelection = 0;
+ else
+ pFattrs->fsSelection = FATTR_SEL_BOLD;
+
+ if (pFont->GetStyle() == wxITALIC || pFont->GetStyle() == wxSLANT)
+ pFattrs->fsSelection |= FATTR_SEL_ITALIC;
+
+ if (pFont->GetUnderlined())
+ pFattrs->fsSelection |= FATTR_SEL_UNDERSCORE;
+} // 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;