Add wxNativeFontInfo::GetPointSizeFromLogFontHeight() helper
No real changes, just refactor the code previously present in both wxNativeFontInfo ctor and SetPixelSize() in a single function and reuse it in both places.
This commit is contained in:
@@ -118,7 +118,14 @@ public:
|
||||
// set the XFLD
|
||||
void SetXFontName(const wxString& xFontName);
|
||||
#elif defined(__WXMSW__)
|
||||
wxNativeFontInfo(const LOGFONT& lf_);
|
||||
wxNativeFontInfo(const LOGFONT& lf_)
|
||||
: lf(lf_),
|
||||
pointSize(GetPointSizeFromLogFontHeight(lf.lfHeight))
|
||||
{
|
||||
}
|
||||
|
||||
// MSW-specific: get point size from LOGFONT height using the default DPI.
|
||||
static float GetPointSizeFromLogFontHeight(int height);
|
||||
|
||||
// MSW-specific: get the height value in pixels using LOGFONT convention
|
||||
// (i.e. negative) corresponding to the given size in points and DPI.
|
||||
|
@@ -402,13 +402,13 @@ void wxFontRefData::Free()
|
||||
// wxNativeFontInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxNativeFontInfo::wxNativeFontInfo(const LOGFONT& lf_)
|
||||
: lf(lf_)
|
||||
/* static */
|
||||
float wxNativeFontInfo::GetPointSizeFromLogFontHeight(int height)
|
||||
{
|
||||
// Determine the size in points using the primary screen DPI as we don't
|
||||
// have anything else here.
|
||||
const float ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
||||
pointSize = 72.0f * abs(lf.lfHeight) / ppi;
|
||||
return 72.0f * abs(height) / ppi;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::Init()
|
||||
@@ -535,8 +535,7 @@ void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)
|
||||
|
||||
// We don't have the right DPI to use here neither, but we need to update
|
||||
// the point size too, so fall back to the default.
|
||||
const float ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
||||
pointSize = 72.0f * pixelSize.GetHeight() / ppi;
|
||||
pointSize = GetPointSizeFromLogFontHeight(lf.lfHeight);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
|
Reference in New Issue
Block a user