Correctly use pixelSize in wxGraphicsContext::CreateFont
It is documented as using pixel size, and this is also used in all other contexts.
For clarity, rename all parameters to sizeInPixels.
This partially reverts d5020362ff
This commit is contained in:
@@ -948,12 +948,12 @@ wxGraphicsFont wxGraphicsContext::CreateFont( const wxFont &font , const wxColou
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsFont
|
wxGraphicsFont
|
||||||
wxGraphicsContext::CreateFont(double size,
|
wxGraphicsContext::CreateFont(double sizeInPixels,
|
||||||
const wxString& facename,
|
const wxString& facename,
|
||||||
int flags,
|
int flags,
|
||||||
const wxColour& col) const
|
const wxColour& col) const
|
||||||
{
|
{
|
||||||
return GetRenderer()->CreateFont(size, facename, flags, col);
|
return GetRenderer()->CreateFont(sizeInPixels, facename, flags, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsBitmap wxGraphicsContext::CreateBitmap( const wxBitmap& bmp ) const
|
wxGraphicsBitmap wxGraphicsContext::CreateBitmap( const wxBitmap& bmp ) const
|
||||||
|
@@ -345,14 +345,14 @@ public:
|
|||||||
const wxColour& col );
|
const wxColour& col );
|
||||||
wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
const wxColour& col);
|
const wxColour& col);
|
||||||
|
|
||||||
// This ctor takes ownership of the brush.
|
// This ctor takes ownership of the brush.
|
||||||
wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
Brush* textBrush);
|
Brush* textBrush);
|
||||||
|
|
||||||
@@ -365,17 +365,17 @@ private :
|
|||||||
// Common part of all ctors, flags here is a combination of values of
|
// Common part of all ctors, flags here is a combination of values of
|
||||||
// FontStyle GDI+ enum.
|
// FontStyle GDI+ enum.
|
||||||
void Init(const wxString& name,
|
void Init(const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
Brush* textBrush);
|
Brush* textBrush);
|
||||||
|
|
||||||
// Common part of ctors taking wxColour.
|
// Common part of ctors taking wxColour.
|
||||||
void Init(const wxString& name,
|
void Init(const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
const wxColour& col)
|
const wxColour& col)
|
||||||
{
|
{
|
||||||
Init(name, size, style, new SolidBrush(wxColourToColor(col)));
|
Init(name, sizeInPixels, style, new SolidBrush(wxColourToColor(col)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Brush* m_textBrush;
|
Brush* m_textBrush;
|
||||||
@@ -656,7 +656,7 @@ public :
|
|||||||
virtual wxGraphicsFont CreateFont( const wxFont& font,
|
virtual wxGraphicsFont CreateFont( const wxFont& font,
|
||||||
const wxColour& col) wxOVERRIDE;
|
const wxColour& col) wxOVERRIDE;
|
||||||
|
|
||||||
virtual wxGraphicsFont CreateFont(double size,
|
virtual wxGraphicsFont CreateFont(double sizeInPixels,
|
||||||
const wxString& facename,
|
const wxString& facename,
|
||||||
int flags = wxFONTFLAG_DEFAULT,
|
int flags = wxFONTFLAG_DEFAULT,
|
||||||
const wxColour& col = *wxBLACK) wxOVERRIDE;
|
const wxColour& col = *wxBLACK) wxOVERRIDE;
|
||||||
@@ -1105,7 +1105,7 @@ extern const wxArrayString& wxGetPrivateFontFileNames();
|
|||||||
|
|
||||||
void
|
void
|
||||||
wxGDIPlusFontData::Init(const wxString& name,
|
wxGDIPlusFontData::Init(const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
Brush* textBrush)
|
Brush* textBrush)
|
||||||
{
|
{
|
||||||
@@ -1127,7 +1127,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, UnitPoint);
|
m_font = new Font(&gs_pFontFamily[j], sizeInPixels, style, UnitPixel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1136,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, UnitPoint);
|
m_font = new Font(name.wc_str(), sizeInPixels, style, UnitPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_textBrush = textBrush;
|
m_textBrush = textBrush;
|
||||||
@@ -1157,27 +1157,27 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
|
|||||||
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
||||||
style |= FontStyleBold;
|
style |= FontStyleBold;
|
||||||
|
|
||||||
Init(font.GetFaceName(), font.GetFractionalPointSize(), style, col);
|
Init(font.GetFaceName(), (REAL)(font.GetPixelSize().GetHeight()), style, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
const wxColour& col) :
|
const wxColour& col) :
|
||||||
wxGraphicsObjectRefData(renderer)
|
wxGraphicsObjectRefData(renderer)
|
||||||
{
|
{
|
||||||
Init(name, size, style, col);
|
Init(name, sizeInPixels, style, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||||
const wxString& name,
|
const wxString& name,
|
||||||
REAL size,
|
REAL sizeInPixels,
|
||||||
int style,
|
int style,
|
||||||
Brush* brush)
|
Brush* brush)
|
||||||
: wxGraphicsObjectRefData(renderer)
|
: wxGraphicsObjectRefData(renderer)
|
||||||
{
|
{
|
||||||
Init(name, size, style, brush);
|
Init(name, sizeInPixels, style, brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusFontData::~wxGDIPlusFontData()
|
wxGDIPlusFontData::~wxGDIPlusFontData()
|
||||||
@@ -2732,7 +2732,7 @@ wxGDIPlusRenderer::CreateFont( const wxFont &font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsFont
|
wxGraphicsFont
|
||||||
wxGDIPlusRenderer::CreateFont(double size,
|
wxGDIPlusRenderer::CreateFont(double sizeInPixels,
|
||||||
const wxString& facename,
|
const wxString& facename,
|
||||||
int flags,
|
int flags,
|
||||||
const wxColour& col)
|
const wxColour& col)
|
||||||
@@ -2752,7 +2752,7 @@ wxGDIPlusRenderer::CreateFont(double size,
|
|||||||
|
|
||||||
|
|
||||||
wxGraphicsFont f;
|
wxGraphicsFont f;
|
||||||
f.SetRefData(new wxGDIPlusFontData(this, facename, size, style, col));
|
f.SetRefData(new wxGDIPlusFontData(this, facename, sizeInPixels, style, col));
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2876,9 +2876,7 @@ wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, c
|
|||||||
m_font->GetWeight(),
|
m_font->GetWeight(),
|
||||||
m_font->GetStyle(),
|
m_font->GetStyle(),
|
||||||
m_font->GetStretch(),
|
m_font->GetStretch(),
|
||||||
// We need to use DIP units for the font size, with 1dip = 1/96in,
|
(FLOAT)(font.GetPixelSize().GetHeight()),
|
||||||
// while wxFont uses points with 1pt = 1/72in.
|
|
||||||
font.GetFractionalPointSize()*96/72,
|
|
||||||
L"en-us",
|
L"en-us",
|
||||||
&m_textFormat);
|
&m_textFormat);
|
||||||
|
|
||||||
@@ -4651,7 +4649,7 @@ public :
|
|||||||
wxGraphicsFont CreateFont(const wxFont& font, const wxColour& col) wxOVERRIDE;
|
wxGraphicsFont CreateFont(const wxFont& font, const wxColour& col) wxOVERRIDE;
|
||||||
|
|
||||||
wxGraphicsFont CreateFont(
|
wxGraphicsFont CreateFont(
|
||||||
double size, const wxString& facename,
|
double sizeInPixels, const wxString& facename,
|
||||||
int flags = wxFONTFLAG_DEFAULT,
|
int flags = wxFONTFLAG_DEFAULT,
|
||||||
const wxColour& col = *wxBLACK) wxOVERRIDE;
|
const wxColour& col = *wxBLACK) wxOVERRIDE;
|
||||||
|
|
||||||
@@ -4904,12 +4902,12 @@ wxGraphicsFont wxD2DRenderer::CreateFont(const wxFont& font, const wxColour& col
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsFont wxD2DRenderer::CreateFont(
|
wxGraphicsFont wxD2DRenderer::CreateFont(
|
||||||
double size, const wxString& facename,
|
double sizeInPixels, const wxString& facename,
|
||||||
int flags,
|
int flags,
|
||||||
const wxColour& col)
|
const wxColour& col)
|
||||||
{
|
{
|
||||||
return CreateFont(
|
return CreateFont(
|
||||||
wxFontInfo(size).AllFlags(flags).FaceName(facename),
|
wxFontInfo(wxSize(sizeInPixels, sizeInPixels)).AllFlags(flags).FaceName(facename),
|
||||||
col);
|
col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user