1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:37:35 +00:00

LibGfx: Avoid rounding/truncating glyph positions till blitting

This keeps some overloads that accept ints to avoid adding calls to
.to_type<float>() all over the place.
This commit is contained in:
MacDue 2023-01-01 19:42:00 +01:00 committed by Andreas Kling
parent 68f678f566
commit a1726b1ba5
14 changed files with 172 additions and 106 deletions

View file

@ -44,7 +44,7 @@ enum class FitWithinRect {
// b) Taking the Lines from TextLayout and painting each glyph.
class TextLayout {
public:
TextLayout(Gfx::Font const* font, Utf8View const& text, IntRect const& rect)
TextLayout(Gfx::Font const* font, Utf8View const& text, FloatRect const& rect)
: m_font(font)
, m_text(text)
, m_rect(rect)
@ -57,15 +57,15 @@ public:
Utf8View const& text() const { return m_text; }
void set_text(Utf8View const& text) { m_text = text; }
IntRect const& rect() const { return m_rect; }
void set_rect(IntRect const& rect) { m_rect = rect; }
FloatRect const& rect() const { return m_rect; }
void set_rect(FloatRect const& rect) { m_rect = rect; }
Vector<DeprecatedString, 32> lines(TextElision elision, TextWrapping wrapping, int line_spacing) const
{
return wrap_lines(elision, wrapping, line_spacing, FitWithinRect::Yes);
}
IntRect bounding_rect(TextWrapping wrapping, int line_spacing) const;
FloatRect bounding_rect(TextWrapping wrapping, int line_spacing) const;
private:
Vector<DeprecatedString, 32> wrap_lines(TextElision, TextWrapping, int line_spacing, FitWithinRect) const;
@ -73,7 +73,7 @@ private:
Font const* m_font;
Utf8View m_text;
IntRect m_rect;
FloatRect m_rect;
};
}