Skip to content

Commit bea5d39

Browse files
authored
Switch SVG path parsing to fonttools (#545)
1 parent af12339 commit bea5d39

20 files changed

Lines changed: 130 additions & 366 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
3636

3737
## [2.5.7] - 2022-09-08
3838
### Changed
39+
- Since the fonttools library offers similar functionality, the dependency to "svg.path" is gone again, thanks to @gmischler; [#525](https://github.com/PyFPDF/fpdf2/issues/525)
3940
- HTML headings are now rendered with an additional leading of 20% the font size above and below them; [#520](https://github.com/PyFPDF/fpdf2/issues/520)
4041
- `fpdf2` now uses [fontTools](https://fonttools.readthedocs.io/en/latest/) to read and embed fonts in the PDF, thanks to @gmischler and @RedShy
4142

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Go try it **now** online in a Jupyter notebook: [![Open In Colab](https://colab.
3131
It is a fork and the successor of `PyFPDF` (_cf._ [history](https://pyfpdf.github.io/fpdf2/Development.html#history)).
3232
Compared with other PDF libraries, `fpdf2` is **fast, versatile, easy to learn and to extend** ([example](https://github.com/digidigital/Extensions-and-Scripts-for-pyFPDF-fpdf2)).
3333
It is also entirely written in Python and has very few dependencies:
34-
[Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), [svg.path](https://pypi.org/project/svg.path/) & [fontTools](https://fonttools.readthedocs.io/en/latest/index.html).
34+
[Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), & [fontTools](https://fonttools.readthedocs.io/en/latest/index.html).
3535

3636
**Development status**: this project is **mature** and **actively maintained**.
3737

docs/index.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Go try it **now** online in a Jupyter notebook: [![Open In Colab](https://colab.
4040
* [Annotations](Annotations.md), including text highlights, and [file attachments](FileAttachments.md)
4141
* [Presentation mode](Presentations.md) with control over page display duration & transitions
4242
* Optional basic Markdown-like styling: `**bold**, __italics__`
43-
* It has very few dependencies: [Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), [svg.path](https://pypi.org/project/svg.path/) & [fonttools](https://pypi.org/project/fonttools/)
43+
* It has very few dependencies: [Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), & [fonttools](https://pypi.org/project/fonttools/)
4444
* Can render [mathematical equations & charts](https://pyfpdf.github.io/fpdf2/Maths.html)
4545
* Many example scripts available throughout this documentation, including usage examples with [Django](https://www.djangoproject.com/), [Flask](https://flask.palletsprojects.com), [streamlit](https://streamlit.io/), AWS lambdas... : [Usage in web APIs](UsageInWebAPI.md)
4646
* Unit tests with `qpdf`-based PDF diffing, and PDF samples validation using 3 different checkers:
@@ -74,11 +74,6 @@ To get the latest, unreleased, development version straight from the development
7474
pip install git+https://github.com/PyFPDF/fpdf2.git@master
7575
```
7676

77-
`fpdf2` can be installed without any dependency, but it needs [Pillow](https://pypi.org/project/Pillow/) to render images:
78-
```bash
79-
pip install --no-dependencies fpdf2
80-
```
81-
8277
**Developement**: check the [dedicated documentation page](Development.md).
8378

8479
### Displaying deprecation warnings

fpdf/drawing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,6 +3356,9 @@ def add_path_element(self, item, _copy=True):
33563356

33573357
self._graphics_context.add_item(item, _copy=_copy)
33583358

3359+
def remove_last_path_element(self):
3360+
self._graphics_context.remove_last_item()
3361+
33593362
def rectangle(self, x, y, w, h, rx=0, ry=0):
33603363
"""
33613364
Append a rectangle as a closed subpath to the current path.
@@ -3963,6 +3966,9 @@ def add_item(self, item, _copy=True):
39633966

39643967
self.path_items.append(item)
39653968

3969+
def remove_last_item(self):
3970+
del self.path_items[-1]
3971+
39663972
def merge(self, other_context):
39673973
"""Copy another `GraphicsContext`'s path items into this one."""
39683974
self.path_items.extend(other_context.path_items)

0 commit comments

Comments
 (0)