Repository navigation
fix(🔤): apply TextStyle fontVariations on native - #4338
Merged
wcandillon merged 2 commits intoOct 27, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wcandillon
self-requested a review
October 27, 2026 08:53
…license Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 3.8.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Before / after
wght100 → 1000 → 100, same code on both sides: 3.8.0 on the left never changes, this PR on the right follows the axis.One row per variation, 3.8.0 on the left, this PR on the right.
Problem
fontVariationson a text style has no effect on iOS and Android: a variable font always renders its default instance. Requestingwght100 or 1000,wdth25 or 151, oropsz8 or 144 gives the same glyphs and the same width. The same code works on web.Roboto Flex at 34 pt on an iPhone 15 Pro (iOS 26.5), width from
getLongestLine():wght100wght1000wdth25wdth151opsz8opsz144No issue reports it; I searched the tracker for
fontVariations, "variable font" and "font variation".Root cause
fontVariationsis part ofSkTextStyle(src/skia/types/Paragraph/TextStyle.ts) and the web implementation passes it to CanvasKit (src/skia/web/JsiSkTextStyle.ts), but the native parser incpp/api/JsiSkTextStyle.hhas no branch for it. It readsfontFeaturesand moves on tofontSize, so the axes never reach skparagraph.Solution
Parse
fontVariationsnext tofontFeatures:TextStyle::setFontArgumentscopies the coordinates, so the local vector can go out of scope.cpp/apiis shared by iOS and Android. No public API change.Tests
ParagraphMethods.spec.tsx, "should apply fontVariations", lays out "Hello" with Roboto Flex and checks thatwght100 is narrower,wght1000 wider andwdth25 narrower than the default instance. The font is a 4.7 KB subset of Roboto Flex (SIL OFL, no reserved font name) with only the "Hello" glyphs and thewghtandwdthaxes, added assrc/skia/__tests__/assets/RobotoFlex-Hello.ttf.The test passes in Jest on
maintoo, since CanvasKit already applies the variations. On a device it fails onmain, where all four widths are equal, and passes with this PR. The Android e2e job runs this spec (it only skipsParagraphs); the iOS job skips every Paragraph spec.Verification
On
39d14f7with this branch:yarn lint·yarn tsc· cpplint (the CI flags): cleanyarn test: 117 suites, 894 tests passed (15 suites skipped)yarn test-cpp·yarn build: passedyarn test:web: 41 passede2e/ParagraphMethods.spec.tsxon a Galaxy Z Fold6 (Android 16) against the example app: 10 passed. WithJsiSkTextStyle.hback tomain, the new test fails (wght100 measures 55.125, the same as the default).The lint, build, web and device runs were done with this branch and the
plusLighter/plusDarkerfix (#4337) applied together. The two touch different files.Not covered
On iOS the system font from
FontMgr.System().matchFamilyStyle(".AppleSystemUIFont", …)still ignores variations with this PR, while the same SF file loaded withTypeface.MakeFromDatahonors them. I haven't found the cause, so it isn't part of this PR.Related
2.xhas the same gap (itsJsiSkTextStyle.hdoesn't readfontVariationseither); I can open a backport if you want one.Base
39d14f7🤖 Generated with Claude Code