@@ -219,7 +219,7 @@ static std::vector<ShapedGlyph> lowLevelShape (Span<const juce_wchar> string,
219219{
220220 static const auto language = SystemStats::getDisplayLanguage ();
221221
222- HbBuffer buffer { hb_buffer_create () };
222+ HbBuffer buffer { hb_buffer_create (), IncrementRef::no };
223223 hb_buffer_clear_contents (buffer.get ());
224224
225225 hb_buffer_set_cluster_level (buffer.get (), HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES);
@@ -316,20 +316,14 @@ static std::vector<ShapedGlyph> lowLevelShape (Span<const juce_wchar> string,
316316 const auto xAdvanceBase = HbScale::hbToJuce (positions[visualIndex].x_advance );
317317 const auto yAdvanceBase = -HbScale::hbToJuce (positions[visualIndex].y_advance );
318318
319- // For certain OS, Font and glyph ID combinations harfbuzz will not find extents data and
320- // hb_font_get_glyph_extents will return false. In such cases Typeface::getGlyphBounds
321- // will return an empty rectangle. Here we need to distinguish this situation from the one
322- // where extents information is available and is an empty rectangle, which indicates a
323- // whitespace.
324- const auto extentsDataAvailable = std::invoke ([&]
325- {
326- hb_glyph_extents_t extents{};
327- return hb_font_get_glyph_extents (font.getTypefacePtr ()->getNativeDetails ().getFont (),
328- (hb_codepoint_t ) glyphId,
329- &extents);
330- });
319+ // For certain OS, Font and glyph ID combinations harfbuzz will not find extents data.
320+ // In such cases Typeface::getGlyphBounds will return an empty rectangle. Here we need
321+ // to distinguish this situation from the one where extents information is available
322+ // and is an empty rectangle, which indicates a whitespace.
323+ const auto * native = font.getTypefacePtr ()->getNativeDetails ();
324+ const auto extents = native->getGlyphExtents (glyphId);
331325
332- const auto whitespace = extentsDataAvailable
326+ const auto whitespace = extents. has_value ()
333327 && font.getTypefacePtr ()->getGlyphBounds (font.getMetricsKind (), (int ) glyphId).isEmpty ()
334328 && xAdvanceBase > 0 ;
335329
0 commit comments