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

Height estimation is incorrect for a majority of custom fonts #93

Open
iGerman00 opened this issue Dec 29, 2023 · 4 comments
Open

Height estimation is incorrect for a majority of custom fonts #93

iGerman00 opened this issue Dec 29, 2023 · 4 comments

Comments

@iGerman00
Copy link

Snapshot of Untitled project - 2023-12-29 04-08-28 (0 000s)

In the screenshot I've loaded Source Sans Pro on the right which works correctly and is perfectly centered,
I also loaded in a random TTF font from dafont, and it's not centered. This is the case for most custom fonts I load, especially the artsy ones.

Changing the baseline, unfortunately, doesn't help much, with ideographic being the closest to being centered, and the rest just putting it even lower
msedge (2023-12-29 04։12։42)

@iGerman00
Copy link
Author

I've just updated to 4.1.1 (sorry about that and the last issue), and it seems like now it also completely ignores the context textBaseline? The issue otherwise is still present

@stefcameron
Copy link

I wonder if this is because of the way the library currently calculates the height of the text by setting the baseline to 'bottom' and use the TextMetrics.actualBoundingBoxAscent as the height, instead of using the newer TextMetrics.fontBoundingBoxAscent + TextMetrics.fontBoundingBoxDescent, which I believe consider the height of entire font instead of exactly what's rendered (so you get a bit more buffer).

In #95, I propose to move the library to use those newer metrics if available (note that the Node-based canvas package for rendering to canvas in Node does not support these, so the library falls back to its old calculation if that's the case).

@iGerman00
Copy link
Author

I noticed that there was a new package released by a third party as a result. I'm not sure if it actually fixed the issue since I can't change the font in their demo, but if it has, would you be able to look into adding it into this package?

@iGerman00
Copy link
Author

@geongeorge Bumping this since an update to my software is coming soon. If you could take a look at both the non-functional baseline config and the line height estimation, I'd really appreciate it.

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

2 participants