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

Metrics fixes #23

Open
mattdesl opened this issue Mar 2, 2018 · 2 comments
Open

Metrics fixes #23

mattdesl opened this issue Mar 2, 2018 · 2 comments

Comments

@mattdesl
Copy link

mattdesl commented Mar 2, 2018

Hey there,

I think it might be good to have a very robust test case for metrics that covers this module and also mdsf-bmfont. It seems like msdf-bmfont had some issues with alignment (Experience-Monks#11) which means all fonts exported with it may be wrong (and perhaps also msdf-bmfont-xml, since it seemed like I was getting similar alignments there).

Keep up the awesome work in this module, by the way! 😄

@soimy
Copy link
Owner

soimy commented Mar 15, 2018

Thanks for mention it. There are several commits ahead of Jam3/msdf-bmfont related on this issue like 437b2cb and 4a76865 .
I'm no expert at font metrics things, so if you found any metrics problems, please let me know, I'll try to fix.

@jcmonnin
Copy link

I also experienced metrics issues. When rendering the text, the bottom of the letters are getting below the line (for example the bottom of the 'g' character is cut). In my font example the lineHeight was reporting 33.6. It was looking right with a value of approximately 37. Using opentype.js.org, I checked the font properties:

  1. (os2.sTypoAscender- os2.sTypoDescender+ os2.sTypoLineGap) * fontSize / unitsPerEm = 33.5938
  2. (hhea.ascender - hhea.descender + hhea.lineGap) * fontSize / unitsPerEm = 37.5.

The actual code uses method 1. By observation, without really understanding the font metrics, I would say that taking the 3 properties from the "Horizontal Header table" instead of "OS/2 and Windows Metrics table" fixes the issue.

My test case was with the font Roboto-Regular.ttf, size 32.

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.

3 participants