mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-17 00:23:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9e5c7abd94 Pull-request: https://github.com/SerenityOS/serenity/pull/20329
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…
Reference in a new issue