-
Description of the bugGlyphs with unicode 2000-200A are not rendered if used in the end of the string How to reproduce the bugAccording to #2970 I updated problematic glyphs (0-9 alternates) with Unicode codepoints in the range 2000-200F, see font https://www.dropbox.com/scl/fi/omdtevtwi9r6ps2ym2e44/GothamNarrow-Medium.otf?rlkey=bo7w24upjt9iopb8am51ks4ar&dl=0 insert_textbox will not render certain glyphs if ending the string with them, e.g.: shape.insert_textbox(rect, '\u2001\u2001\u2001', align=1, fontname='GothamNarrow-Medium', fontsize=14.8) Is it possible to debug this confusing issue? PyMuPDF version1.23.8 Operating systemMacOS Python version3.9 |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 7 replies
-
Can you provide the final font please - including your modifications? |
Beta Was this translation helpful? Give feedback.
-
Several reasons may be possible, like an error in the glyph bbox, etc. |
Beta Was this translation helpful? Give feedback.
-
Dropbox link to the font (not allowed to be attached as is): https://www.dropbox.com/scl/fi/omdtevtwi9r6ps2ym2e44/GothamNarrow-Medium.otf?rlkey=bo7w24upjt9iopb8am51ks4ar&dl=0 |
Beta Was this translation helpful? Give feedback.
-
Realized that this may be a whitespace issue as the codepoints I selected are different kind of spaces (2000-200A). |
Beta Was this translation helpful? Give feedback.
-
Ok I'll wait and mark this issue accordingly. |
Beta Was this translation helpful? Give feedback.
-
Thinking about it, for the time being this post is more a "Discussions" item than anything else. |
Beta Was this translation helpful? Give feedback.
-
It is a whitespace issue, codepoints 2000-200A and 202F will be stripped off from the right end of any string using insert_textbox (and probably with insert_htmlbox as well, not tested). Moving the glyphs to other codepoints do work. I am still struggling to use a variable with syntax protecting from \ and unicode issues, cannot make it work. rect = Rect(197.5, 144.0, 397.5, 251.0)
shape.insert_textbox(rect,linenumber.replace('u', r'\u'), align=1, fontname='GothamNarrow-Medium', fontsize=14.8)
rect = Rect(197.5, 130.0, 397.5, 251.0) ![]() |
Beta Was this translation helpful? Give feedback.
-
We think it may be a PyMuPDF issue that we cannot get unicode names in a Python variable to render the real glyphs. |
Beta Was this translation helpful? Give feedback.
-
Downloaded the font from here and made this script import fitz
fontfile = "GothamNarrow-Medium.otf"
doc = fitz.open()
page = doc.new_page()
page.insert_font(fontname="F0", fontfile=fontfile)
page.insert_text((100, 100), "⅓⅓⅓", fontname="F0", fontsize=14.8)
doc.save("test.pdf") Same thing for textbox output. |
Beta Was this translation helpful? Give feedback.
-
This script works as desired: import fitz
fontfile = "GothamNarrow-Medium.240109-1605.otf"
text = f"{chr(0x2032)}{chr(0x2032)}{chr(0x2032)}"
doc = fitz.open()
page = doc.new_page()
page.insert_font(fontname="F0", fontfile=fontfile)
page.insert_text((100, 100), text, fontname="F0", fontsize=14.8)
doc.save("test.pdf") |
Beta Was this translation helpful? Give feedback.
This script works as desired: