+{
+ Free();
+}
+
+bool wxFontRefData::Alloc( wxFont* pFont )
+{
+ wxString sFaceName;
+ long flId = m_hFont;
+ long lRc;
+ ERRORID vError;
+ wxString sError;
+
+ if (!m_bNativeFontInfoOk)
+ {
+ wxFillLogFont( &m_vNativeFontInfo.fa
+ ,&m_vNativeFontInfo.fn
+ ,&m_hPS
+ ,&m_bInternalPS
+ ,&flId
+ ,sFaceName
+ ,pFont
+ );
+ m_bNativeFontInfoOk = true;
+ }
+ else
+ {
+ if (flId == 0L)
+ flId = 1L;
+ else
+ flId++;
+ if (flId > 254)
+ flId = 1L;
+ }
+ if((lRc = ::GpiCreateLogFont( m_hPS
+ ,NULL
+ ,flId
+ ,&m_vNativeFontInfo.fa
+ )) != GPI_ERROR)
+ {
+ m_hFont = (WXHFONT)flId;
+ m_nFontId = flId;
+ }
+ if (!m_hFont)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogLastError(wxT("CreateFont"));
+ }
+
+ ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space
+ ::GpiQueryFontMetrics(m_hPS, sizeof(FONTMETRICS), &m_vNativeFontInfo.fm);
+
+ //
+ // Set refData members with the results
+ //
+ memcpy(&m_vFattrs, &m_vNativeFontInfo.fa, sizeof(m_vFattrs));
+ memcpy(&m_vFname, &m_vNativeFontInfo.fn, sizeof(m_vFname));
+ //
+ // Going to leave the point size alone. Mostly we use outline fonts
+ // that can be set to any point size inside of Presentation Parameters,
+ // regardless of whether or not the actual font is registered in the system.
+ // The GpiCreateLogFont will do enough by selecting the right family,
+ // and face name.
+ //
+ if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman") == 0)
+ m_nFamily = wxROMAN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Times New Roman MT 30") == 0)
+ m_nFamily = wxROMAN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "@Times New Roman MT 30") == 0)
+ m_nFamily = wxROMAN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Tms Rmn") == 0)
+ m_nFamily = wxROMAN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "WarpSans") == 0)
+ m_nFamily = wxDECORATIVE;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helvetica") == 0)
+ m_nFamily = wxSWISS;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Helv") == 0)
+ m_nFamily = wxSWISS;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Script") == 0)
+ m_nFamily = wxSCRIPT;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier New") == 0)
+ m_nFamily = wxTELETYPE;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Courier") == 0)
+ m_nFamily = wxTELETYPE;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Monospaced") == 0)
+ m_nFamily = wxTELETYPE;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System VIO") == 0)
+ m_nFamily = wxMODERN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "System Proportional") == 0)
+ m_nFamily = wxMODERN;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Arial") == 0)
+ m_nFamily = wxSWISS;
+ else if (strcmp(m_vNativeFontInfo.fm.szFamilyname, "Swiss") == 0)
+ m_nFamily = wxSWISS;
+ else
+ m_nFamily = wxSWISS;
+
+ if (m_vNativeFontInfo.fa.fsSelection & FATTR_SEL_ITALIC)
+ m_nStyle = wxFONTSTYLE_ITALIC;
+ else
+ m_nStyle = wxFONTSTYLE_NORMAL;
+ switch(m_vNativeFontInfo.fn.usWeightClass)
+ {
+ case FWEIGHT_DONT_CARE:
+ m_nWeight = wxFONTWEIGHT_NORMAL;
+ break;
+
+ case FWEIGHT_NORMAL:
+ m_nWeight = wxFONTWEIGHT_NORMAL;
+ break;
+
+ case FWEIGHT_LIGHT:
+ m_nWeight = wxFONTWEIGHT_LIGHT;
+ break;
+
+ case FWEIGHT_BOLD:
+ m_nWeight = wxFONTWEIGHT_BOLD;
+ break;
+
+ case FWEIGHT_ULTRA_BOLD:
+ m_nWeight = wxFONTWEIGHT_MAX;
+ break;
+
+ default:
+ m_nWeight = wxFONTWEIGHT_NORMAL;
+ }
+ m_bUnderlined = ((m_vNativeFontInfo.fa.fsSelection & FATTR_SEL_UNDERSCORE) != 0);
+ m_sFaceName = (wxChar*)m_vNativeFontInfo.fa.szFacename;
+ m_vEncoding = wxGetFontEncFromCharSet(m_vNativeFontInfo.fa.usCodePage);
+
+ //
+ // We don't actuall keep the font around if using a temporary PS
+ //
+ if (m_bInternalPS)
+ {
+ if(m_hFont)
+ ::GpiDeleteSetId( m_hPS
+ ,flId
+ );
+
+ ::WinReleasePS(m_hPS);
+ }
+ else
+ //
+ // Select the font into the Presentation space
+ //
+ ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space
+ return true;
+} // end of wxFontRefData::Alloc
+
+void wxFontRefData::Free()