From e1146627e2bf16a48554e1c224f427dbd6247c5d Mon Sep 17 00:00:00 2001 From: David Webster Date: Thu, 24 Jan 2002 23:24:32 +0000 Subject: [PATCH] Fixing font utilities git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/font.cpp | 30 ++++++++++++++++++++---------- src/os2/fontutil.cpp | 17 ++++++----------- src/os2/utils.cpp | 16 +++++++++++++--- src/os2/wx23.def | 6 +++--- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/os2/font.cpp b/src/os2/font.cpp index e4abc8de91..8023ca58c8 100644 --- a/src/os2/font.cpp +++ b/src/os2/font.cpp @@ -363,6 +363,9 @@ bool wxFontRefData::Alloc( { wxString sFaceName; long flId = m_hFont; + long lRc; + short nIndex = 0; + PFONTMETRICS pFM = NULL; if (!m_bNativeFontInfoOk) { @@ -377,22 +380,21 @@ bool wxFontRefData::Alloc( m_bNativeFontInfoOk = TRUE; } - if(::GpiCreateLogFont( m_hPS - ,NULL - ,flId - ,&m_vNativeFontInfo.fa - ) != GPI_ERROR) + if((lRc = ::GpiCreateLogFont( m_hPS + ,NULL + ,flId + ,&m_vNativeFontInfo.fa + )) != GPI_ERROR) + { m_hFont = (WXHFONT)flId; m_nFontId = flId; - + } 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); // @@ -403,13 +405,21 @@ bool wxFontRefData::Alloc( m_nPointSize = m_vNativeFontInfo.fm.lEmHeight; 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 = wxMODERN; + 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; diff --git a/src/os2/fontutil.cpp b/src/os2/fontutil.cpp index 73610c2ac7..805b4eeb9e 100644 --- a/src/os2/fontutil.cpp +++ b/src/os2/fontutil.cpp @@ -325,6 +325,9 @@ void wxFillLogFont( wxString sVals; + // + // For debugging, delete later + // for (int i = 0; i < lNumFonts; i++) { sVals << "Face: " << pFM[i].szFacename @@ -440,12 +443,12 @@ void wxOS2SelectMatchingFontByName( int nPointSize; int nDiff; int nIs; - int nIndex; int nMinDiff; int nMinDiff0; int nApirc; int anDiff[16]; int anMinDiff[16]; + int nIndex = 0; STR8 zFn; char zFontFaceName[FACESIZE]; wxString sFaceName; @@ -612,16 +615,8 @@ void wxOS2SelectMatchingFontByName( pFattrs->lMatch = pFM[nIndex].lMatch; // force match pFattrs->idRegistry = pFM[nIndex].idRegistry; // uses default registry pFattrs->usCodePage = pFM[nIndex].usCodePage; // code-page - if(pFM[nIndex].lMatch) - { - pFattrs->lMaxBaselineExt = pFM[nIndex].lMaxBaselineExt; // requested font height - pFattrs->lAveCharWidth = pFM[nIndex].lAveCharWidth ; // requested font width - } - else - { - pFattrs->lMaxBaselineExt = 0; - pFattrs->lAveCharWidth = 0; - } + pFattrs->lMaxBaselineExt = 0; // OUTLINE fonts need this set to 0 as they use other attributes to match + pFattrs->lAveCharWidth = 0; // OUTLINE fonts need this set to 0 as they use other attributes to match pFattrs->fsType = 0;// pfm->fsType; /* uses default type */ pFattrs->fsFontUse = 0; diff --git a/src/os2/utils.cpp b/src/os2/utils.cpp index 816ed527eb..6cc381d718 100644 --- a/src/os2/utils.cpp +++ b/src/os2/utils.cpp @@ -1218,6 +1218,7 @@ void wxOS2SetFont( char zStyle[30]; if (hWnd == NULLHANDLE) + return; // // The fonts available for Presentation Params are just three @@ -1227,20 +1228,29 @@ void wxOS2SetFont( switch(rFont.GetFamily()) { case wxSCRIPT: + strcpy(zFacename, "Script"); + break; + case wxDECORATIVE: case wxROMAN: - strcpy(zFacename,"Times New Roman"); + strcpy(zFacename,"Tms Rmn"); break; case wxTELETYPE: - case wxMODERN: strcpy(zFacename, "Courier"); break; + case wxMODERN: + strcpy(zFacename, "System Vio"); + break; + case wxSWISS: + strcpy(zFacename, "Helv"); + break; + case wxDEFAULT: default: - strcpy(zFacename, "Helvetica"); + strcpy(zFacename, "System Vio"); break; } diff --git a/src/os2/wx23.def b/src/os2/wx23.def index efa02ebbf2..b073de67dd 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL CODE LOADONCALL EXPORTS -;From library: F:\DEV\WX2\WXWINDOWS\LIB\wx.lib +;From library: H:\DEV\WX2\WXWINDOWS\LIB\wx.lib ;From object file: dummy.cpp ;PUBDEFs (Symbols available from object file): wxDummyChar @@ -1772,7 +1772,7 @@ EXPORTS wxEVT_NC_LEFT_DCLICK wxEVT_INIT_DIALOG wxEVT_COMMAND_SET_FOCUS - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c ;PUBDEFs (Symbols available from object file): ConvertToIeeeExtended ConvertFromIeeeExtended @@ -5771,7 +5771,7 @@ EXPORTS Read32__17wxTextInputStreamFv ;wxTextInputStream::SkipIfEndOfLine(char) SkipIfEndOfLine__17wxTextInputStreamFc - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;PUBDEFs (Symbols available from object file): unzReadCurrentFile unzGetCurrentFileInfo