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

Custom fonts have really large text boxes when selecting #108

Open
cyphar opened this issue Dec 22, 2021 · 2 comments
Open

Custom fonts have really large text boxes when selecting #108

cyphar opened this issue Dec 22, 2021 · 2 comments

Comments

@cyphar
Copy link
Contributor

cyphar commented Dec 22, 2021

When creating a PDF using printpdf, I've noticed that with custom fonts (specifically Roboto Slab and B612 Mono), when you try to select text in a PDF viewer the selection will be much taller than the text and will overlap adjacent lines (rendering them invisible). If I use the built-in courier fonts with exactly the same text settings, the problem goes away. Here's a screenshot of the issue in Evince:

2021-12-23-094214_561x794_scrot

This is most notable when opening the PDF in Evince. In Firefox and Chrome the selected text is the right height. You can get a copy of an example PDF with this problem here.

@fschutt
Copy link
Owner

fschutt commented Dec 24, 2021

The "problem" with those fonts is that the unitsPerEm field is set to 2000 instead of the default 1000 and Evince is the only PDF viewer that doesn't respect that.

image

I can work around it by dividing the ascender / descender by 2.0, but then the text appears "spaced out", because the glyph widths still expect 2000 units per em:

image

I also need to debug why the ascender / descender doesn't use the sTypoMetrics field as it should. The fix is to scale the ascender / descender AND the glyph widths to 1000em and also to submit a bug report to Evince.

@seijikun
Copy link

seijikun commented May 21, 2023

Same problem with Okular. I think both depend on Poppler for pdf parsing/rendering, so if that's really a viewer bug, it might be located there.
I opened a bug for Okular: https://bugs.kde.org/show_bug.cgi?id=470091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants