github deeplook/svglib v2.4.0
svglib v2.4.0

3 hours ago

Added

  • <textPath> is now supported: text follows the <path> named by its href
    or xlink:href, with startOffset (a length or a percentage) and
    text-anchor, and styled <tspan> children. ReportLab can't draw text along
    a path, so each glyph is placed and rotated individually, at the point of the
    path under its midpoint; glyphs beyond the end of the path are dropped. Only
    paths of the same document can be followed, and side, method, spacing
    and per-glyph dx/dy/rotate are not supported (#298, #532).
  • The plain opacity property is now supported, as a presentation attribute,
    in style attributes and in <style> rules, including percentages. Opacity
    composes down the tree, so a shape at 0.5 inside a group at 0.5 is drawn at
    0.25. It is applied per shape, so overlapping shapes inside a translucent
    group show through each other, and images are not affected (#109, #525,
    thanks to @Pharex38).
  • The CSS font shorthand is now expanded into font-style, font-weight,
    font-size and font-family, in style attributes and in <style> rules.
    Invalid shorthands are ignored (#343, #526, thanks to @Pharex38).

Removed

  • Dropped support for Python 3.9 (and PyPy 3.9). pip 26.2.2, the new
    minimum safe version, requires Python 3.10 or newer. requires-python is now
    >=3.10, the 3.9 classifier is gone, and CI no longer tests 3.9 or PyPy 3.9.

Tooling and housekeeping

  • CI now fails if a locked or installed dependency, or the uv binary, is below
    its minimum safe version (scripts/check_min_versions.py).
  • CI runs the lowest supported Python, 3.10, next to 3.13, 3.15 and PyPy 3.11.
    Python 3.15 is declared supported (classifier and tox).
  • make install installs the dev dependency group (it used the dev extra,
    which doesn't exist), make uninstall no longer passes an option that
    uv pip doesn't know, and make test-dist works: scripts/test-dist.sh
    builds the wheel and tests it in a clean virtual environment. New:
    make check-versions.
  • tests/test_basic.py is split into modules by topic (test_paths.py,
    test_text.py, test_text_path.py, test_use.py, test_gradients.py, ...).
    The tests that download files carry the pytest marker network, so
    pytest -m "not network" (or make test-fast) skips them.
  • tests/test_public_api.py records the names, signatures and class members
    of svglib, svglib.svglib, svglib.utils and svglib.fonts in
    tests/public_api.json, so that restructuring the modules can't silently
    change what user code can import.
  • The READMEs and notes in demos/ and tests/ are Markdown now, and the
    testing instructions describe the current uv and Makefile based workflow.

Fixed

  • A style attribute or <style> rule whose value contains a colon or a
    semicolon, such as cursor: url(http://example.com/c.cur), auto or a data
    URL, no longer makes svg2rlg() fail with ValueError or truncates the
    value. Declarations are now parsed with tinycss2, malformed ones are
    skipped, and !important and comments are no longer part of the value
    (#527, thanks to @Pharex38).
  • baseline-shift on text is now also read from style attributes and
    <style> rules, and a percentage is taken relative to the font size instead
    of being used as a length in user units. A value on an enclosing <g> does
    not affect the text, as the property is not inherited (#528, thanks to
    @Pharex38).
  • stroke-dasharray values that SVG calls invalid (any negative length, or a
    list that sums to zero) no longer produce an invalid PDF dash pattern and
    raise ValueError while rendering; they give a solid line. none no longer
    relies on a swallowed exception, and an odd number of values is repeated once
    to make it even, as the specification requires (#529, thanks to @Pharex38).

Don't miss a new svglib release

NewReleases is sending notifications on new releases.