Skip to content

feat(android): add fontSize and fontFamily to customStyle - #758

Open
kacperzolkiewski wants to merge 6 commits into
@kacperzolkiewski/feat-custom-style-web-fontfrom
@kacperzolkiewski/feat-custom-style-android-font
Open

feat(android): add fontSize and fontFamily to customStyle#758
kacperzolkiewski wants to merge 6 commits into
@kacperzolkiewski/feat-custom-style-web-fontfrom
@kacperzolkiewski/feat-custom-style-android-font

Conversation

@kacperzolkiewski

@kacperzolkiewski kacperzolkiewski commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add fontSize and fontFamily to customStyle

Test Plan

Run example app and experiment with applying fontSize and fontFamily colors through the toolbar across different text styles.

Screenshots / Videos

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@kacperzolkiewski
kacperzolkiewski changed the base branch from @kacperzolkiewski/feat-custom-style-font to @kacperzolkiewski/feat-custom-style-web-font August 11, 2026 08:09
@kacperzolkiewski
kacperzolkiewski requested a lite review from Copilot August 11, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fontSize and fontFamily to CustomStyle and propagates them through span state/selection and custom-style span application.
  • Updates span factories and custom style span implementations to carry AssetManager + allowFontScaling so fonts and size can be applied consistently.
  • Extends HTML parsing/serialization to read/write font-size and font-family within 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

  • parseCssFontFamily currently returns the full raw font-family value (including comma-separated stacks and partial quoting). That can’t be applied as a React Native fontFamily and 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.

Comment thread android/src/main/java/com/swmansion/enriched/common/CustomStyle.kt Outdated
@kacperzolkiewski
kacperzolkiewski marked this pull request as ready for review August 11, 2026 10:10
Comment thread android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt Outdated

@hejsztynx hejsztynx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants