+ return M_FONTDATA->m_vEncoding;
+} // end of wxFont::GetEncoding
+
+HPS wxFont::GetPS() const
+{
+ return M_FONTDATA->m_hPS;
+} // end of wxFont::GetPS
+
+void wxFont::OS2SelectMatchingFontByName()
+{
+ int i;
+ int nDiff0;
+ int nDiff;
+ int nIs;
+ int nIndex;
+ int nMinDiff;
+ int nMinDiff0;
+ int nApirc;
+ int anDiff[16];
+ int anMinDiff[16];
+ STR8 zFn;
+ char zFontFaceName[FACESIZE];
+ wxString sFaceName;
+ USHORT usWeightClass;
+ int fsSelection = 0;
+
+ nMinDiff0 = 0xf000;
+ for(i = 0;i < 16; i++)
+ anMinDiff[i] = nMinDiff0;
+
+ switch (GetFamily())
+ {
+ case wxSCRIPT:
+ sFaceName = wxT("Script");
+ break;
+
+ case wxDECORATIVE:
+ case wxROMAN:
+ sFaceName = wxT("Times New Roman");
+ break;
+
+ case wxTELETYPE:
+ case wxMODERN:
+ sFaceName = wxT("Courier") ;
+ break;
+
+ case wxSWISS:
+ sFaceName = wxT("WarpSans") ;
+ break;
+
+ case wxDEFAULT:
+ default:
+ sFaceName = wxT("Helv") ;
+ }
+
+ switch (GetWeight())
+ {
+ default:
+ wxFAIL_MSG(_T("unknown font weight"));
+ // fall through
+ usWeightClass = FWEIGHT_DONT_CARE;
+ break;
+
+ case wxNORMAL:
+ usWeightClass = FWEIGHT_NORMAL;
+ break;
+
+ case wxLIGHT:
+ usWeightClass = FWEIGHT_LIGHT;
+ break;
+
+ case wxBOLD:
+ usWeightClass = FWEIGHT_BOLD;
+ break;
+
+ case wxFONTWEIGHT_MAX:
+ usWeightClass = FWEIGHT_ULTRA_BOLD;
+ break;
+ }
+ M_FONTDATA->m_vFname.usWeightClass = usWeightClass;
+
+ switch (GetStyle())
+ {
+ case wxITALIC:
+ case wxSLANT:
+ fsSelection = FM_SEL_ITALIC;
+ M_FONTDATA->m_vFname.flOptions = FTYPE_ITALIC;
+ break;
+
+ default:
+ wxFAIL_MSG(wxT("unknown font slant"));
+ // fall through
+
+ case wxNORMAL:
+ fsSelection = 0;
+ break;
+ }
+
+ wxStrncpy(zFontFaceName, sFaceName.c_str(), WXSIZEOF(zFontFaceName));
+ M_FONTDATA->m_nPointSize = GetPointSize();
+ nIndex = 0;
+ for(i = 0, nIs = 0; i < M_FONTDATA->m_nNumFonts; i++)
+ {
+ // Debug code
+ int nPointSize = M_FONTDATA->m_nPointSize;
+ int nEmHeight = 0;
+ int nXHeight = 0;
+ anDiff[0] = wxGpiStrcmp(M_FONTDATA->m_pFM[i].szFamilyname, zFontFaceName);
+ anDiff[1] = abs(M_FONTDATA->m_pFM[i].lEmHeight - M_FONTDATA->m_nPointSize);
+ anDiff[2] = abs(M_FONTDATA->m_pFM[i].usWeightClass - usWeightClass);
+ anDiff[3] = abs((M_FONTDATA->m_pFM[i].fsSelection & 0x2f) - fsSelection);
+ if(anDiff[0] == 0)
+ {
+ nEmHeight = (int)M_FONTDATA->m_pFM[i].lEmHeight;
+ nXHeight =(int)M_FONTDATA->m_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;
+ }
+ }
+ }
+
+ M_FONTDATA->m_vFattrs.usRecordLength = sizeof(FATTRS); // sets size of structure
+ M_FONTDATA->m_vFattrs.fsSelection = M_FONTDATA->m_pFM[nIndex].fsSelection; // uses default selection
+ M_FONTDATA->m_vFattrs.lMatch = M_FONTDATA->m_pFM[nIndex].lMatch; // force match
+ M_FONTDATA->m_vFattrs.idRegistry = M_FONTDATA->m_pFM[nIndex].idRegistry; // uses default registry
+ M_FONTDATA->m_vFattrs.usCodePage = M_FONTDATA->m_pFM[nIndex].usCodePage; // code-page
+ if(M_FONTDATA->m_pFM[nIndex].lMatch)
+ {
+ M_FONTDATA->m_vFattrs.lMaxBaselineExt = M_FONTDATA->m_pFM[nIndex].lMaxBaselineExt; // requested font height
+ M_FONTDATA->m_vFattrs.lAveCharWidth = M_FONTDATA->m_pFM[nIndex].lAveCharWidth ; // requested font width
+ }
+ else
+ {
+ M_FONTDATA->m_vFattrs.lMaxBaselineExt = 0;
+ M_FONTDATA->m_vFattrs.lAveCharWidth = 0;
+ }
+ M_FONTDATA->m_vFattrs.fsType = 0;// pfm->fsType; /* uses default type */
+ M_FONTDATA->m_vFattrs.fsFontUse = 0;
+
+ wxStrcpy(M_FONTDATA->m_vFattrs.szFacename, M_FONTDATA->m_pFM[nIndex].szFacename);
+ // Debug
+ strcpy(zFontFaceName, M_FONTDATA->m_pFM[nIndex].szFacename);
+ strcpy(zFontFaceName, M_FONTDATA->m_vFattrs.szFacename);
+
+ if(usWeightClass >= FWEIGHT_BOLD)
+ M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_BOLD;
+ if(GetUnderlined())
+ M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_UNDERSCORE;
+ if(fsSelection & FM_SEL_ITALIC)
+ M_FONTDATA->m_vFattrs.fsSelection |= FATTR_SEL_ITALIC;