From: Vadim Zeitlin Date: Thu, 11 Jan 2001 16:26:24 +0000 (+0000) Subject: applied Derry's patch to fix scaling bug X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6c49baf214ccd8b3330c2910b19246d767e7344d?ds=inline applied Derry's patch to fix scaling bug git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9077 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 2c371f3c1f..9b0395e839 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -110,8 +110,8 @@ static wxNativeFont wxLoadQueryFont(int pointSize, // encodingid;registry;encoding[;facename] bool wxNativeEncodingInfo::FromString(const wxString& s) { + // use ";", not "-" because it may be part of encoding name wxStringTokenizer tokenizer(s, _T(";")); - // cannot use "-" because it may be part of encoding name wxString encid = tokenizer.GetNextToken(); long enc; @@ -274,13 +274,34 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize, } } } - + // OK, we have the correct xregistry/xencoding in info structure wxNativeFont font = 0; // if we already have the X font name, try to use it if( xFontName && !xFontName->IsEmpty() ) - font = wxLoadFont(*xFontName); + { + // + // Make sure point size is correct for scale factor. + // + wxStringTokenizer tokenizer(*xFontName, _T("-"), wxTOKEN_RET_DELIMS); + wxString newFontName; + + for(int i = 0; i < 8; i++) + newFontName += tokenizer.NextToken(); + + (void) tokenizer.NextToken(); + + newFontName += wxString::Format("%d-", pointSize); + + while(tokenizer.HasMoreTokens()) + newFontName += tokenizer.GetNextToken(); + + font = wxLoadFont(newFontName); + + if(font) + *xFontName = newFontName; + } if( !font ) font = wxLoadQueryFont( pointSize, family, style, weight, @@ -360,13 +381,12 @@ static bool wxTestFontSpec(const wxString& fontspec) wxNativeFont test = (wxNativeFont) g_fontHash->Get( fontspec ); if (test) { -// printf( "speed up\n" ); return TRUE; } test = wxLoadFont(fontspec); g_fontHash->Put( fontspec, (wxObject*) test ); - + if ( test ) { wxFreeFont(test);