#FLM: ReType Complete Real Asc/Desc V2.0 # Find and fill real asc and desc values in all open fonts from robofab.world import CurrentFont,AllFonts max_Y_values = [] min_Y_values = [] for font in AllFonts(): for x in font: max_Y_values.append(x.box[3]) min_Y_values.append(x.box[1]) WinAscend = max(max_Y_values) WinDescend = min(min_Y_values) Ascender = font.info.ascender Descender = font.info.descender Gap = (Ascender + abs(Descender)) - (WinAscend + abs(WinDescend)) for font in AllFonts(): font.info.openTypeOS2WinAscent = WinAscend font.info.openTypeOS2WinDescent = abs(WinDescend) font.info.openTypeOS2TypoAscender = Ascender font.info.openTypeOS2TypoDescender = Descender font.info.openTypeHheaAscender = WinAscend font.info.openTypeHheaDescender = -abs(WinDescend) font.info.openTypeHheaLineGap = 0 font.info.openTypeOS2TypoLineGap = abs(Gap) print print "In all open fonts:" print "The maximun Y value is: "+ str(max(max_Y_values)) print "The minimum Y value is: "+ str(min(min_Y_values)) print "TypoLineGap is: " + str(Gap)
Comments
there is another script by @Jens Kutilek (based on Karsten Lücke’s Calculations) for calculating the vertical metrics as well:
https://github.com/jenskutilek/RoboFont/blob/master/scripts/SetVerticalMetrics.py
I sort of forgot the 'Aringacute' issue because I don't include it anymore in my fonts.
But you are right, this situation should be addressed. Below is the same script but with a line that exclude 'Aringacute' from the list. IMO, 'aringacute' is not usually a problem. I will check later Jens' script (surely way much better than mine).
It will also get dimensions of composite characters and utilizes a banList of omitted glyphs.
I agree—and when planning these values from the beginning, you should consider that you need to either allow for such things as Vietnamese stacked accents from the beginning (even if they aren't in your current plans), else be prepared that if you add such things later, you may have to break vertical metrics compatibility with the older version of the font.
And I frequently work on fonts from other designers and therefore need to asses the family to enter the correct values. I am not producing Vietnamese fonts and I don't need to care much about stacked diacritics.
Example:
You surely can improve it but it works for me.
Regarding a webfont font metrics strategy, it is quite simple to implement in the script but I am not sure which should be the most advisable policy. I used to follow the recommendation I found on a Google's page at: https://code.google.com/archive/p/googlefontdirectory/wikis/HowToGenerateWebNativeFonts.wiki but it's not available anymore and the recommendations were different to the one in the Glyphs' page.
For my web fonts I usually follow the following strategy:
First, calculate the winAscent and winDescent values, then:
So, question to everybody, what is currently the best font metric policy for web fonts?
EDIT: thanks for the links, they were what I wanted to know!