Repository navigation
fix(android): center inline images on the cap height like iOS - #1089
hryhoriiK97 merged 2 commits into
Conversation
An inline image's bottom sat on the baseline, so an icon taller than the capitals stood above the line of text. iOS centers inline attachments on the font's cap height; Android now draws the image centered on the cap height of the paint it is drawn with. Both ImageSpan copies change the same way.
Android drew an inline image with its bottom on the baseline, so icons sat above the line while iOS centers them on the cap height. The Enriched Markdown archive now carries software-mansion/enriched-markdown#1089, which centers them the same way on Android. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Centered on the cap height, an inline image taller than the text ran past both edges of its line and the view clipped it. iOS grows the line for such an attachment; getSize now widens the line metrics the same way. Re-records the Android inline image screenshots for the new placement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed a fixup on top: 7bf92da (fix(android): grow the line to fit a tall inline image) Centering on the cap height fixes normal-size icons, but Android never let an inline image change the line height ( Checked in the RN example on the Pixel 9 / API 36 emulator, and on the iOS simulator for reference. The first three rows use the default 20dp icon (body text, wrapped text, heading); the last row uses
|
Upstream merged our software-mansion#1086, software-mansion#1087, software-mansion#1088 and software-mansion#1089; the fork's copies of software-mansion#1088 and software-mansion#1089 were reverted first because upstream edited them before merging. Conflicts were the md4c flag lists, where upstream added strikethrough (software-mansion#1090) next to our preserveWindowsPaths, and the parser TurboModule's flag struct now has ten fields.




What/Why?
On Android an inline image is drawn with its bottom near the baseline (
y - h + 0.1h), so an icon taller than the capitals stands above the line of text. iOS centers inline attachments on the font's cap height (ENRMImageAttachment,(capHeight - height) / 2), so the same Markdown lines up on iOS and sits high on Android.Both
ImageSpancopies (the React Native package andenriched-markdown-android) now center the image on the cap height of the paint it is drawn with, matching iOS. Line metrics are unchanged, sincegetSizeandchooseHeightdon't look at inline images.Measured in T3 Code on an Android 17 emulator and an iOS 27 simulator. The offset is the gap between the image's center and the text's cap center, in cap heights:
Testing
InlineImagePlacementTest(native graphics, likeSpoilerPaintingTest) draws an inline image between text and checks that its painted center is the cap-height center. It fails onmain(9.5 against 11.0) and passes here.enriched-markdown-android::ui:testDebugUnitTest(526 tests) and:ui:ktlintCheckpass. React Native package:testDebugUnitTestandktlintCheckpass.PR Checklist
Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.