Handle fractional point sizes in GDI+ wxGraphicsFont

Also switch to using UnitPoint when creating GDI+ fonts as it's not
clear at all why should we use UnitPixel here.
This commit is contained in:
Vadim Zeitlin
2018-09-15 13:36:46 +02:00
parent f085981601
commit d5020362ff

View File

@@ -335,7 +335,7 @@ public:
const wxColour& col ); const wxColour& col );
wxGDIPlusFontData(wxGraphicsRenderer* renderer, wxGDIPlusFontData(wxGraphicsRenderer* renderer,
const wxString& name, const wxString& name,
REAL sizeInPixels, REAL size,
int style, int style,
const wxColour& col); const wxColour& col);
~wxGDIPlusFontData(); ~wxGDIPlusFontData();
@@ -349,8 +349,7 @@ private :
void Init(const wxString& name, void Init(const wxString& name,
REAL size, REAL size,
int style, int style,
const wxColour& col, const wxColour& col);
Unit fontUnit);
Brush* m_textBrush; Brush* m_textBrush;
Font* m_font; Font* m_font;
@@ -986,8 +985,7 @@ void
wxGDIPlusFontData::Init(const wxString& name, wxGDIPlusFontData::Init(const wxString& name,
REAL size, REAL size,
int style, int style,
const wxColour& col, const wxColour& col)
Unit fontUnit)
{ {
#if wxUSE_PRIVATE_FONTS #if wxUSE_PRIVATE_FONTS
// If the user has registered any private fonts, they should be used in // If the user has registered any private fonts, they should be used in
@@ -1007,7 +1005,7 @@ wxGDIPlusFontData::Init(const wxString& name,
int rc = gs_pFontFamily[j].GetFamilyName(familyName); int rc = gs_pFontFamily[j].GetFamilyName(familyName);
if ( rc == 0 && name == familyName ) if ( rc == 0 && name == familyName )
{ {
m_font = new Font(&gs_pFontFamily[j], size, style, fontUnit); m_font = new Font(&gs_pFontFamily[j], size, style, UnitPoint);
break; break;
} }
} }
@@ -1016,7 +1014,7 @@ wxGDIPlusFontData::Init(const wxString& name,
if ( !m_font ) if ( !m_font )
#endif // wxUSE_PRIVATE_FONTS #endif // wxUSE_PRIVATE_FONTS
{ {
m_font = new Font(name.wc_str(), size, style, fontUnit); m_font = new Font(name.wc_str(), size, style, UnitPoint);
} }
m_textBrush = new SolidBrush(wxColourToColor(col)); m_textBrush = new SolidBrush(wxColourToColor(col));
@@ -1037,19 +1035,17 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
if ( font.GetWeight() == wxFONTWEIGHT_BOLD ) if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
style |= FontStyleBold; style |= FontStyleBold;
// Create font which size is measured in logical units Init(font.GetFaceName(), font.GetFractionalPointSize(), style, col);
// and let the system rescale it according to the target resolution.
Init(font.GetFaceName(), font.GetPixelSize().GetHeight(), style, col, UnitPixel);
} }
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer, wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
const wxString& name, const wxString& name,
REAL sizeInPixels, REAL size,
int style, int style,
const wxColour& col) : const wxColour& col) :
wxGraphicsObjectRefData(renderer) wxGraphicsObjectRefData(renderer)
{ {
Init(name, sizeInPixels, style, col, UnitPixel); Init(name, size, style, col);
} }
wxGDIPlusFontData::~wxGDIPlusFontData() wxGDIPlusFontData::~wxGDIPlusFontData()