Add Superscript and Subscript font styles#348
Merged
oneplus1000 merged 6 commits intoJul 26, 2026
Conversation
Collaborator
|
Hello again! Thank you for PR. I will check and review it on the weekend. |
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.
This adds superscript and subscript text support.
How it works
Superscript = 8andSubscript = 16. LikeUnderline, they are decoration bits: they reuse the already-loaded font face (the face lookup now strips all decoration bits, not justUnderline).ySuperscriptYSize/YOffset,ySubscriptYSize/YOffset), whichParseOS2previously skipped over. Fonts with missing or zero metrics fall back to conventional ratios (58.3% size, +33.3%/-14.1% baseline shift)./F1 9.1 Tf 0 Tc 6.34 Ts.Tsis emitted on every draw (0 Tsfor plain text) because text state persists acrossBT/ETblocks, so each draw must reset it.MeasureTextWidth, wrapping, justify adjustments) uses the scaled size so measurements match rendering.Notes for review
getConvertedStylematches single letters viaContains, so "SUP"/"SUB" would falsely match Bold/Underline. The flags are int-style only.TestSuperscriptSubscriptVisualDemowritestest/out/superscript_subscript_demo.pdffor visual checking (chemical formulas, exponents, footnote markers).