photopea / Typr.js

Typr.js - process fonts in Javascript
MIT License
914 stars 73 forks source link

How to get baseline / x-height? #12

Closed ghost closed 7 years ago

ghost commented 7 years ago

How did you calculate the baseline of the path?

I noticed the demo page and readme have the baseline marked, but I can't work out how to get the baseline of a path from the font.hhea.ascender and font.hhea.descender provided.

photopea commented 7 years ago

You define the baseline wherever you want. In font coordinates, the baseline has the Y=0. The ascender is the height of the character above the baseline.

ghost commented 7 years ago

img

Thanks @photopea. Also, how can I find the x-height of a path from Typr.js?

photopea commented 7 years ago

You are welcome. First of all, don't "find" anything from a path, i.e. never analyze vector curves to get any information about the font. I think that the value that you are looking for is the sxHeight parameter of the OS/2 table: https://www.microsoft.com/typography/otspec/os2.htm

ghost commented 7 years ago

Thanks. sxHeight is what I was looking for