mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibGfx: Make Font::pixel_size() return a float
Here's yet another place where we were chopping of decimals.
This commit is contained in:
parent
09a125bcab
commit
bfa7381852
4 changed files with 6 additions and 6 deletions
|
@ -42,7 +42,7 @@ public:
|
||||||
u8 presentation_size() const override { return m_presentation_size; }
|
u8 presentation_size() const override { return m_presentation_size; }
|
||||||
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
||||||
|
|
||||||
virtual int pixel_size() const override { return m_glyph_height; }
|
virtual float pixel_size() const override { return m_glyph_height; }
|
||||||
virtual float point_size() const override { return static_cast<float>(m_glyph_height) * 0.75f; }
|
virtual float point_size() const override { return static_cast<float>(m_glyph_height) * 0.75f; }
|
||||||
|
|
||||||
u16 weight() const override { return m_weight; }
|
u16 weight() const override { return m_weight; }
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
virtual FontPixelMetrics pixel_metrics() const = 0;
|
virtual FontPixelMetrics pixel_metrics() const = 0;
|
||||||
|
|
||||||
virtual u8 presentation_size() const = 0;
|
virtual u8 presentation_size() const = 0;
|
||||||
virtual int pixel_size() const = 0;
|
virtual float pixel_size() const = 0;
|
||||||
virtual float point_size() const = 0;
|
virtual float point_size() const = 0;
|
||||||
virtual u8 slope() const = 0;
|
virtual u8 slope() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
virtual NonnullRefPtr<Font> clone() const override { return MUST(try_clone()); } // FIXME: clone() should not need to be implemented
|
virtual NonnullRefPtr<Font> clone() const override { return MUST(try_clone()); } // FIXME: clone() should not need to be implemented
|
||||||
virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const override { return *this; }
|
virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const override { return *this; }
|
||||||
virtual u8 presentation_size() const override { return m_point_height; }
|
virtual u8 presentation_size() const override { return m_point_height; }
|
||||||
virtual int pixel_size() const override { return m_point_height * 1.33333333f; }
|
virtual float pixel_size() const override { return m_point_height * 1.33333333f; }
|
||||||
virtual float point_size() const override { return m_point_height; }
|
virtual float point_size() const override { return m_point_height; }
|
||||||
virtual Gfx::FontPixelMetrics pixel_metrics() const override;
|
virtual Gfx::FontPixelMetrics pixel_metrics() const override;
|
||||||
virtual u8 slope() const override { return m_font->slope(); }
|
virtual u8 slope() const override { return m_font->slope(); }
|
||||||
|
|
|
@ -1391,8 +1391,8 @@ void Painter::draw_emoji(IntPoint point, Gfx::Bitmap const& emoji, Font const& f
|
||||||
IntRect dst_rect {
|
IntRect dst_rect {
|
||||||
point.x(),
|
point.x(),
|
||||||
point.y(),
|
point.y(),
|
||||||
font.pixel_size() * emoji.width() / emoji.height(),
|
static_cast<int>(ceilf(font.pixel_size() * emoji.width() / emoji.height())),
|
||||||
font.pixel_size()
|
static_cast<int>(ceilf(font.pixel_size())),
|
||||||
};
|
};
|
||||||
draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
|
draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
|
||||||
}
|
}
|
||||||
|
@ -2443,7 +2443,7 @@ void Gfx::Painter::draw_ui_text(Gfx::IntRect const& rect, StringView text, Gfx::
|
||||||
Optional<size_t> underline_offset;
|
Optional<size_t> underline_offset;
|
||||||
auto name_to_draw = parse_ampersand_string(text, &underline_offset);
|
auto name_to_draw = parse_ampersand_string(text, &underline_offset);
|
||||||
|
|
||||||
Gfx::IntRect text_rect { 0, 0, font.width(name_to_draw), font.pixel_size() };
|
Gfx::IntRect text_rect { 0, 0, font.width(name_to_draw), static_cast<int>(ceilf(font.pixel_size())) };
|
||||||
text_rect.align_within(rect, text_alignment);
|
text_rect.align_within(rect, text_alignment);
|
||||||
|
|
||||||
draw_text(text_rect, name_to_draw, font, text_alignment, color);
|
draw_text(text_rect, name_to_draw, font, text_alignment, color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue