From 20ea92ce6f53518aea21177f8c7d736117a7d407 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 16 May 2024 15:55:19 -0700 Subject: [PATCH] [Impeller] use smaller SkFont size for determining glyph bounds. (flutter/engine#52868) Applies the fix that @jason-simmons previously suggested in https://github.com/flutter/flutter/issues/128624#issuecomment-1846473830 I'm not sure if these results are better or not ... but I think we try and make this change to see if things are improved anyway? Leaving up golden diffs for others to look at. --- .../impeller/typographer/backends/skia/text_frame_skia.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/typographer/backends/skia/text_frame_skia.cc b/engine/src/flutter/impeller/typographer/backends/skia/text_frame_skia.cc index d39e36ad2b..fdf2b3d68a 100644 --- a/engine/src/flutter/impeller/typographer/backends/skia/text_frame_skia.cc +++ b/engine/src/flutter/impeller/typographer/backends/skia/text_frame_skia.cc @@ -36,7 +36,7 @@ static Rect ToRect(const SkRect& rect) { return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); } -static constexpr Scalar kScaleSize = 100000.0f; +static constexpr Scalar kScaleSize = 64.0f; std::shared_ptr MakeTextFrameFromTextBlobSkia( const sk_sp& blob) { @@ -59,7 +59,8 @@ std::shared_ptr MakeTextFrameFromTextBlobSkia( // For some platforms (including Android), `SkFont::getBounds()` snaps // the computed bounds to integers. And so we scale up the font size // prior to fetching the bounds to ensure that the returned bounds are - // always precise enough. + // always precise enough. Scaling too large will cause Skia to use + // path rendering and potentially inaccurate glyph sizes. font.setSize(kScaleSize); font.getBounds(glyphs, glyph_count, glyph_bounds.data(), nullptr);