Skip to content

Commit

Permalink
Fix NBSP support. Closes: py-pdf#834.
Browse files Browse the repository at this point in the history
  • Loading branch information
rysson committed Oct 10, 2023
1 parent a99de0a commit 811bb95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fpdf/line_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SOFT_HYPHEN = "\u00ad"
HYPHEN = "\u002d"
SPACE = " "
NBSP = "\u00a0"
NEWLINE = "\n"


Expand Down Expand Up @@ -409,6 +410,10 @@ def add_character(
self.number_of_spaces,
)
self.number_of_spaces += 1
elif character == NBSP:
# PDF viewers ignore NBSP for word spacing with "Tw".
character = SPACE
self.number_of_spaces += 1
elif character == SOFT_HYPHEN and not self.print_sh:
self.hyphen_break_hint = HyphenHint(
original_fragment_index,
Expand Down

0 comments on commit 811bb95

Please sign in to comment.