Skip to content

fix(ios): apply obliqueness if italics are not supported - #745

Open
hejsztynx wants to merge 5 commits into
mainfrom
@ksienkiewicz/fix-ios-cjk-italics
Open

fix(ios): apply obliqueness if italics are not supported#745
hejsztynx wants to merge 5 commits into
mainfrom
@ksienkiewicz/fix-ios-cjk-italics

Conversation

@hejsztynx

Copy link
Copy Markdown
Collaborator

Summary

this fixes #739

  • now NSObliqueness attribute is applied, when given font does not support proper italics
  • added stylingPriority trait for base styles, so italics can be applied last

Test Plan

Paste some non-latin characters, e.g. "冰淇淋", apply the italic style, everything should look as expected

Screenshots / Videos

The italics are now properly applied

cjkitalics.mov

Compatibility

OS Implemented
iOS
Android
Web

Checklist

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

Copilot AI review requested due to automatic review settings August 5, 2026 12:01
@hejsztynx
hejsztynx marked this pull request as draft August 5, 2026 12:01

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 improves iOS italic rendering by applying an NSObliqueness fallback when the active font (or its italic face) can’t render italic glyphs (notably for CJK), and introduces a style-priority mechanism so italics can be applied after font-changing inline styles.

Changes:

  • Added ItalicUtils to classify grapheme clusters and apply either a real italic font or an NSObliqueness fallback per segment.
  • Introduced stylingPriority on StyleBase and used it to deterministically order inline style application (with italics opting to apply last).
  • Updated inline-style application ordering in both TextHtmlParser and InputAttributesManager.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ios/utils/ItalicUtils.mm New per-cluster italic/oblique application logic using CoreText glyph coverage checks.
ios/utils/ItalicUtils.h Public interface for applying italic logic to an NSTextStorage range.
ios/textHtmlParser/TextHtmlParser.mm Sorts deferred inline style applications by stylingPriority.
ios/styles/ItalicStyle.mm Switches italic styling to use ItalicUtils and sets priority to apply later.
ios/interfaces/StyleBase.mm Adds default stylingPriority implementation.
ios/interfaces/StyleBase.h Declares stylingPriority on the base style interface.
ios/inputAttributesManager/InputAttributesManager.mm Orders style re-application using paragraph-first + stylingPriority.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ios/utils/ItalicUtils.mm Outdated
Comment thread ios/utils/ItalicUtils.mm Outdated
Comment thread ios/interfaces/StyleBase.mm Outdated
Comment thread ios/inputAttributesManager/InputAttributesManager.mm Outdated

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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (1)

ios/utils/ItalicUtils.mm:129

  • [NeutralCharacters() invertedSet] allocates a new character set each time kindForCluster: runs. This is called per composed character sequence, so it can create avoidable churn on large strings. Cache the inverted set once (similar to NeutralCharacters()) and reuse it.
  if ([cluster rangeOfCharacterFromSet:[NeutralCharacters() invertedSet]]
          .location == NSNotFound) {
    return ItalicKindNone;
  }

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.

[iOS] CJK text remains visually upright after toggleItalic despite <i> output

2 participants