mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-30 04:58:34 -06:00
Shaped text (Arabic, Indic, combining marks) was written as one text object per glyph: BT, the whole text state (Tf Tc Tw Tz TL Ts and the colour), Tm, Tj and ET. A 15-glyph row took 15 text objects and 392 tokens (the whole stream), a long Arabic paragraph thousands of operators, and other viewers saw every glyph as a separate piece of text. Each run is now one text object: the state once, one Tm, and the glyphs in TJ arrays. A glyph's adjustment moves it from where the glyph before it ends (its width in the embedded font) to where shaping put it, and a mark shaped above or below its letter is raised with Ts, then reset (ISO 32000-1 9.4.3, 9.3.7). Character and word spacing are part of those positions, so Tc and Tw are 0 in the run. The same row is now 1 text object (90 tokens for the stream), and renders the same at 300 dpi (138 of 33 million bytes differ, by 1 level, from rounding). The new test shapes marks beside and above their letters with Inter, reads each glyph's origin back from the TJ displacements and checks it against the shaped position. It fails without this change (15 text objects in the run against 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>