diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h index f7ba39237e..38f473654e 100644 --- a/include/wx/fontutil.h +++ b/include/wx/fontutil.h @@ -122,7 +122,16 @@ public: // MSW-specific: get the height value in pixels using LOGFONT convention // (i.e. negative) corresponding to the given size in points and DPI. - int GetLogFontHeightAtPPI(int ppi) const; + static int GetLogFontHeightAtPPI(float size, int ppi) + { + return -wxRound(size * ppi / 72.0); + } + + // And the same thing for the size of this font. + int GetLogFontHeightAtPPI(int ppi) const + { + return GetLogFontHeightAtPPI(pointSize, ppi); + } LOGFONT lf; diff --git a/src/msw/font.cpp b/src/msw/font.cpp index aa18cc8bd4..255aafcdae 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -509,31 +509,14 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const return wxGetFontEncFromCharSet(lf.lfCharSet); } -int wxNativeFontInfo::GetLogFontHeightAtPPI(int ppi) const -{ - return -wxRound(pointSize * ppi / 72.0); -} - void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew) { - if ( pointSize == 0.0f ) - { - // Do this before calling GetLogFontHeightAtPPI() below. - pointSize = pointSizeNew; + // We don't have the correct DPI to use here, so use that of the + // primary screen. + const int ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY); + lf.lfHeight = GetLogFontHeightAtPPI(pointSizeNew, ppi); - // We don't have the correct DPI to use here, so use that of the - // primary screen. - const int ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY); - lf.lfHeight = GetLogFontHeightAtPPI(ppi); - } - else // Changing the size of a valid font. - { - // Scale the font using the ratio of sizes, to ensure that we use the - // same DPI as before. - lf.lfHeight = -wxRound(abs(lf.lfHeight) * pointSizeNew / pointSize); - - pointSize = pointSizeNew; - } + pointSize = pointSizeNew; } void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)