wxGDIPlusFontData only needs wxGDIPlusContext to get the font unit to use, so
pass the font unit directly to the ctor to allow also using it when there is
no context at hand.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69357
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
virtual Brush* GetGDIPlusBrush() { return m_textBrush; }
virtual Font* GetGDIPlusFont() { return m_font; }
virtual Brush* GetGDIPlusBrush() { return m_textBrush; }
virtual Font* GetGDIPlusFont() { return m_font; }
+ // Common part of all ctors, flags here is a combination of values of
+ // FontStyle GDI+ enum.
+ void Init(const wxString& name,
+ REAL size,
+ int style,
+ const wxColour& col,
+ Unit fontUnit = UnitPixel);
+
Brush* m_textBrush;
Font* m_font;
};
Brush* m_textBrush;
Font* m_font;
};
// wxGDIPlusFont implementation
//-----------------------------------------------------------------------------
// wxGDIPlusFont implementation
//-----------------------------------------------------------------------------
+void
+wxGDIPlusFontData::Init(const wxString& name,
+ REAL size,
+ int style,
+ const wxColour& col,
+ Unit fontUnit)
+{
+ // This scaling is needed when we use unit other than the
+ // default UnitPoint. It works for both display and printing.
+ size *= 100.0f / 72.0f;
+
+ m_font = new Font(name, size, style, fontUnit);
+
+ m_textBrush = new SolidBrush(wxColourToColor(col));
+}
+
wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
const wxGDIPlusContext* gc,
const wxFont &font,
const wxColour& col )
: wxGraphicsObjectRefData( renderer )
{
wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
const wxGDIPlusContext* gc,
const wxFont &font,
const wxColour& col )
: wxGraphicsObjectRefData( renderer )
{
- wxWCharBuffer s = font.GetFaceName().wc_str( *wxConvUI );
int style = FontStyleRegular;
if ( font.GetStyle() == wxFONTSTYLE_ITALIC )
style |= FontStyleItalic;
int style = FontStyleRegular;
if ( font.GetStyle() == wxFONTSTYLE_ITALIC )
style |= FontStyleItalic;
if ( fontUnit == UnitDisplay )
fontUnit = UnitPixel;
if ( fontUnit == UnitDisplay )
fontUnit = UnitPixel;
- REAL points = font.GetPointSize();
-
- // This scaling is needed when we use unit other than the
- // default UnitPoint. It works for both display and printing.
- REAL size = points * (100.0 / 72.0);
-
// NB: font unit should match context's unit. We can use UnitPixel,
// as that is what the print context should use.
// NB: font unit should match context's unit. We can use UnitPixel,
// as that is what the print context should use.
- m_font = new Font( s, size, style, fontUnit );
-
- m_textBrush = new SolidBrush(wxColourToColor(col));
+ Init(font.GetFaceName(), font.GetPointSize(), style, col, fontUnit);
}
wxGDIPlusFontData::~wxGDIPlusFontData()
}
wxGDIPlusFontData::~wxGDIPlusFontData()