X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d0a6b27997bc37c69ebae7e5a6e84d0b1b816970..91b4bd63177025704dd39679a2a7c4198eeb7909:/src/os2/font.cpp diff --git a/src/os2/font.cpp b/src/os2/font.cpp index 623f7fd444..c1839db1ca 100644 --- a/src/os2/font.cpp +++ b/src/os2/font.cpp @@ -108,8 +108,13 @@ public: // inline int GetPointSize(void) const { - return m_bNativeFontInfoOk ? m_vNativeFontInfo.GetPointSize() - : m_nPointSize; + // + // We don't use the actual native font point size since it is + // the chosen physical font, which is usually only and approximation + // of the desired outline font. The actual displayable point size + // is the one stored in the refData + // + return m_nPointSize; } inline int GetFamily(void) const @@ -362,13 +367,17 @@ bool wxFontRefData::Alloc( ) { wxString sFaceName; - long flId; + long flId = m_hFont; + long lRc; + short nIndex = 0; + PFONTMETRICS pFM = NULL; if (!m_bNativeFontInfoOk) { wxFillLogFont( &m_vNativeFontInfo.fa ,&m_vNativeFontInfo.fn - ,m_hPS + ,&m_hPS + ,&m_bInternalPS ,&flId ,sFaceName ,pFont @@ -376,54 +385,52 @@ bool wxFontRefData::Alloc( m_bNativeFontInfoOk = TRUE; } - if(::GpiCreateLogFont( m_hPS - ,NULL - ,flId - ,&m_vNativeFontInfo.fa - ) != GPI_ERROR) - m_hFont = (WXHFONT)1; - - // - // We don't actuall keep the font around if using a temporary PS - // - if (m_bInternalPS) + if((lRc = ::GpiCreateLogFont( m_hPS + ,NULL + ,flId + ,&m_vNativeFontInfo.fa + )) != GPI_ERROR) { - if(m_hFont) - ::GpiDeleteSetId( m_hPS - ,flId - ); - - ::WinReleasePS(m_hPS); + m_hFont = (WXHFONT)flId; + m_nFontId = flId; } - else - // - // Select the font into the Presentation space - // - ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space if (!m_hFont) { wxLogLastError("CreateFont"); } - // - // Query for the actual metrics of the current font being used - // + ::GpiSetCharSet(m_hPS, flId); // sets font for presentation space ::GpiQueryFontMetrics(m_hPS, sizeof(FONTMETRICS), &m_vNativeFontInfo.fm); // // Set refData members with the results // - m_hFont = (WXHFONT)m_nFontId; memcpy(&m_vFattrs, &m_vNativeFontInfo.fa, sizeof(m_vFattrs)); memcpy(&m_vFname, &m_vNativeFontInfo.fn, sizeof(m_vFname)); - m_nPointSize = m_vNativeFontInfo.fm.lEmHeight; + // + // 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.fa.szFacename, "Times New Roman") == 0) m_nFamily = wxROMAN; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Tms Rmn") == 0) + m_nFamily = wxSWISS; else if (strcmp(m_vNativeFontInfo.fa.szFacename, "WarpSans") == 0) m_nFamily = wxSWISS; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Helvitica") == 0) + m_nFamily = wxSWISS; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Helv") == 0) + m_nFamily = wxSWISS; else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Script") == 0) m_nFamily = wxSCRIPT; else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier New") == 0) + m_nFamily = wxTELETYPE; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier") == 0) + m_nFamily = wxTELETYPE; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "System VIO") == 0) m_nFamily = wxMODERN; else m_nFamily = wxSWISS; @@ -460,6 +467,24 @@ bool wxFontRefData::Alloc( m_bUnderlined = ((m_vNativeFontInfo.fa.fsSelection & FATTR_SEL_UNDERSCORE) != 0); m_sFaceName = 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