Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert glyph without unicode def #2970

Closed
Andreasox opened this issue Jan 3, 2024 · 3 comments
Closed

Insert glyph without unicode def #2970

Andreasox opened this issue Jan 3, 2024 · 3 comments
Labels
not a bug not a bug / user error / unable to reproduce question

Comments

@Andreasox
Copy link

Description of the bug

I assume it is not possible to reference a glyph without a unicode name in insert_text and insert_textbox for export to PDF.

How to reproduce the bug

At least Gotham Narrow fonts have defined a separate range of digits 0-9 without unicode names.
Downloaded from https://freefontsfamily.com/gotham-font-family/
Glyphs 0183 - 018d, they are named in the font as zero.tab, one.tab, two.tab etc. (checked for Gotham Narrow Medium)

PyMuPDF version

1.23.8

Operating system

MacOS

Python version

3.9

@JorjMcKie
Copy link
Collaborator

I'm not sure I understand the issue.
Both methods Page.insert_text/Page.insert_textbox simply use the Unicode number of a character to lookup the desired glyph and then output the glyph's hex value.
There is no other check whatsoever.

@Andreasox
Copy link
Author

I interpret your answer as my assumption is correct, pymupdf (Python/HTML) can only access glyphs with a valid Unicode codepoint.
To make such glyphs usable, we must update the fonts with valid Unicode codepoints and ensure that the fonts are embedded in the PDF.

@JorjMcKie
Copy link
Collaborator

To make such glyphs usable, we must update the fonts with valid Unicode codepoints and ensure that the fonts are embedded in the PDF.

Correct - with the additional comment that the embedding itself is happening automatically, once at least one Unicode of the font has been written.
Initially, a font is embedded in its entirety. You have the option to execute doc.subset_fonts() right before saving. This will scan the PDF for fonts that benefit from a smaller size, when unused glyphs are stripped off of it. Beneficial for large fonts (e.g. Asian scripts).

@JorjMcKie JorjMcKie added not a bug not a bug / user error / unable to reproduce question labels Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug not a bug / user error / unable to reproduce question
Projects
None yet
Development

No branches or pull requests

2 participants