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
Generating a static font from variable font results in inconsistent letter spacing #3454
Comments
|
Thanks @m4rc1e but that didn't make any difference, except, the generated static file size got increased from 75k to around 700K when changing from varLib.mutator to varLib.instancer and they both behave the same. Still the letter spacing is like completely gone versus using the variable font directly.
Loading the font in HTML, Android, iOS, renders the same behavior of completely no letter spacing, and susceptibly kerning as well. |
Try with OS/2.recalcAvgCharWidth font = TTFont('static.ttf')
font['OS/2'].recalcAvgCharWidth()
font.save('static.ttf') |
To use recalcAvgCharWidth I had to pass it the actual variable font instance for it to work since it requires ttFont as an argument, which ends up with a 751K font file for weight 500; my final code is as follows.
Will test it and update back, tho I'm not feeling confident from calling |
Your You should use: Anyway, I downloaded Robot Flex from Google and exported all the static instances
The static instances didn't need the recalculation of the xAvgCharWidth vaule. See attached files: static.zip |
Thanks @ftCLI I tested with both your generated static fonts and I did generate my own using the same command provided and it seems working so far, need to validate on all pre-defined weights yet with what's included in Figma. One more thing, we're using custom weights like 425 and 475 at some places, so how can I generate these as well? Much appreciate your outstandingly fast response :) |
To generate static fonts for non-named instances, add the '-s' switch. It will allow you to choose custom values for each axis. Without passing |
So, I was just validating on a single line with only five words comparing both line spacing as in Figma versus usage in Jetpack Compose and it shows the letter spacing is actually accurate, however, when tested on a multi-line block of text with more than fifty words, it got completely messed up and the letter spacing is not as it is in Figma, or Adobe Illustrator, to make sure nothing funny caused by any of these tools tho they're giving both same output but not similar to the generated font file. Not sure what might be the reason of that, I tried with multiple font weights from the attached statically generated fonts you did without any luck. |
I don't have Figma nor Illustrator, can't help. Those are not valid fonts anyway, at least the name table should be updated. These ones pass fontbakery check-universal (with some warnings): static.zip |
I am using Roboto Flex font, and the following is the command being used to generate a static instance.
$ fonttools varLib.mutator RobotoFlex-VariableFont_GRAD,XTRA,YOPQ,YTAS,YTDE,YTFI,YTLC,YTUC,opsz,slnt,wdth,wght-VF.ttf wght=100 wdth=100
and different weights.Now, wherever (web, mobile) this font is being used, the letter spacing is completely not related to what has been I believe the default within the variable font itself.
What might I be doing wrong?
The text was updated successfully, but these errors were encountered: