1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +00:00

LibGfx+FontEditor+Fonts: Add "mean line" value to all fonts

The main inspiration behind this was to have a correct ex CSS unit.
The mean line is based off what it shows in the CSS Values and Units
Level 4 specification, section 6.1.1.

https://www.w3.org/TR/css-values-4/#font-relative-lengths
This commit is contained in:
Luke 2020-10-05 16:19:37 +01:00 committed by Andreas Kling
parent 043b31ad9a
commit 52c31bb743
19 changed files with 55 additions and 13 deletions

View file

@ -101,7 +101,18 @@ public:
u8 glyph_fixed_width() const { return m_glyph_width; }
u8 baseline() const { return m_baseline; }
void set_baseline(u8 baseline) { m_baseline = baseline; }
void set_baseline(u8 baseline)
{
m_baseline = baseline;
update_x_height();
}
u8 mean_line() const { return m_mean_line; }
void set_mean_line(u8 mean_line)
{
m_mean_line = mean_line;
update_x_height();
}
int width(const StringView&) const;
int width(const Utf8View&) const;
@ -132,11 +143,13 @@ public:
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, u8 baseline);
Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line);
static RefPtr<Font> load_from_memory(const u8*);
static size_t glyph_count_by_type(FontTypes type);
void update_x_height() { m_x_height = m_mean_line - m_baseline; };
void set_family_fonts();
RefPtr<Font> m_bold_family_font;
@ -155,6 +168,7 @@ private:
u8 m_max_glyph_width { 0 };
u8 m_glyph_spacing { 0 };
u8 m_baseline { 0 };
u8 m_mean_line { 0 };
bool m_fixed_width { false };
bool m_boldface { false };