mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibGfx/OpenType: Return metrics from hmtx even if there is no glyf entry
This fixes an issue with some typefaces where the space character has an advance width, but no glyf entry (and thus no ascent/descent). Before this change, we'd render whitespace with zero advance in such cases.
This commit is contained in:
parent
58e3b8cf58
commit
9e5c7abd94
1 changed files with 2 additions and 4 deletions
|
@ -671,11 +671,9 @@ Gfx::ScaledGlyphMetrics Font::glyph_metrics(u32 glyph_id, float x_scale, float y
|
|||
auto horizontal_metrics = m_hmtx.get_glyph_horizontal_metrics(glyph_id);
|
||||
auto glyph_offset = m_loca->get_glyph_offset(glyph_id);
|
||||
auto glyph = m_glyf->glyph(glyph_offset);
|
||||
if (!glyph.has_value())
|
||||
return {};
|
||||
return Gfx::ScaledGlyphMetrics {
|
||||
.ascender = static_cast<float>(glyph->ascender()) * y_scale,
|
||||
.descender = static_cast<float>(glyph->descender()) * y_scale,
|
||||
.ascender = glyph.has_value() ? static_cast<float>(glyph->ascender()) * y_scale : 0,
|
||||
.descender = glyph.has_value() ? static_cast<float>(glyph->descender()) * y_scale : 0,
|
||||
.advance_width = static_cast<float>(horizontal_metrics.advance_width) * x_scale,
|
||||
.left_side_bearing = static_cast<float>(horizontal_metrics.left_side_bearing) * x_scale,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue