Skip to content

Commit

Permalink
Switch SVG path parsing to fonttools (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmischler authored Sep 20, 2022
1 parent af12339 commit bea5d39
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 366 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',

## [2.5.7] - 2022-09-08
### Changed
- 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)
- 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)
- `fpdf2` now uses [fontTools](https://fonttools.readthedocs.io/en/latest/) to read and embed fonts in the PDF, thanks to @gmischler and @RedShy

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Go try it **now** online in a Jupyter notebook: [![Open In Colab](https://colab.
It is a fork and the successor of `PyFPDF` (_cf._ [history](https://pyfpdf.github.io/fpdf2/Development.html#history)).
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)).
It is also entirely written in Python and 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://fonttools.readthedocs.io/en/latest/index.html).
[Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), & [fontTools](https://fonttools.readthedocs.io/en/latest/index.html).

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

Expand Down
7 changes: 1 addition & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Go try it **now** online in a Jupyter notebook: [![Open In Colab](https://colab.
* [Annotations](Annotations.md), including text highlights, and [file attachments](FileAttachments.md)
* [Presentation mode](Presentations.md) with control over page display duration & transitions
* Optional basic Markdown-like styling: `**bold**, __italics__`
* 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/)
* It has very few dependencies: [Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), & [fonttools](https://pypi.org/project/fonttools/)
* Can render [mathematical equations & charts](https://pyfpdf.github.io/fpdf2/Maths.html)
* 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)
* Unit tests with `qpdf`-based PDF diffing, and PDF samples validation using 3 different checkers:
Expand Down Expand Up @@ -74,11 +74,6 @@ To get the latest, unreleased, development version straight from the development
pip install git+https://github.com/PyFPDF/fpdf2.git@master
```

`fpdf2` can be installed without any dependency, but it needs [Pillow](https://pypi.org/project/Pillow/) to render images:
```bash
pip install --no-dependencies fpdf2
```

**Developement**: check the [dedicated documentation page](Development.md).

### Displaying deprecation warnings
Expand Down
6 changes: 6 additions & 0 deletions fpdf/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3356,6 +3356,9 @@ def add_path_element(self, item, _copy=True):

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

def remove_last_path_element(self):
self._graphics_context.remove_last_item()

def rectangle(self, x, y, w, h, rx=0, ry=0):
"""
Append a rectangle as a closed subpath to the current path.
Expand Down Expand Up @@ -3963,6 +3966,9 @@ def add_item(self, item, _copy=True):

self.path_items.append(item)

def remove_last_item(self):
del self.path_items[-1]

def merge(self, other_context):
"""Copy another `GraphicsContext`'s path items into this one."""
self.path_items.extend(other_context.path_items)
Expand Down
Loading

0 comments on commit bea5d39

Please sign in to comment.