Skip to content

svglib 2.0.0

Latest

Choose a tag to compare

@deeplook deeplook released this 16 Jun 13:36

2.0.0 (2026-06-16)

Identical to 2.0b1 in terms of code; this release promotes the beta to a
stable release and converts the project documentation files from RST to
Markdown format.

2.0b1 (2026-05-26)

Breaking change — output sizes will differ from 1.x.

svglib now correctly maps SVG user units to ReportLab points using the
standard SVG/CSS conversion factor: 1 px = 0.75 pt (96 dpi). Previous
releases treated 1 user unit as 1 pt, which is 33 % too large. Any SVG
whose width/height or viewBox uses user units or px will
produce a PDF that is 75 % of its previous linear dimensions (same
proportions, correct physical size).

Migration — if you need to preserve the old apparent size, scale the
returned Drawing object before use:

```python
from svglib.svglib import svg2rlg

drawing = svg2rlg("file.svg")

Restore 1.x dimensions (1 user unit → 1 pt, non-spec):

factor = 4 / 3 # 1 / 0.75
drawing.width *= factor
drawing.height *= factor
drawing.scale(factor, factor)
```

  • Add support for SVG 2 length units: rem, vw, vh, vmin,
    vmax, and q (quarter-millimetre) in convertLength (#449).
  • rem now resolves against the root <svg> element's font-size
    (falling back to the CSS default of 16 px when not set).
  • Warn when loading SVGs created with Inkscape < 0.92, which used a
    non-standard 90 dpi reference resolution (#452).
  • Move rlpycairo to the bitmaps extra, so Cairo is no longer part of
    the default installation path.
  • Fix inconsistent unit handling: bare numbers and px units now produce
    identical output, as required by the SVG spec (§5.9.2). convertLength
    now returns user units (px) instead of ReportLab points; a new
    convertLengthToPt helper is used where absolute point values are needed
    (font sizes, canvas dimensions) (#439).
  • Fix SVGs with a viewBox but no explicit width/height: the
    viewport scale now defaults to PX_TO_PT (0.75) instead of 1, preventing
    content from being cropped.
  • Add support for SVG linearGradient and radialGradient paint servers
    (#442).
  • Add support for SVG <switch> elements with conditional rendering (#441).
  • Fix fill-rule handling for paths by setting ReportLab fillMode
    directly (#440).
  • Fix case-insensitive font family lookup in FontMap (#433, #435).
  • Fix fontconfig handling when resolved fonts use non-normal weight or style.
  • Improve missing font warnings by pointing users to register_font().
  • Harden fc-match calls by resolving the executable path and passing
    arguments after --.
  • Fixed a SVG path interpretation bug with two successive M or m commands
    (#414).