mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibGfx: Add dummy Font::x_height() getter
Right now we just guess that the x-height is glyph_height/2, which is obviously not accurate. We currently don't store the x-height in fonts, so that's something we'll need to fix.
This commit is contained in:
parent
fae9c9f81f
commit
0bbced444b
Notes:
sideshowbarker
2024-07-19 04:09:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0bbced444b8
2 changed files with 7 additions and 0 deletions
|
@ -137,6 +137,9 @@ Font::Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_wid
|
|||
, m_glyph_spacing(glyph_spacing)
|
||||
, m_fixed_width(is_fixed_width)
|
||||
{
|
||||
// FIXME: This is just a dumb guess. It would be cool to know the actual x-height of the font!
|
||||
m_x_height = glyph_height / 2;
|
||||
|
||||
m_glyph_count = glyph_count_by_type(m_type);
|
||||
|
||||
if (!m_fixed_width) {
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
u8 glyph_width(size_t ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[ch]; }
|
||||
int glyph_or_emoji_width(u32 code_point) const;
|
||||
u8 glyph_height() const { return m_glyph_height; }
|
||||
int x_height() const { return m_x_height; }
|
||||
|
||||
u8 min_glyph_width() const { return m_min_glyph_width; }
|
||||
u8 max_glyph_width() const { return m_max_glyph_width; }
|
||||
u8 glyph_fixed_width() const { return m_glyph_width; }
|
||||
|
@ -121,6 +123,7 @@ public:
|
|||
|
||||
FontTypes type() { return m_type; }
|
||||
void set_type(FontTypes type);
|
||||
|
||||
private:
|
||||
Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type);
|
||||
|
||||
|
@ -137,6 +140,7 @@ private:
|
|||
|
||||
u8 m_glyph_width { 0 };
|
||||
u8 m_glyph_height { 0 };
|
||||
u8 m_x_height { 0 };
|
||||
u8 m_min_glyph_width { 0 };
|
||||
u8 m_max_glyph_width { 0 };
|
||||
u8 m_glyph_spacing { 0 };
|
||||
|
|
Loading…
Add table
Reference in a new issue