mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
LibGfx: Insert pixel and ttf fonts into Typeface structure
This adds a new structure 'Typeface' to the FontDatabase that represents all fonts of the same family and variant. It can contain a list of BitmapFonts with varying size but of the same family and weight or a pointer to a single TTF font for all sizes of this Typeface.
This commit is contained in:
parent
2c4e13f14a
commit
179dba652e
13 changed files with 248 additions and 32 deletions
|
@ -473,7 +473,7 @@ String Font::family() const
|
|||
return m_name.family_name();
|
||||
}
|
||||
|
||||
String Font::subfamily() const
|
||||
String Font::variant() const
|
||||
{
|
||||
auto string = m_name.typographic_subfamily_name();
|
||||
if (!string.is_empty())
|
||||
|
@ -520,4 +520,30 @@ RefPtr<Gfx::Bitmap> ScaledFont::raster_glyph(u32 glyph_id) const
|
|||
return glyph_bitmap;
|
||||
}
|
||||
|
||||
Gfx::Glyph ScaledFont::glyph(u32 code_point) const
|
||||
{
|
||||
auto id = glyph_id_for_codepoint(code_point);
|
||||
auto bitmap = raster_glyph(id);
|
||||
return Gfx::Glyph(bitmap);
|
||||
}
|
||||
|
||||
u8 ScaledFont::glyph_width(size_t code_point) const
|
||||
{
|
||||
auto id = glyph_id_for_codepoint(code_point);
|
||||
auto metrics = glyph_metrics(id);
|
||||
return metrics.advance_width;
|
||||
}
|
||||
|
||||
int ScaledFont::glyph_or_emoji_width(u32 code_point) const
|
||||
{
|
||||
auto id = glyph_id_for_codepoint(code_point);
|
||||
auto metrics = glyph_metrics(id);
|
||||
return metrics.advance_width;
|
||||
}
|
||||
|
||||
u8 ScaledFont::glyph_fixed_width() const
|
||||
{
|
||||
return (u8)m_x_scale;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue