Repository navigation
fix(🔤): accept a TypefaceFontProvider wherever a FontMgr is expected - #4541
Merged
wcandillon merged 1 commit intoNov 26, 2026
Merged
wcandillon merged 1 commit into
wcandillon merged 1 commit into
Conversation
Skia.SVG.MakeFromString and MakeFromData document useFonts() as their font manager, and SkTypefaceFontProvider extends SkFontMgr in the types, on the web and in Skia itself. On iOS and Android, JsiSkFontMgr::fromValue only accepted a JsiSkFontMgr, so passing a provider threw "Expected FontMgr but got different type". fromValue now also unwraps a JsiSkTypefaceFontProvider; anything else still goes through the strict check.
wcandillon
self-requested a review
November 26, 2026 07:10
wcandillon
approved these changes
Nov 26, 2026
wcandillon
pushed a commit
that referenced
this pull request
Nov 26, 2026
…(2.x backport of #4541) (#4542) Skia.SVG.MakeFromString and MakeFromData document useFonts() as their font manager, and SkTypefaceFontProvider extends SkFontMgr in the types, on the web and in Skia itself. On iOS and Android, JsiSkFontMgr::fromValue only accepted a JsiSkFontMgr, so passing a provider threw "Expected FontMgr but got different type". fromValue now also unwraps a JsiSkTypefaceFontProvider; anything else still goes through the strict check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4543
I ran into this bug while building an Expo 58 app that renders SVGs with text using
useFonts()the way the SVG docs show, and the app crashed on native withExpected FontMgr but got different type.TypefaceFontProvideralready extendsSkFontMgrin TypeScript, on web, and in Skia C++, butJsiSkFontMgr::fromValuerejected its native object.(Translated from Portuguese with AI.)
Agent-written content
Summary
packages/skia/cpp/api/JsiSkFontMgr.h,JsiSkFontMgr::fromValuenow checkstryGetJsiObject<JsiSkTypefaceFontProvider>(runtime, obj)first and returnsprovider->getObject()(whosesk_sp<skia::textlayout::TypefaceFontProvider>converts implicitly tosk_sp<SkFontMgr>).objectFromValue(runtime, obj), preserving the strictExpected FontMgr but got different typeerror for invalid objects and the disposed-object check on disposed providers.JsiSkSVGFactory(MakeFromStringandMakeFromData) is the only native caller today; typedsk_sp<SkFontMgr>arguments viaJSIConverterget the same behavior automatically.JsiSkTypefaceFontProvider.hdoes not includeJsiSkFontMgr.h, andJsiSkParagraphBuilder.halready includes both).Tests (
packages/skia/src/renderer/__tests__/e2e/SVG.spec.tsx)MakeFromStringandMakeFromDataaccept aTypefaceFontProviderwith Roboto registered, and drawing<text font-family="Roboto">paints pixels on an offscreen surface.FontMgr.System()continues to work.FontMgrobject (Skia.Paint()) still throwsExpected FontMgr but got different type.Local verification
cpplint(exactci.ymlcommand),clang-format,eslint,prettier,yarn tsc, andclang++ -std=c++20 -fsyntax-onlyagainst the pinned Skia headers all passed.