Store fractional point size in wxMSW wxNativeFontInfo

We can't losslessly recover the fractional point size from LOGFONT, so
store it in parallel.
This commit is contained in:
Vadim Zeitlin
2018-09-12 17:49:21 +02:00
parent 4be459d98e
commit 2823e289d8
2 changed files with 15 additions and 1 deletions

View File

@@ -118,9 +118,14 @@ public:
// set the XFLD
void SetXFontName(const wxString& xFontName);
#elif defined(__WXMSW__)
wxNativeFontInfo(const LOGFONT& lf_) : lf(lf_) { }
wxNativeFontInfo(const LOGFONT& lf_) : lf(lf_), pointSize(0.0f) { }
LOGFONT lf;
// MSW only has limited support for fractional point sizes and we need to
// store the fractional point size separately if it was initially specified
// as we can't losslessly recover it from LOGFONT later.
float pointSize;
#elif defined(__WXOSX__)
public:
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }

View File

@@ -440,10 +440,15 @@ void wxNativeFontInfo::Init()
lf.lfQuality = wxSystemOptions::GetOptionInt("msw.font.no-proof-quality")
? DEFAULT_QUALITY
: PROOF_QUALITY;
pointSize = 0.0f;
}
float wxNativeFontInfo::GetFractionalPointSize() const
{
if ( pointSize != 0.0f )
return pointSize;
// FIXME: using the screen here results in incorrect font size calculation
// for printing!
const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
@@ -531,6 +536,10 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
{
// Store it to be able to return it from GetFractionalPointSize() later
// exactly.
pointSize = pointsize;
// FIXME: using the screen here results in incorrect font size calculation
// for printing!
const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);