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

Dynamic font kerning bug #30014

Closed
sszigeti opened this issue Jun 23, 2019 · 5 comments · Fixed by #37963
Closed

Dynamic font kerning bug #30014

sszigeti opened this issue Jun 23, 2019 · 5 comments · Fixed by #37963

Comments

@sszigeti
Copy link

Godot version: 3.1.1

OS/device including version: Windows 10

Issue description: The dynamic font uses incorrect kerning values for a Google Font which renders correctly in Photoshop and in a browser.

Steps to reproduce: Open the demo project and observe the indicated visual problems, then compare with the included texture which shows the expected result.

Minimal reproduction project: https://github.com/sszigeti/godot-3.1.1-kerning-bug

Screenshot

@Raphael2048
Copy link
Contributor

Raphael2048 commented Jul 3, 2019

It seems to be the problem of the font, I tried it in unity and it overlaps too. And I get the font graph of 'P' and 'l' and put them together, then I got an image like this:
QQ20190703-134241@2x
You can see they overlaps. You can check font info use this: https://opentype.js.org/glyph-inspector.html
I think there are some intelligent mechanism when processing font in photoshop and Google fonts, so they don't overlap.

@ayuusweetfish
Copy link
Contributor

It is an aspect of the standard that FreeType does not handle. FT_HAS_KERNING indeed returns 0 on this font. FreeType docs suggest other libraries like HarfBuzz for such cases.

For the curious: many recent fonts store the kerning information in GPOS table and omit the good old kern table. GPOS contains far more information, often requiring more complex layout considerations, which is out of scope for FreeType as a font renderer 😝

@ayuusweetfish
Copy link
Contributor

It's possible to process the font before use.

Import the font into FontForge GUI, choose File → Generate Fonts, select the TrueType format, click Options, tick Old style 'kern' and generate.

The ttx utility may as well come handy for inspecting font file contents.

@Calinou
Copy link
Member

Calinou commented Apr 8, 2020

Since this is something we can't solve on our end, we should probably add a quick note in the DynamicFont documentation about FreeType limitations and document the workaround given by @kawa-yoiko.

@follower
Copy link
Contributor

Having just seen the workaround suggested in the docs and recently discovering that currently DynamicFont doesn't support kerning of any kind (see: #35730) I thought I'd mention that fact here to clarify that presently changing the kerning table included won't actually make the kerning work in Godot.

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

Successfully merging a pull request may close this issue.

6 participants