mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
ShapedText: Fix falsely marking glyphs with missing extent information as whitespace
This commit is contained in:
parent
bd14d47211
commit
503788fd0c
1 changed files with 18 additions and 1 deletions
|
|
@ -511,11 +511,28 @@ static std::vector<ShapedGlyph> lowLevelShape (const String& string,
|
|||
const auto glyphId = infos[j].codepoint;
|
||||
const auto xAdvance = positions[j].x_advance;
|
||||
|
||||
// For certain OS, Font and glyph ID combinations harfbuzz will not find extents data and
|
||||
// hb_font_get_glyph_extents will return false. In such cases Typeface::getGlyphBounds
|
||||
// will return an empty rectangle. Here we need to distinguish this situation from the one
|
||||
// where extents information is available and is an empty rectangle, which indicates a
|
||||
// whitespace.
|
||||
const auto extentsDataAvailable = std::invoke ([&]
|
||||
{
|
||||
hb_glyph_extents_t extents{};
|
||||
return hb_font_get_glyph_extents (font.getTypefacePtr()->getNativeDetails().getFont(),
|
||||
(hb_codepoint_t) glyphId,
|
||||
&extents);
|
||||
});
|
||||
|
||||
const auto whitespace = extentsDataAvailable
|
||||
&& font.getTypefacePtr()->getGlyphBounds (font.getMetricsKind(), (int) glyphId).isEmpty()
|
||||
&& xAdvance > 0;
|
||||
|
||||
glyphs.push_back ({
|
||||
glyphId,
|
||||
(int64) infos[j].cluster + range.getStart(),
|
||||
(infos[j].mask & HB_GLYPH_FLAG_UNSAFE_TO_BREAK) != 0,
|
||||
font.getTypefacePtr()->getGlyphBounds (font.getMetricsKind(), (int) glyphId).isEmpty() && xAdvance > 0,
|
||||
whitespace,
|
||||
Point<float> { HbScale::hbToJuce (xAdvance) + trackingAmount, -HbScale::hbToJuce (positions[j].y_advance) },
|
||||
Point<float> { HbScale::hbToJuce (positions[j].x_offset), -HbScale::hbToJuce (positions[j].y_offset) },
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue