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

calculation of top/bottomMargin #507

Closed
schriftgestalt opened this issue Apr 3, 2020 · 4 comments
Closed

calculation of top/bottomMargin #507

schriftgestalt opened this issue Apr 3, 2020 · 4 comments

Comments

@schriftgestalt
Copy link
Contributor

How is fontParts calculating the vertical side bearings? What is the vertical origin?

@anthrotype
Copy link
Member

anthrotype commented Apr 3, 2020

@schriftgestalt I don't know about fontParts, but you may be interested in this related discussion on the ufo-spec repo about verticalOrigin, and the different defaults for glyph.height between defcon (0), on the one hand, and Glyphs.app/FDK (OS2.TypoAscender - OS2.TypoDescender), and my proposal to try align the two: unified-font-object/ufo-spec#95 (comment)

@anthrotype
Copy link
Member

anthrotype commented Apr 3, 2020

ufo2ft sets the default verticalOrigin to OS2.TypoAscender, if a particular glyph doesn't have a public.verticalOrigin in its lib:
https://github.com/googlefonts/ufo2ft/blob/66510c8128f9a447617c8c4d6d5871ef4577f74f/Lib/ufo2ft/outlineCompiler.py#L65

then the top sidebearing is computed as the verticalOrigin - bbox.yMax

https://github.com/googlefonts/ufo2ft/blob/66510c8128f9a447617c8c4d6d5871ef4577f74f/Lib/ufo2ft/outlineCompiler.py#L816-L819

@typesupply
Copy link
Member

How is fontParts calculating the vertical side bearings?

Here's the code: https://github.com/robotools/fontParts/blob/master/Lib/fontParts/base/glyph.py#L493

@schriftgestalt
Copy link
Contributor Author

As far as I see getting the topMargin of BaseGlyph will trigger a self.raiseNotImplementedError() in getHeight.
As far as I can see: bottomMargin = bbox.yMin and topMargin = height - bbox.yMax?

That will produce values not suitable for CJK glyphs. The links that Cosimo posted explain it quite well.

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