Skip to content

Commit f03b3b1

Browse files
authored
Changelog and tests (#1109)
1 parent 286f5e6 commit f03b3b1

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
3333
* fixed gutter handing when a pagebreak occurs within a table with header rows - thanks to @mjasperse
3434
* fixed handling of `border=0` in HTML table - thanks to @mjasperse
3535
* [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html) now properly honors `align=` attributes in `<th>` tags
36+
* fixed problem using bold italic standard fonts in markdown - thanks to @Alan-Collins
3637
### Changed
3738
* refactored [`FPDF.multi_cell()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.multi_cell) to generate fewer PDF component objects - thanks to @mjasperse
3839
* outer table borders are now drawn continuously for nonzero `gutter_width`/`gutter_height`, with spacing applied inside the border similar to HTML tables - thanks to @mjasperse - cf. [#1071](https://github.com/py-pdf/fpdf2/issues/1071)

fpdf/fpdf.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -3214,23 +3214,20 @@ def _preload_font_styles(self, text, markdown):
32143214
prev_font_style += "U"
32153215
styled_txt_frags = tuple(self._parse_chars(text, markdown))
32163216
if markdown:
3217-
# Know problem:
3218-
# If a bold italic font is present (like courierBI) fpdf2 will add
3219-
# courierB, courierI and courierBI to the output pdf
32203217
page = self.page
32213218
# We set the current to page to zero so that
32223219
# set_font() does not produce any text object on the stream buffer:
32233220
self.page = 0
3224-
if any("B" in frag.font_style for frag in styled_txt_frags):
3221+
if any(frag.font_style == "B" for frag in styled_txt_frags):
32253222
# Ensuring bold font is supported:
32263223
self.set_font(style="B")
3227-
if any("I" in frag.font_style for frag in styled_txt_frags):
3224+
if any(frag.font_style == "I" for frag in styled_txt_frags):
32283225
# Ensuring italics font is supported:
32293226
self.set_font(style="I")
3230-
if any("BI" in frag.font_style for frag in styled_txt_frags):
3227+
if any(frag.font_style == "BI" for frag in styled_txt_frags):
32313228
# Ensuring bold italics font is supported:
32323229
self.set_font(style="BI")
3233-
if any("" in frag.font_style for frag in styled_txt_frags):
3230+
if any(frag.font_style == "" for frag in styled_txt_frags):
32343231
# Ensuring base font is supported:
32353232
self.set_font(style="")
32363233
for frag in styled_txt_frags:
1.13 KB
Binary file not shown.

test/text/test_cell.py

+9
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ def test_cell_markdown(tmp_path):
173173
assert_pdf_equal(pdf, HERE / "cell_markdown.pdf", tmp_path)
174174

175175

176+
def test_cell_markdown_bold_italic(tmp_path):
177+
# issue 1094
178+
pdf = FPDF()
179+
pdf.add_page()
180+
pdf.set_font("Times", size=60)
181+
pdf.cell(text="**__Lorem --Ipsum--__**", markdown=True)
182+
assert_pdf_equal(pdf, HERE / "cell_markdown_bold_italic.pdf", tmp_path)
183+
184+
176185
def test_cell_markdown_with_ttf_fonts(tmp_path):
177186
pdf = FPDF()
178187
pdf.add_page()

0 commit comments

Comments
 (0)