diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4de3c97..42c5a3837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/), and [PEP 440](https://www.python.org/dev/peps/pep-0440/). -## [2.4.1] - not released yet +## [2.4.1] - 2021-06-12 ### Fixed - erroneous page breaks occured for full-width / full-height images +- rendering issue of non-ASCII characaters with unicode fonts ## [2.4.0] - 2021-06-11 ### Changed diff --git a/fpdf/fpdf.py b/fpdf/fpdf.py index d089d14a1..415c05428 100644 --- a/fpdf/fpdf.py +++ b/fpdf/fpdf.py @@ -62,7 +62,7 @@ HERE = Path(__file__).resolve().parent # Global variables -FPDF_VERSION = "2.4.0" +FPDF_VERSION = "2.4.1" FPDF_FONT_DIR = HERE / "font" PAGE_FORMATS = { @@ -1634,7 +1634,7 @@ def cell( txt_frag_escaped = escape_parens( txt_frag.encode("UTF-16BE").decode("latin-1") ) - for char in txt_frag_escaped: + for char in txt_frag: self.current_font["subset"].append(ord(char)) else: txt_frag_escaped = escape_parens(txt_frag) diff --git a/test/cells/cell_markdown_with_ttf_fonts.pdf b/test/cells/cell_markdown_with_ttf_fonts.pdf index 63c17b165..02ce88d02 100644 Binary files a/test/cells/cell_markdown_with_ttf_fonts.pdf and b/test/cells/cell_markdown_with_ttf_fonts.pdf differ diff --git a/test/end_to_end_legacy/charmap/charmap_first_999_chars-DejaVuSans.pdf b/test/end_to_end_legacy/charmap/charmap_first_999_chars-DejaVuSans.pdf index 85bfc2ee8..31c3bcb3f 100644 Binary files a/test/end_to_end_legacy/charmap/charmap_first_999_chars-DejaVuSans.pdf and b/test/end_to_end_legacy/charmap/charmap_first_999_chars-DejaVuSans.pdf differ diff --git a/test/end_to_end_legacy/charmap/charmap_first_999_chars-DroidSansFallback.pdf b/test/end_to_end_legacy/charmap/charmap_first_999_chars-DroidSansFallback.pdf index d7a4fb7d4..734f42638 100644 Binary files a/test/end_to_end_legacy/charmap/charmap_first_999_chars-DroidSansFallback.pdf and b/test/end_to_end_legacy/charmap/charmap_first_999_chars-DroidSansFallback.pdf differ diff --git a/test/end_to_end_legacy/charmap/charmap_first_999_chars-Roboto-Regular.pdf b/test/end_to_end_legacy/charmap/charmap_first_999_chars-Roboto-Regular.pdf index b98874312..0a0a4edb5 100644 Binary files a/test/end_to_end_legacy/charmap/charmap_first_999_chars-Roboto-Regular.pdf and b/test/end_to_end_legacy/charmap/charmap_first_999_chars-Roboto-Regular.pdf differ diff --git a/test/end_to_end_legacy/charmap/charmap_first_999_chars-cmss12.pdf b/test/end_to_end_legacy/charmap/charmap_first_999_chars-cmss12.pdf index b289455af..b403d7ffd 100644 Binary files a/test/end_to_end_legacy/charmap/charmap_first_999_chars-cmss12.pdf and b/test/end_to_end_legacy/charmap/charmap_first_999_chars-cmss12.pdf differ diff --git a/test/fonts/render_en_dash.pdf b/test/fonts/render_en_dash.pdf new file mode 100644 index 000000000..48ad8e4a6 Binary files /dev/null and b/test/fonts/render_en_dash.pdf differ diff --git a/test/fonts/test_add_font.py b/test/fonts/test_add_font.py index 4af800b23..b1d375b1b 100644 --- a/test/fonts/test_add_font.py +++ b/test/fonts/test_add_font.py @@ -109,3 +109,13 @@ def test_add_core_fonts(): pdf.add_font("times", style="") pdf.add_font("courier") assert pdf.fonts == {} # No fonts added, as all of them are core fonts + + +def test_render_en_dash(tmp_path): # issue-166 + pdf = FPDF() + font_file_path = HERE / "../fonts/Roboto-Regular.ttf" + pdf.add_font("Roboto-Regular", fname=font_file_path, uni=True) + pdf.set_font("Roboto-Regular", size=120) + pdf.add_page() + pdf.cell(w=pdf.epw, txt="–") # U+2013 + assert_pdf_equal(pdf, HERE / "render_en_dash.pdf", tmp_path) diff --git a/test/html/issue_156.pdf b/test/html/issue_156.pdf index 1ed99e6e5..bf28a417a 100644 Binary files a/test/html/issue_156.pdf and b/test/html/issue_156.pdf differ