Skip to content

Font-size in px results in incorrect displayed size #415

@taminomara

Description

@taminomara

This is new in 1.6.0.

This is the code I used to test the issue:

import io
from reportlab.graphics import renderPM
from svglib import svglib

render = """
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="100" viewBox="0 0 500 100">
  <text x="250" y="14" font-family="Courier New" font-size="14" text-anchor="middle" stroke="#000">The quick brown fox jumps over the lazy dog</text>
  <text x="250" y="28" font-family="Courier New" font-size="14px" text-anchor="middle" stroke="#000">The quick brown fox jumps over the lazy dog</text>
</svg>
"""
stream = io.StringIO(render)
drawing = svglib.svg2rlg(stream)
renderPM.drawToFile(drawing, "output.gif", dpi=72)

In 1.5.1, both lines have the same size:

Image

In 1.6.0, the <text> with font-size given in px, the text is significantly smaller:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions