Skip to content

Commit c9bb536

Browse files
authored
CI: adding spell-check using typos CLI (#1370)
1 parent 14bfce1 commit c9bb536

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+149
-118
lines changed

.github/workflows/continuous-integration-workflow.yml

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
guarddog pypi verify docs/requirements.txt
7272
guarddog pypi verify test/linters-requirements.txt
7373
guarddog pypi verify test/requirements.txt
74+
- name: Spell Check Repo ✍️
75+
uses: crate-ci/typos@v1.29.7
7476
test:
7577
strategy:
7678
matrix:

.typos.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[default]
2+
extend-ignore-identifiers-re = [
3+
"1fpt", # FPDF._downscale_image()
4+
".+_2nd",
5+
"BUI",
6+
"decode_parms",
7+
"odf", # odf.opendocument / odf.table
8+
"parameter_ot",
9+
"sur", "Sur",
10+
"ue", "UE",
11+
"FlateDecode",
12+
"VAI",
13+
]
14+
extend-ignore-re = [
15+
"loca subsetting",
16+
"np.arange",
17+
]
18+
19+
[files]
20+
extend-exclude = [
21+
"*.pdf",
22+
"docs/Tutorial-*.md",
23+
]

CHANGELOG.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
8888
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): `tag_indents` introduced in the last version - Now the indentation can be provided through the `tag_styles` parameter, using the `.l_margin` of `TextStyle` instances
8989
### Changed
9090
* [`FPDF.local_context()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.local_context) used to treat `font_size` as a value in points. Now this is the role of `font_size_pt`, whereas `font_size` allows to set the font size into chosen document units (specified with `FPDF(unit=)`) - MR: [#1207](https://github.com/py-pdf/fpdf2/pulls/1207)
91-
* [`FPDF.circle()`](https://py-pdf.github.io/fpdf2/fpdf.html#fpdf.fpdf.FPDF.circle) : the previous `r` parameter, that in fact defined the diameter, has been replaced by a new `radius` paremeter. The `x` & `y` parameters now define the circle **center**, instead of its top-left corner as it used to be - [issue #1245](https://github.com/py-pdf/fpdf2/issues/1245)
91+
* [`FPDF.circle()`](https://py-pdf.github.io/fpdf2/fpdf.html#fpdf.fpdf.FPDF.circle) : the previous `r` parameter, that in fact defined the diameter, has been replaced by a new `radius` parameter. The `x` & `y` parameters now define the circle **center**, instead of its top-left corner as it used to be - [issue #1245](https://github.com/py-pdf/fpdf2/issues/1245)
9292
* [`FPDF.table()`](https://py-pdf.github.io/fpdf2/Tables.html) now raises an error when a single row is too high to be rendered on a single page
9393
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html): indentation of HTML elements can now be non-integer (float), and is now independent of font size and bullet strings.
9494
* improved performance of font glyph selection by using functools cache
@@ -572,23 +572,23 @@ This has been fixed, and a warning is now triggered by the [`FPDF.code39`](https
572572
- [`FPDF.circle`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.circle): new method added, thanks to @viraj-shah18 !
573573
- `write_html`: support setting HTML font colors by name and short hex codes
574574
- [`FPDF.will_page_break`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.will_page_break)
575-
utility method to let users know in advance when adding an elemnt will trigger a page break.
576-
This can be useful to repeat table headers on each page for exemple,
575+
utility method to let users know in advance when adding an element will trigger a page break.
576+
This can be useful to repeat table headers on each page for example,
577577
_cf._ [documentation on Tables](https://py-pdf.github.io/fpdf2/Tables.html#repeat-table-header-on-each-page).
578578
- [`FPDF.set_link`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.set_link) now support a new optional `x` parameter to set the horizontal position after following the link
579579
### Fixed
580580
- fixed a bug when `fpdf.Template` was used to render QRCodes, due to a forced conversion to string (#175)
581581

582582
## [2.4.1] - 2021-06-12
583583
### Fixed
584-
- erroneous page breaks occured for full-width / full-height images
585-
- rendering issue of non-ASCII characaters with unicode fonts
584+
- erroneous page breaks occurred for full-width / full-height images
585+
- rendering issue of non-ASCII characters with unicode fonts
586586

587587
## [2.4.0] - 2021-06-11
588588
### Changed
589589
- now `fpdf2` uses the newly supported `DCTDecode` image filter for JPEG images,
590590
instead of `FlateDecode` before, in order to improve the compression ratio without any image quality loss.
591-
On test images, this reduced the size of embeded JPEG images by 90%.
591+
On test images, this reduced the size of embedded JPEG images by 90%.
592592
- `FPDF.cell`: the `w` (width) parameter becomes optional, with a default value of `None`, meaning to generate a cell with the size of the text content provided
593593
- the `h` (height) parameter of the `cell`, `multi_cell` & `write` methods gets a default value change, `None`, meaning to use the current font size
594594
- removed the useless `w` & `h` parameters of the `FPDF.text_annotation()` method
@@ -712,7 +712,7 @@ prevented strings passed first to the text-rendering methods to be displayed.
712712
## [2.0.4] - 2020-03-26
713713
### Fixed
714714
* images centering - thanks `cgfrost`!
715-
* added missing import statment for `urlopen` in `image_parsing` module
715+
* added missing import statement for `urlopen` in `image_parsing` module
716716
* changed urlopen import from `six` library to maintain python2 compatibility
717717

718718
## [2.0.3] - 2020-01-03

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pip install git+https://github.com/py-pdf/fpdf2.git@master
8282
Our 350+ reference PDF test files, generated by `fpdf2`, are validated using 3 different checkers:
8383

8484
[![QPDF logo](https://py-pdf.github.io/fpdf2/qpdf-logo.svg)](https://github.com/qpdf/qpdf)
85-
[![PDF Checker logo](https://py-pdf.github.io/fpdf2/pdfchecker-logo.png)](https://www.datalogics.com/products/pdf-tools/pdf-checker/)
85+
[![PDF Checker logo](https://py-pdf.github.io/fpdf2/pdfchecker-logo.png)](https://www.datalogics.com/repair-pdf-files)
8686
[![VeraPDF logo](https://py-pdf.github.io/fpdf2/vera-logo.jpg)](https://verapdf.org)
8787

8888
## Please show the value

docs/Development.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ static code analysis with `pylint`, unit tests...
208208
_Pull Requests_ submitted must pass all those checks in order to be approved.
209209
Ask maintainers through comments if some errors in the pipeline seem obscure to you.
210210

211+
### typos
212+
[typos](https://github.com/crate-ci/typos) is a handy CLI tool to detect & auto-fix [typos](https://en.wikipedia.org/wiki/Typographical_error) in source files.
213+
Installation is relatively straightfoward ([read the docs](https://github.com/crate-ci/typos?tab=readme-ov-file#install)).
214+
215+
This tool is invoked in our CI pipeline.
216+
If it fails, you should either:
217+
* auto-fix the errors detected by invoking `typos --write-changes`
218+
* add an exclusion rule to `.typos.toml`
219+
211220
### Release checklist
212221
1. complete `CHANGELOG.md` and add the version & date of the new release
213222
2. bump `FPDF_VERSION` in `fpdf/fpdf.py`.
@@ -261,7 +270,6 @@ there are still many PDF features that this library does not support.
261270
## Useful tools to manipulate PDFs
262271

263272
### qpdf
264-
265273
[qpdf](https://qpdf.sourceforge.io/) is a very powerful tool to analyze PDF documents.
266274

267275
One of it most useful features is the [QDF mode](https://qpdf.readthedocs.io/en/stable/qdf.html) that can convert any PDF file to a human-readable, decompressed & annotated new PDF document:
@@ -273,7 +281,6 @@ qpdf --qdf doc.pdf doc-qdf.pdf
273281
This is extremely useful to peek into the PDF document structure.
274282

275283
### pdfly
276-
277284
`pdfly` is a very handy CLI tool to manipulate PDF files: [py-pdf/pdfly](https://github.com/py-pdf/pdfly?tab=readme-ov-file#usage).
278285

279286
Those are some very useful commands:

docs/EmojisSymbolsDingbats.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ For reference, it was built using this script: [zapfdingbats.py](zapfdingbats.py
7575

7676
## Fallback fonts ##
7777

78-
If you need to mix special characters and emojis within normal text, it is possible to specify alternative fonts for FPDF to use as fallback fonts. See an exemple of use [Here](Unicode.md#fallback-fonts)
78+
If you need to mix special characters and emojis within normal text, it is possible to specify alternative fonts for FPDF to use as fallback fonts. See an example of use [Here](Unicode.md#fallback-fonts)

docs/HTML.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pdf.output("html_helvetica.pdf")
181181
_New in [:octicons-tag-24: 2.8.0](https://github.com/py-pdf/fpdf2/blob/master/CHANGELOG.md)_
182182

183183
Page breaks can be triggered explicitly using the [break-before](https://developer.mozilla.org/en-US/docs/Web/CSS/break-before) or [break-after](https://developer.mozilla.org/en-US/docs/Web/CSS/break-after) CSS properties.
184-
For exemple you can use:
184+
For example you can use:
185185
```html
186186
<br style="break-after: page">
187187
```

docs/Maths.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ You can find documentation on how to convert vector images (SVG) to raster image
112112

113113
## Mathematical formulas ##
114114
`fpdf2` can only insert mathematical formula in the form of **images**.
115-
The following sections will explaing how to generate and embed such images.
115+
The following sections will explain how to generate and embed such images.
116116

117117
### Using Google Charts API ###
118118
Official documentation: [Google Charts Infographics - Mathematical Formulas](https://developers.google.com/chart/infographics/docs/formulas).

docs/Patterns.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ Both linear and radial gradients support **multiple colors**. If you pass, for e
119119
For **linear gradients** or **radial gradients**, passing `bounds=[0.2, 0.4, 0.7, ...]` (values between 0 and 1) fine-tunes where each color transition occurs. For instance, if you have 5 colors, you can specify 3 boundary values that partition the color progression among them.
120120

121121
For example, taking a gradient with 5 colors and `bounds=[0.1, 0.8, 0.9]`:
122-
- The transition from color 1 to color 2 start at the beggining (0%) and ends at 10%
123-
- The transition from color 2 to color 3 start at 10% and ends at 80%
124-
- The transition from color 3 to color 4 start at 80% and ends at 90%
125-
- The transition from color 4 to color 5 start at 90% and goes to the end (100%)
122+
- The transition from color 1 to color 2 starts at the beginning (0%) and ends at 10%
123+
- The transition from color 2 to color 3 starts at 10% and ends at 80%
124+
- The transition from color 3 to color 4 starts at 80% and ends at 90%
125+
- The transition from color 4 to color 5 starts at 90% and goes to the end (100%)
126126

127127
In other words, each boundary value dictates where the color transitions will occur along the total gradient length.

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This documentation is published online at https://py-pdf.github.io/fpdf2/
22

33
Docs generation & publication on GitHub Pages is performed for every new commit on the `master` branch
4-
throught the GitHub Actions pipeline.
4+
through the GitHub Actions pipeline.
55

66
Please refer to the [development manual](https://py-pdf.github.io/fpdf2/Development.html#documentation)
77
for more information.

docs/Tables.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ with pdf.table() as table:
419419
row.cell(datum)
420420
```
421421

422-
Can be shortened to the followng code,
422+
Can be shortened to the following code,
423423
by passing lists of strings as the `cells` optional argument of `.row()`:
424424

425425
```python

docs/Templates.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ from fpdf import Template
241241
elements = [
242242
{ 'name': 'company_logo', 'type': 'I', 'x1': 20.0, 'y1': 17.0, 'x2': 78.0, 'y2': 30.0, 'font': None, 'size': 0.0, 'bold': 0, 'italic': 0, 'underline': 0, 'align': 'C', 'text': 'logo', 'priority': 2, 'multiline': False},
243243
{ 'name': 'company_name', 'type': 'T', 'x1': 17.0, 'y1': 32.5, 'x2': 115.0, 'y2': 37.5, 'font': 'helvetica', 'size': 12.0, 'bold': 1, 'italic': 0, 'underline': 0,'align': 'C', 'text': '', 'priority': 2, 'multiline': False},
244-
{ 'name': 'multline_text', 'type': 'T', 'x1': 20, 'y1': 100, 'x2': 40, 'y2': 105, 'font': 'helvetica', 'size': 12, 'bold': 0, 'italic': 0, 'underline': 0, 'background': 0x88ff00, 'align': 'C', 'text': 'Lorem ipsum dolor sit amet, consectetur adipisici elit', 'priority': 2, 'multiline': True, 'wrapmode': 'WORD'},
244+
{ 'name': 'multiline_text', 'type': 'T', 'x1': 20, 'y1': 100, 'x2': 40, 'y2': 105, 'font': 'helvetica', 'size': 12, 'bold': 0, 'italic': 0, 'underline': 0, 'background': 0x88ff00, 'align': 'C', 'text': 'Lorem ipsum dolor sit amet, consectetur adipisici elit', 'priority': 2, 'multiline': True, 'wrapmode': 'WORD'},
245245
{ 'name': 'box', 'type': 'B', 'x1': 15.0, 'y1': 15.0, 'x2': 185.0, 'y2': 260.0, 'font': 'helvetica', 'size': 0.0, 'bold': 0, 'italic': 0, 'underline': 0, 'align': 'C', 'text': None, 'priority': 0, 'multiline': False},
246246
{ 'name': 'box_x', 'type': 'B', 'x1': 95.0, 'y1': 15.0, 'x2': 105.0, 'y2': 25.0, 'font': 'helvetica', 'size': 0.0, 'bold': 1, 'italic': 0, 'underline': 0, 'align': 'C', 'text': None, 'priority': 2, 'multiline': False},
247247
{ 'name': 'line1', 'type': 'L', 'x1': 100.0, 'y1': 25.0, 'x2': 100.0, 'y2': 57.0, 'font': 'helvetica', 'size': 0, 'bold': 0, 'italic': 0, 'underline': 0, 'align': 'C', 'text': None, 'priority': 3, 'multiline': False},

docs/Text.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ With supporting Unicode fonts, `fpdf2` should handle the following text shaping
3030
There are a few advanced typesetting features that `fpdf2` doesn't currently support:
3131

3232
* Contextual forms - In some writing systems (eg. Arabic, Mongolian, etc.), characters may take a different shape, depending on whether they appear at the beginning, in the middle, or at the end of a word, or isolated. Fpdf will always use the same standard shape in those cases.
33-
* Vertical writing - Some writing systems are meant to be written vertically. Doing so is not directly supported. In cases where this just means to stack characters on top of each other (eg. Chinese, Japanese, etc.), client software can implement this by placing each character individuall at the correct location. In cases where the characters are connected with each other (eg. Mongolian), this may be more difficult, if possible at all.
33+
* Vertical writing - Some writing systems are meant to be written vertically. Doing so is not directly supported. In cases where this just means to stack characters on top of each other (eg. Chinese, Japanese, etc.), client software can implement this by placing each character individually at the correct location. In cases where the characters are connected with each other (eg. Mongolian), this may be more difficult, if possible at all.
3434

3535
### Character or Word Based Line Wrapping
3636
By default, `multi_cell()` and `write()` will wrap lines based on words, using space characters and soft hyphens as separators.

docs/TextRegion.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ All types of text regions have the following constructor parameters in common:
5858
* `image` (str or PIL.Image.Image or io.BytesIO, optional) - An image to add to the region. This is a convenience parameter for cases when no further text or images need to be added to the paragraph. If both `text` and `image` arguments are present, the text will be inserted first. (Default: None)
5959
* `image_fill_width` (bool, optional) - Indicates whether to increase the size of the image to fill the width of the column. Larger images will always be reduced to column width. (Default: False)
6060

61-
All of those values can be overriden for each individual paragraph.
61+
All of those values can be overridden for each individual paragraph.
6262

6363

6464
### Common Methods ###

docs/TextShaping.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _New in [:octicons-tag-24: 2.7.5](https://github.com/py-pdf/fpdf2/blob/master/CH
77
## What is text shaping? ##
88
Text shaping is a fundamental process in typography and computer typesetting that influences the aesthetics and readability of text in various languages and scripts. It involves the transformation of Unicode text into glyphs, which are then positioned for display or print.
99

10-
For texts in latin script, text shaping can improve the aesthetics by replacing characters that would colide or overlap by a single glyph specially crafted to look harmonious.
10+
For texts in latin script, text shaping can improve the aesthetics by replacing characters that would collide or overlap by a single glyph specially crafted to look harmonious.
1111

1212
![](text-shaping-ligatures.png)
1313

docs/TextStyling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This method changes the distance between individual characters of a test string.
5353

5454
Character spacing works best for formatting single line text created by any method, or for highlighting individual words included in a block of text with `.write()`.
5555

56-
**Limitations**: Spacing will only be changed *within* a sequence of characters that `fpdf2` adds to the PDF in one go. This means that there will be no extra distance _eg._ between text parts that are placed successivly with `write()`. Also, if you apply different font styles using the Markdown functionality of `.cell()` and `.multi_cell()` or by using `html_write()`, then any parts given different styles will have the original distance between them. This is so because `fpdf2` has to add each styled fragment to the PDF file seperately.
56+
**Limitations**: Spacing will only be changed *within* a sequence of characters that `fpdf2` adds to the PDF in one go. This means that there will be no extra distance _eg._ between text parts that are placed successively with `write()`. Also, if you apply different font styles using the Markdown functionality of `.cell()` and `.multi_cell()` or by using `html_write()`, then any parts given different styles will have the original distance between them. This is so because `fpdf2` has to add each styled fragment to the PDF file separately.
5757

5858
The example shows the same text justified to the same width, with char_spacing values of 0 and 10 (font size 8 pt).
5959
```python

docs/Unicode.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Besides the limited set of latin fonts built into the PDF format, `fpdf2` offers
55
To make use of that functionality, you have to install at least one Unicode font, either in the system font folder or in some other location accessible to your program.
66
For professional work, many designers prefer commercial fonts, suitable to their specific needs. There are also many sources of free TTF fonts that can be downloaded online and used free of cost (some of them may have restrictions on commercial redistribution, such as server installations or including them in a software project).
77

8-
* [Font Library](https://fontlibrary.org/) - A collection of fonts for many languates with an open source type license.
8+
* [Font Library](https://fontlibrary.org/) - A collection of fonts for many languages with an open source type license.
99

1010
* [Google Fonts](https://fonts.google.com/) - A collection of free to use fonts for many languages.
1111

@@ -214,5 +214,5 @@ When a glyph cannot be rendered uing the current font,
214214
By default, if it does not find such matching font, the character will not be rendered using any fallback font. This behaviour can be relaxed by passing `exact_match=False` to [`set_fallback_fonts()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.set_fallback_fonts).
215215

216216
Moreover, for more control over font fallback election logic,
217-
the [`get_fallback_font()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.get_fallback_font) can be overriden.
217+
the [`get_fallback_font()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.get_fallback_font) can be overridden.
218218
An example of this can be found in [test/fonts/test_font_fallback.py](https://github.com/py-pdf/fpdf2/blob/master/test/fonts/test_font_fallback.py).

0 commit comments

Comments
 (0)