feat(android): add fontSize and fontFamily to customStyle - #758
Open
kacperzolkiewski wants to merge 6 commits into
Open
Conversation
kacperzolkiewski
changed the base branch from
@kacperzolkiewski/feat-custom-style-font
to
@kacperzolkiewski/feat-custom-style-web-font
August 11, 2026 08:09
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the Android implementation of customStyle to support fontSize and fontFamily end-to-end (JS command payload → span application → selection/state emission → HTML parse/serialize).
Changes:
- Adds
fontSizeandfontFamilytoCustomStyleand propagates them through span state/selection and custom-style span application. - Updates span factories and custom style span implementations to carry
AssetManager+allowFontScalingso fonts and size can be applied consistently. - Extends HTML parsing/serialization to read/write
font-sizeandfont-familywithin inline<span style="...">.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpanState.kt | Adds font size/family to stored custom style and includes them in emitted style payload. |
| android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt | Extracts font size/family from custom style spans when resolving selection state. |
| android/src/main/java/com/swmansion/enriched/textinput/styles/CustomStyles.kt | Accepts font size/family from JS and applies them to active style or spans. |
| android/src/main/java/com/swmansion/enriched/textinput/spans/EnrichedInputCustomStyleSpan.kt | Extends input custom-style span to include font size/family + assets/scaling. |
| android/src/main/java/com/swmansion/enriched/textinput/MeasurementStore.kt | Instantiates spannable factory with assets + allowFontScaling. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Switches to creating a configured spannable factory (assets + allowFontScaling). |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt | Updates span factory interface impl to create font-aware custom style spans. |
| android/src/main/java/com/swmansion/enriched/text/spans/EnrichedTextCustomStyleSpan.kt | Extends text-view custom-style span to include font size/family + assets/scaling. |
| android/src/main/java/com/swmansion/enriched/text/MeasurementStore.kt | Instantiates text span factory with assets + allowFontScaling. |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt | Switches to creating a configured text span factory (assets + allowFontScaling). |
| android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt | Updates span factory interface impl to create font-aware custom style spans. |
| android/src/main/java/com/swmansion/enriched/common/spans/EnrichedCustomStyleSpan.kt | Makes custom style span metric-affecting and applies font family/size to paint. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt | Extends factory interface for custom style spans with font size/family args. |
| android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java | Adds parsing/serialization of font-size and font-family in inline span styles. |
| android/src/main/java/com/swmansion/enriched/common/CustomStyle.kt | Adds fontSize/fontFamily fields and an isEmpty() helper. |
Suppressed comments (1)
android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java:1027
parseCssFontFamilycurrently returns the full rawfont-familyvalue (including comma-separated stacks and partial quoting). That can’t be applied as a React NativefontFamilyand also breaks round-tripping with the serializer. Consider parsing just the first family and stripping surrounding quotes/whitespace.
private static String parseCssFontFamily(String raw) {
if (raw == null) return null;
String value = raw.trim();
if ((value.startsWith("'") && value.endsWith("'"))
|| (value.startsWith("\"") && value.endsWith("\""))) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kacperzolkiewski
marked this pull request as ready for review
August 11, 2026 10:10
hejsztynx
requested changes
Aug 11, 2026
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
Add fontSize and fontFamily to customStyle
Test Plan
Run example app and experiment with applying
fontSizeandfontFamilycolors through the toolbar across different text styles.Screenshots / Videos
Compatibility
Checklist