+
+ //
+ // This does the actual selection of fonts
+ //
+ wxOS2SelectMatchingFontByName( pFattrs
+ ,pFaceName
+ ,pFM
+ ,(int)lNumFonts
+ ,pFont
+ );
+ //
+ // We should now have the correct FATTRS set with the selected
+ // font, so now we need to generate an ID
+ //
+ long lNumLids = ::GpiQueryNumberSetIds(*phPS);
+ long lGpiError;
+
+ if(lNumLids )
+ {
+ long alTypes[255];
+ STR8 azNames[255];
+ long alIds[255];
+
+ if(!::GpiQuerySetIds( *phPS
+ ,lNumLids
+ ,alTypes
+ ,azNames
+ ,alIds
+ ))
+ {
+ if (bInternalPS)
+ ::WinReleasePS(*phPS);
+ return;
+ }
+
+ for(unsigned long LCNum = 0; LCNum < lNumLids; LCNum++)
+ if(alIds[LCNum] == *pflId)
+ ++*pflId;
+ if(*pflId > 254) // wow, no id available!
+ {
+ if (bInternalPS)
+ ::WinReleasePS(*phPS);
+ return;
+ }
+ }
+ else
+ *pflId = 1L;
+ //
+ // Release and delete the current font
+ //
+ ::GpiSetCharSet(*phPS, LCID_DEFAULT);/* release the font before deleting */
+ ::GpiDeleteSetId(*phPS, 1L); /* delete the logical font */
+
+ //
+ // Now build a facestring
+ //
+ char zFacename[128];
+
+ strcpy(zFacename, pFattrs->szFacename);
+
+ if(::GpiQueryFaceString( *phPS
+ ,zFacename
+ ,pFaceName
+ ,FACESIZE
+ ,pFattrs->szFacename
+ ) == GPI_ERROR)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ }
+ sFaceName = zFacename;
+ *pbInternalPS = bInternalPS;
+
+ //
+ // That's it, we now have everything we need to actually create the font
+ //
+} // end of wxFillLogFont
+
+void wxOS2SelectMatchingFontByName(
+ PFATTRS pFattrs
+, PFACENAMEDESC pFaceName
+, PFONTMETRICS pFM
+, int nNumFonts
+, const wxFont* pFont
+)
+{
+ int i;
+ int nDiff0;
+ int nPointSize;
+ int nDiff;
+ int nIs;
+ int nMinDiff;
+ int nMinDiff0;
+ int nApirc;
+ int anDiff[16];
+ int anMinDiff[16];
+ int nIndex = 0;
+ STR8 zFn;
+ char zFontFaceName[FACESIZE];
+ wxString sFaceName;
+ USHORT usWeightClass;
+ int fsSelection = 0;
+
+ nMinDiff0 = 0xf000;
+ for(i = 0;i < 16; i++)
+ anMinDiff[i] = nMinDiff0;
+