Initialize point size correctly from v0 native font info strings

Reading native font info strings in v0 format, used by the previous
wxWidgets versions, resulted in creation of fonts with 0 point size,
which resulted in suboptimal user experience when such a font was used
to display text.

Fix this by initializing point size to the value corresponding to the
font height in pixels using the default DPI, just as we already do when
creating wxNativeFontInfo from a LOGFONT.
This commit is contained in:
Vadim Zeitlin 2019-07-16 14:37:19 +02:00
parent 5507f8eebc
commit 228cd926e2

View File

@ -658,11 +658,13 @@ bool wxNativeFontInfo::FromString(const wxString& s)
if ( !token.ToLong(&l) ) if ( !token.ToLong(&l) )
return false; return false;
bool setPointSizeFromHeight = false;
switch ( l ) switch ( l )
{ {
case 0: case 0:
// Fractional point size is not present in this version. // Fractional point size is not present in this version, it will be
pointSize = 0.0f; // set from lfHeight below in this case.
setPointSizeFromHeight = true;
break; break;
case 1: case 1:
@ -685,6 +687,8 @@ bool wxNativeFontInfo::FromString(const wxString& s)
if ( !token.ToLong(&l) ) if ( !token.ToLong(&l) )
return false; return false;
lf.lfHeight = l; lf.lfHeight = l;
if ( setPointSizeFromHeight )
pointSize = GetPointSizeFromLogFontHeight(l);
token = tokenizer.GetNextToken(); token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) ) if ( !token.ToLong(&l) )