fix(ios): register custom fonts by URL instead of the deprecated graphics-font API by NathanWalker · Pull Request #11698 · NativeScript/NativeScript
Repository navigation
fix(ios): register custom fonts by URL instead of the deprecated graphics-font API - #11698
Open
NathanWalker wants to merge 1 commit into main from fix/ios-font-registration-url
Open
fix(ios): register custom fonts by URL instead of the deprecated graphics-font API #11698 NathanWalker wants to merge 1 commit into main from fix/ios-font-registration-url
Conversation
NathanWalker commented Dec 1, 2026
Copy link Copy Markdown
Contributor
PR Checklist
- The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/main/tools/notes/CONTRIBUTING.md#commit-messages .
- There is an issue for the bug/feature this PR is for. Follow-up to fix(ios): resolve computed weights for variable fonts #11619 (review note on the deprecated registration API).
- You have read and signed the CLA .
- All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/main/tools/notes/DevelopmentWorkflow.md#unit-testing .
- Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/main/tools/notes/WritingUnitTests.md .
What is the current behavior?
ios.registerFont (which also registers every .ttf/.otf in the app's fonts folder at startup) loads the whole file into memory and registers it with CTFontManagerRegisterGraphicsFont, which has been deprecated since iOS 18. That API registers a single CGFont, so only a variable font's default instance and only the first face of a font collection are visible to UIKit.
What is the new behavior?
Font files are registered with CTFontManagerRegisterFontsForURL at process scope, which Apple names as the replacement. It doesn't read the file into JS memory first, and it exposes every face in the file. For the bundled SN Pro variable font, UIFont.fontNamesForFamilyName('SN Pro') now lists all eight named instances (SNPro-Regular through SNPro-Black) instead of just the default one.
Error handling is unchanged:
- A missing file, or a file that isn't a valid font (
kCTFontManagerErrorUnrecognizedFormat/kCTFontManagerErrorInvalidFontData), still throwsCould not load font from: <file>. - Other registration failures, such as a font that is already registered, are still only traced.
The public API (ios.registerFont(fontFile)) is unchanged.
New FONT-REGISTRATION device tests (iOS) cover the missing-file and invalid-data throws, registering the same font twice, and the named instances being exposed.
Validation:
- Core unit tests pass.
- Full
apps/automatediOS suite on an iOS 27.0 simulator: 1861 OK, 0 failed. This includes the existing Roboto registration tests and the variable-font tests from fix(ios): resolve computed weights for variable fonts #11619 .
fix(ios): register custom fonts by URL instead of the deprecated grap...
4cfa182
...hics-font API CTFontManagerRegisterGraphicsFont is deprecated since iOS 18. Register font files with CTFontManagerRegisterFontsForURL at process scope instead, which Apple names as the replacement. It also exposes every face in the file: the named instances of a variable font and all fonts in a collection. Missing files and files that aren't valid fonts still throw "Could not load font from"; other registration failures, such as a font that is already registered, are still only traced.
nx-cloud
Bot
commented
Dec 1, 2026
·
edited
Loading
Copy link Copy Markdown
|
View your CI Pipeline Execution ↗ for commit 4cfa182
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
pkg-pr-new
Bot
commented
Dec 1, 2026
Copy link Copy Markdown
commit: |
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment