Handle fractional point sizes in DirectWrite wxGraphicsFont
Also stop scaling the font size by DPI manually, we don't need to do it if we use points instead of pixels. This, in turn, made it unnecessary to pass ID2D1Factory parameter to wxD2DFontData ctor.
This commit is contained in:
@@ -2637,7 +2637,7 @@ wxD2DPenData* wxGetD2DPenData(const wxGraphicsPen& pen)
|
||||
class wxD2DFontData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2d1Factory, const wxFont& font, const wxColor& color);
|
||||
wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, const wxColor& color);
|
||||
|
||||
wxCOMPtr<IDWriteTextLayout> CreateTextLayout(const wxString& text) const;
|
||||
|
||||
@@ -2662,7 +2662,7 @@ private:
|
||||
bool m_strikethrough;
|
||||
};
|
||||
|
||||
wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2dFactory, const wxFont& font, const wxColor& color) :
|
||||
wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, const wxColor& color) :
|
||||
wxGraphicsObjectRefData(renderer), m_brushData(renderer, wxBrush(color)),
|
||||
m_underlined(font.GetUnderlined()), m_strikethrough(font.GetStrikethrough())
|
||||
{
|
||||
@@ -2715,16 +2715,15 @@ wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2dFact
|
||||
hr = familyNames->GetString(0, name, length+1);
|
||||
wxCHECK_HRESULT_RET(hr);
|
||||
|
||||
FLOAT dpiX, dpiY;
|
||||
d2dFactory->GetDesktopDpi(&dpiX, &dpiY);
|
||||
|
||||
hr = wxDWriteFactory()->CreateTextFormat(
|
||||
name,
|
||||
NULL,
|
||||
m_font->GetWeight(),
|
||||
m_font->GetStyle(),
|
||||
m_font->GetStretch(),
|
||||
(FLOAT)(font.GetPixelSize().GetHeight()) / (dpiY / 96.0),
|
||||
// We need to use DIP units for the font size, with 1dip = 1/96in,
|
||||
// while wxFont uses points with 1pt = 1/72in.
|
||||
font.GetFractionalPointSize()*96/72,
|
||||
L"en-us",
|
||||
&m_textFormat);
|
||||
|
||||
@@ -4708,7 +4707,7 @@ wxImage wxD2DRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp)
|
||||
|
||||
wxGraphicsFont wxD2DRenderer::CreateFont(const wxFont& font, const wxColour& col)
|
||||
{
|
||||
wxD2DFontData* fontData = new wxD2DFontData(this, GetD2DFactory(), font, col);
|
||||
wxD2DFontData* fontData = new wxD2DFontData(this, font, col);
|
||||
if ( !fontData->GetFont() )
|
||||
{
|
||||
// Apparently a non-TrueType font is given and hence
|
||||
|
Reference in New Issue
Block a user