feat: enable reading fonts registered via addCustomFont#55711
Closed
vonovak wants to merge 1 commit intofacebook:mainfrom
Closed
feat: enable reading fonts registered via addCustomFont#55711vonovak wants to merge 1 commit intofacebook:mainfrom
vonovak wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
cortinico
approved these changes
Feb 27, 2026
Contributor
cortinico
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Collaborator
|
This pull request was successfully merged by @vonovak in c3acbc4 When will my fix make it into a release? | How to file a pick request? |
zoontek
pushed a commit
to zoontek/react-native
that referenced
this pull request
Mar 9, 2026
Summary: `ReactFontManager` has a write-only API for custom fonts — you can register fonts but there's no way to query what's been registered. This asymmetry means a library that needs to know about font availability needs to use reflection on the private `customTypefaceCache` map, or maintain a custom registry that can easily go out of sync. This becomes a problem when multiple libraries need to cooperate around fonts. Today when a library registers a font, there's no clean way for another library to discover what the first one registered. This adds a `customFontFamilies` property that returns the set of font family names currently in the custom typeface cache. Only `customTypefaceCache` is exposed in this PR because it contains fonts explicitly registered by library code via `addCustomFont()`, whereas `fontCache` is lazily populated as a side effect of `getTypeface()` calls and its contents depend on what has been requested so far rather than what is available. Asset-based fonts (in `assets/fonts/`) already have a discoverable source of truth - the filesystem. ## Changelog: [ANDROID] [ADDED] - `ReactFontManager.customFontFamilies` property to query registered custom font family names Pull Request resolved: facebook#55711 Test Plan: - tested ok by adding ```kt val customFonts = ReactFontManager.getInstance().customFontFamilies Log.d("RNTesterApplication", "customFontFamilies: $customFonts") ``` prints: `customFontFamilies: [Rubik, FiraCode]` [here](https://github.com/facebook/react-native/blob/9353eb55b877e6e51c35c6041eebd72971c6b9a5/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt#L123) Reviewed By: cortinico Differential Revision: D94665574 Pulled By: javache fbshipit-source-id: 07d802ac98f4a738858038a2af6ce8d85c28b5ce
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.
Summary:
ReactFontManagerhas a write-only API for custom fonts — you can register fonts but there's no way to query what's been registered. This asymmetry means a library that needs to know about font availability needs to use reflection on the privatecustomTypefaceCachemap, or maintain a custom registry that can easily go out of sync.This becomes a problem when multiple libraries need to cooperate around fonts. Today when a library registers a font, there's no clean way for another library to discover what the first one registered.
This adds a
customFontFamiliesproperty that returns the set of font family names currently in the custom typeface cache.Only
customTypefaceCacheis exposed in this PR because it contains fonts explicitly registered by library code viaaddCustomFont(), whereasfontCacheis lazily populated as a side effect ofgetTypeface()calls and its contents depend on what has been requested so far rather than what is available.Asset-based fonts (in
assets/fonts/) already have a discoverable source of truth - the filesystem.Changelog:
[ANDROID] [ADDED] -
ReactFontManager.customFontFamiliesproperty to query registered custom font family namesTest Plan:
prints:
customFontFamilies: [Rubik, FiraCode]here