Skip to content

SVG: apply the letter-spacing of text - #2204

Open
RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-letter-spacing
Open

RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-letter-spacing

Conversation

@RavSinghChandan

Copy link
Copy Markdown

The labels of spaCy's displaCy dependency diagrams use letter-spacing: 2px, and Inkscape writes letter-spacing on every text. fpdf2 ignores it, so spaced text is drawn tight.

The letter-spacing of a <text> or <tspan> is now applied with the PDF character spacing operator (Tc), reset after each run. It is inherited, em and ex are relative to the font size, and normal or an unreadable value means no spacing. The spacing is also added to the run widths, so text-anchor="middle" and "end" stay correct. TextRun gets a letter_spacing field, defaulting to 0.

test_svg_text_letter_spacing and test_svg_text_letter_spacing_bounding_box cover these; the spacing cases fail without the change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant