From 775684698c434a6b3e86ea84c604e17d6b0fd0a0 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 30 Sep 2024 09:33:28 +0200 Subject: [PATCH] Doc: mention that text() does lack features (#1265) * adept comparison table in Text.md (add text shaping) * add a note in the functions doc string --- docs/Text.md | 14 +++++++------- fpdf/fpdf.py | 9 ++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/Text.md b/docs/Text.md index 565c09786..0bf9d11e8 100644 --- a/docs/Text.md +++ b/docs/Text.md @@ -4,13 +4,13 @@ There are several ways in fpdf to add text to a PDF document, each of which come ## Simple Text Methods -| method | lines | markdown support | HTML support | accepts new current position | details | -| -- | :--: | :--: | :--: | :--: |-----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [`.text()`](#text) | one | no | no | fixed | Inserts a single-line text string with a precise location on the base line of the font. | -| [`.cell()`](#cell) | one | yes | no | yes | Inserts a single-line text string within the boundaries of a given box, optionally with background and border. | -| [`.multi_cell()`](#multi_cell) | several | yes | no | yes | Inserts a multi-line text string within the boundaries of a given box, optionally with background, border and padding. | -| [`.write()`](#write) | several | no | no | auto | Inserts a multi-line text string within the boundaries of the page margins, starting at the current x/y location (typically the end of the last inserted text). | -| [`.write_html()`](#write_html) | several | no | yes | auto | An extension to `.write()`, with additional parsing of basic HTML tags. +| method | lines | markdown support | HTML support | text shaping | accepts new current position | details | +| -- | :--: | :--: | :--: | :--: | :--: |-----------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [`.text()`](#text) | one | no | no | no | fixed | Inserts a single-line text string with a precise location on the base line of the font. | +| [`.cell()`](#cell) | one | yes | no | yes | yes | Inserts a single-line text string within the boundaries of a given box, optionally with background and border. | +| [`.multi_cell()`](#multi_cell) | several | yes | yes | yes | yes | Inserts a multi-line text string within the boundaries of a given box, optionally with background, border and padding. | +| [`.write()`](#write) | several | no | no | no | auto | Inserts a multi-line text string within the boundaries of the page margins, starting at the current x/y location (typically the end of the last inserted text). | +| [`.write_html()`](#write_html) | several | no | yes | yes | auto | An extension to `.write()`, with additional parsing of basic HTML tags. ## Flowable Text Regions diff --git a/fpdf/fpdf.py b/fpdf/fpdf.py index f3caae6db..823bcdf4b 100644 --- a/fpdf/fpdf.py +++ b/fpdf/fpdf.py @@ -353,7 +353,7 @@ def set_encryption( permissions=AccessPermission.all(), encrypt_metadata=False, ): - """ " + """ Activate encryption of the document content. Args: @@ -2551,6 +2551,13 @@ def text(self, x, y, text=""): y (float): ordinate of the origin text (str): string to print txt (str): [**DEPRECATED since v2.7.6**] string to print + + Notes + ----- + + `text()` is kept for backwards compatibility. It lacks many of the + features available in `FPDF.write()`, `FPDF.cell()` and `FPDF.multi_cell()` + like markdown and text shaping. """ if not self.font_family: raise FPDFException("No font set, you need to call set_font() beforehand")