fix(ios): apply obliqueness if italics are not supported - #745
Open
hejsztynx wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
ItalicUtilsto classify grapheme clusters and apply either a real italic font or anNSObliquenessfallback per segment. - Introduced
stylingPriorityonStyleBaseand used it to deterministically order inline style application (with italics opting to apply last). - Updated inline-style application ordering in both
TextHtmlParserandInputAttributesManager.
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.
Contributor
There was a problem hiding this comment.
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 timekindForCluster:runs. This is called per composed character sequence, so it can create avoidable churn on large strings. Cache the inverted set once (similar toNeutralCharacters()) and reuse it.
if ([cluster rangeOfCharacterFromSet:[NeutralCharacters() invertedSet]]
.location == NSNotFound) {
return ItalicKindNone;
}
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
this fixes #739
NSObliquenessattribute is applied, when given font does not support proper italicsstylingPrioritytrait for base styles, so italics can be applied lastTest 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
Checklist