Use fractional point sizes in wxRichText code

When scaling, just use the floating point result directly instead of
rounding it.
This commit is contained in:
Vadim Zeitlin
2018-09-15 12:44:50 +02:00
parent 03f29d4b67
commit c302a8d1e7
2 changed files with 8 additions and 13 deletions

View File

@@ -6843,7 +6843,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
{
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))
{
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
wxCheckSetFont(dc, textFont);
charHeight = dc.GetCharHeight();
}
@@ -6859,8 +6859,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(size));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
x = rect.x;
y = rect.y;
}
@@ -6878,8 +6877,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(size));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
x = rect.x;
int sub_height = static_cast<int>(static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
y = rect.y + (rect.height - sub_height + (descent - m_descent));
@@ -7197,8 +7195,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
}
else
{
double textSize = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(textSize));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
}
wxCheckSetFont(dc, textFont);
bScript = true;
@@ -7206,7 +7203,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
else if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))
{
wxFont textFont = font;
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
wxCheckSetFont(dc, textFont);
bScript = true;
}
@@ -9264,8 +9261,7 @@ void wxRichTextStdRenderer::SetFontForBullet(wxRichTextBuffer& buffer, wxDC& dc,
}
else
{
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
textFont.SetPointSize(static_cast<int>(size));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
}
wxCheckSetFont(dc, textFont);
}
@@ -9278,7 +9274,7 @@ void wxRichTextStdRenderer::SetFontForBullet(wxRichTextBuffer& buffer, wxDC& dc,
}
else
{
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
}
wxCheckSetFont(dc, textFont);

View File

@@ -516,8 +516,7 @@ void wxRichTextFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
if ((GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) || (GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT))
{
double fontSize = static_cast<double>(font.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
font.SetPointSize( static_cast<int>(fontSize) );
font.SetFractionalPointSize(font.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
}
if ( font.IsOk() )