Skip to content

Commit 9e5c7ab

Browse files
committed
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.
1 parent 58e3b8c commit 9e5c7ab

File tree

1 file changed

+2
-4
lines changed
  • Userland/Libraries/LibGfx/Font/OpenType

1 file changed

+2
-4
lines changed

Userland/Libraries/LibGfx/Font/OpenType/Font.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,9 @@ Gfx::ScaledGlyphMetrics Font::glyph_metrics(u32 glyph_id, float x_scale, float y
671671
auto horizontal_metrics = m_hmtx.get_glyph_horizontal_metrics(glyph_id);
672672
auto glyph_offset = m_loca->get_glyph_offset(glyph_id);
673673
auto glyph = m_glyf->glyph(glyph_offset);
674-
if (!glyph.has_value())
675-
return {};
676674
return Gfx::ScaledGlyphMetrics {
677-
.ascender = static_cast<float>(glyph->ascender()) * y_scale,
678-
.descender = static_cast<float>(glyph->descender()) * y_scale,
675+
.ascender = glyph.has_value() ? static_cast<float>(glyph->ascender()) * y_scale : 0,
676+
.descender = glyph.has_value() ? static_cast<float>(glyph->descender()) * y_scale : 0,
679677
.advance_width = static_cast<float>(horizontal_metrics.advance_width) * x_scale,
680678
.left_side_bearing = static_cast<float>(horizontal_metrics.left_side_bearing) * x_scale,
681679
};

0 commit comments

Comments
 (0)