Skip to content

Commit

Permalink
Fixing a bug when parsing some SVG files - close #356 (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C authored Mar 8, 2022
1 parent a67479d commit 69f56b6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ and [PEP 440](https://www.python.org/dev/peps/pep-0440/).

## [2.5.2] - not released yet
### Fixed
- a bug with string width calculation when Markdown is enabled - _cf._ [#351](https://github.com/PyFPDF/fpdf2/issues/351)
- a regression: now again `multi_cell()` always renders a cell, even if `txt` is an empty string - _cf._ [#349](https://github.com/PyFPDF/fpdf2/issues/349)
- a bug with string width calculation when Markdown is enabled - _cf._ [#351](https://github.com/PyFPDF/fpdf2/issues/351)
- a bug when parsing some SVG files - _cf._ [#356](https://github.com/PyFPDF/fpdf2/issues/356)

## [2.5.1] - 2022-03-07
### Added
Expand Down
5 changes: 4 additions & 1 deletion fpdf/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,10 @@ def svg_path_converter(pdf_path, svg_path):
{"m": "l", "M": "L"}[last_directive_name]
]

numbers, svg_path = _read_n_numbers(svg_path[read_idx:], read_count)
if read_count:
numbers, svg_path = _read_n_numbers(svg_path[read_idx:], read_count)
else:
numbers, svg_path = (), svg_path[read_idx:].strip()

last_directive(pdf_path, *numbers)

Expand Down
Binary file added test/svg/generated_pdf/search.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions test/svg/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ def Gs(**kwargs):
pytest.param(svgfile("triangle01.svg"), id="SVG spec triangle01"),
pytest.param(svgfile("SVG_logo.svg"), id="SVG logo from wikipedia"),
pytest.param(svgfile("viewbox.svg"), id="weird viewbox"),
pytest.param(svgfile("search.svg"), id="search icon"), # issue 356
)

svg_path_edge_cases = (
Expand Down
3 changes: 3 additions & 0 deletions test/svg/svg_sources/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 69f56b6

Please sign in to comment.