Repository navigation
fix(svg): text in the document's fonts — Cyrillic, text-anchor, rotation - #44
Merged
Merged
Conversation
SVG <text> was always set in base-14 Helvetica: Cyrillic printed as "?" (a stamp "ОПЛАЧЕНО" came out as "????????"), text-anchor was ignored and a rotated group printed its text level. - SvgRenderer::render() takes an optional font resolver; the engine passes its own chain (family, fallbacks, bold/italic faces, base-14 last). - font-family/-weight/-style/-size, fill and text-anchor are inherited from the group and read from `style`. - The glyphs are placed by a text matrix built from the SVG→PDF mapping, so rotate/scale/skew of a group apply to the text. - Page::showTextWithMatrix(), ContentStream::textWithMatrix(). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merged
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.
Problem
SVG
<text>was always set in base-14 Helvetica:?— a stamp «ОПЛАЧЕНО» came out as????????;text-anchorwas ignored — centred labels started at their anchor;transformdid not reach the text — a rotated stamp printed its text level;stylewere ignored.Found on a real insurance template in printable (stage acceptance).
Fix
SvgRenderer::render()takes an optional font resolver;Enginepasses its own chain (family list, fallbacks, bold/italic faces, base-14 last) — SVG text gets the same fonts as a paragraph.font-family,font-weight,font-style,font-size,fill,text-anchorinherited from ancestors and read from inlinestyle.Page::showTextWithMatrix()(base-14 or embedded font, kerning via TJ) andContentStream::textWithMatrix().Not in scope:
<tspan>positioning,<textPath>,dx/dy(documented).Tests
tests/Svg/SvgTextFontTest.php: Cyrillic via the document font (pdftotext), inherited bold from<g>+ size fromstyle, anchor start/middle/end offsets, rotation angle of the text matrix, base-14 bold fallback. Full suite 2601 green, phpstan clean.Docs: SVG section in en/de/ru/zh; CHANGELOG
[Unreleased].🤖 Generated with Claude Code