Skip to content

Commit

Permalink
Adding warning in documentation for issue #1090 (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C authored Aug 20, 2024
1 parent 6151a68 commit 8e3857d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/PageBreaks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Simply call `.add_page()`.
The special string `{nb}` will be substituted by the total number of pages on document closure.
This special value can changed by calling [alias_nb_pages()](fpdf/fpdf.html#fpdf.fpdf.FPDF.alias_nb_pages).

!!! warning "This is currently incompatible with [text shaping](./TextShaping.md).<br>_cf._ [GitHub issue #1090](https://github.com/py-pdf/fpdf2/issues/1090)"

## will_page_break ##

`will_page_break(height)` lets you know if adding an element will trigger a page break,
Expand Down
15 changes: 8 additions & 7 deletions docs/TextShaping.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

_New in [:octicons-tag-24: 2.7.5](https://github.com/py-pdf/fpdf2/blob/master/CHANGELOG.md)_

!!! warning "This is currently incompatible with [the special `{nb}` string](./PageBreaks.md) that inserts the number of pages.<br>_cf._ [GitHub issue #1090](https://github.com/py-pdf/fpdf2/issues/1090)"

## What is text shaping? ##
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.

Expand Down Expand Up @@ -32,8 +34,6 @@ Another common use of glyph substitution is to replace a sequence of characters
![](text-shaping-substitution.png)




## Usage ##
Text shaping is disabled by default to keep backwards compatibility, reduce resource requirements and not make uharfbuzz a hard dependency.

Expand Down Expand Up @@ -87,20 +87,21 @@ Direction can be `ltr` (left to right) or `rtl` (right to left). The `ttb` (top

[Valid OpenType language codes](https://learn.microsoft.com/en-us/typography/opentype/spec/languagetags)

# Bidirectional Text #

## Bidirectional Text #

_New in [:octicons-tag-24: 2.7.8](https://github.com/py-pdf/fpdf2/blob/master/CHANGELOG.md)_

Bidirectional text refers to text containing both left-to-right (LTR) and right-to-left (RTL) language scripts. Languages such as Arabic, Hebrew, and Persian are written from right to left, whereas languages like English, Spanish, and French are written from left to right. The Unicode Bidirectional Algorithm is a set of rules defined by the Unicode Consortium to properly display mixed-directional text. This algorithm ensures that characters are shown in their correct order, preserving the logical sequence of the text.

## Unicode Bidirectional Algorithm ##
### Unicode Bidirectional Algorithm ##
The Unicode Bidirectional Algorithm, often abbreviated as the *Bidi* Algorithm, is essential for displaying text containing both RTL and LTR scripts. It determines the directionality of characters and arranges them in a visually correct order. This algorithm takes into account the inherent directionality of characters (such as those in Arabic or Hebrew being inherently RTL) and the surrounding context to decide how text should be displayed.

## Paragraph direction ##
### Paragraph direction ##

![](bidi_paragraph.svg)

## Bidirectional text in fpdf2 ##
### Bidirectional text in fpdf2 ##
fpdf2 will automatically apply the unicode bidirectional algorithm if text shaping is enabled.

If no `direction` parameter is provided - or `direction` is `None` - paragraph direction will be set according to the first directional character present on the text.
Expand All @@ -109,4 +110,4 @@ If there is a need to explicitly set the direction of a paragraph, regardless of

```python
fpdf.set_text_shaping(use_shaping_engine=True, direction="rtl")
```
```
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ or [open a discussion](https://github.com/py-pdf/fpdf2/discussions).

### They use fpdf2 ###
<!-- cf. Watchman Pypi & DavHau/pypi-deps-db -->
Online classes & open source projects:

* **Harvard University** uses `fpdf2` in their [CS50 introductory class](https://cs50.harvard.edu/python/2022/psets/8/shirtificate/)
* [Undying Dusk](https://lucas-c.itch.io/undying-dusk) : a **video game in PDF format**, with a gameplay based on exploration and logic puzzles, in the tradition of dungeon crawlers
* [OpenDroneMap](https://github.com/OpenDroneMap/ODM) : a command line toolkit for processing aerial drone imagery
Expand All @@ -111,7 +113,6 @@ or [open a discussion](https://github.com/py-pdf/fpdf2/discussions).
`fpdf2` also has a demo script to convert a GIF into a one-page-per-frame PDF: [gif2pdf.py](https://github.com/py-pdf/fpdf2/blob/master/tutorial/gif2pdf.py)
* [csv2pdf](https://github.com/TECH-SAVVY-GUY/csv2pdf) : convert CSV files to PDF files easily
* [Planet-Matriarchy-RPG-CharGen](https://github.com/ShawnDriscoll/Planet-Matriarchy-RPG-CharGen) : a PyQt based desktop application (= `.exe` under Windows) that provides a RPG character sheet generator
* [Petleo GMBH](https://petleo.net) : a software company that offers digital solutions for veterinarians, pet owners and pet service providers.

### Usage statistics

Expand Down
8 changes: 4 additions & 4 deletions docs/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends "base.html" %}

{% block announce %}
<center>
<a href="https://github.com/py-pdf/fpdf2/releases/tag/2.7.9">
New release: 2.7.9 on 2024/05/17
<!--center>
<a href="https://github.com/py-pdf/fpdf2/releases/tag/2.X.Y">
New release: 2.X.Y on 20YY/MM/DD
</a>
</center>
</center-->
{% endblock %}

{% block extrahead %}
Expand Down

0 comments on commit 8e3857d

Please sign in to comment.