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

Problem upgrading to 2.x version in CJK fonts #44

Closed
HarelM opened this issue Feb 16, 2022 · 2 comments
Closed

Problem upgrading to 2.x version in CJK fonts #44

HarelM opened this issue Feb 16, 2022 · 2 comments

Comments

@HarelM
Copy link
Contributor

HarelM commented Feb 16, 2022

Hi,

We have upgraded tiny-sdf from version 1.x to 2.x.
As part of the upgrade we understood we need to use the return value of the draw method to get the actual values, which was a breaking change from version 1.x
We did the required changes but now we see that there's an issue with the top offset returned from tiny-sdf as can be seen in the following issue:
maplibre/maplibre-gl-js#1002
Can you please elaborate what should be the right way to use this library to get a correct value for the offset top for CJK fonts?

Thanks again for all the hard work invested in this library!

@mourner
Copy link
Member

mourner commented Feb 16, 2022

The related change was introduced in v1.2.4, it was just not marked as breaking because it used an optional metrics pathway (which became the default later, in v2). See #30. The adjustment GL JS uses is basically top = glyphTop - 27, but it's because of the way fonts are generated server-side, not any flaws in TinySDF logic. Quoting @ChrisLoer:

TinySDF's "top" is the distance from the alphabetic baseline to the top of the glyph. Server-generated fonts specify "top" relative to an origin above the em box (the origin comes from FreeType, but I'm unclear on exactly how it's derived)
ref: https://github.com/mapbox/sdf-glyph-foundry

Server fonts don't yet include baseline information, so we can't line up exactly with them (and they don't line up with each other)
ref: mapbox/node-fontnik#160

To approximately align TinySDF glyphs with server-provided glyphs, we use this baseline adjustment factor calibrated to be in between DIN Pro and Arial Unicode (but closer to Arial Unicode)

@mourner mourner closed this as completed Feb 16, 2022
@HarelM
Copy link
Contributor Author

HarelM commented Feb 16, 2022

Thanks for the info and the super fast response!

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