-
Notifications
You must be signed in to change notification settings - Fork 94
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
Unexpected kerning introduced by fontmake to variable font export (but not to static ttf) #470
Comments
Which one of the two is the correct? |
Sorry about that confusing phrasing, @anthrotype. The Variable font gets different kerning than the existing, status-quo static font file, which I am trying to match. The variable font kerning is incorrect. I have edited the designspace slightly to make the variable font work, so I tested whether a newly-generated static font would have correct or incorrect kerning. When I use FontMake to export a new static TTF from the same edited designspace, it has no visible difference with the status-quo font file. The new Static TTF is correct (in terms of lettershapes and kerning, at least). I am working in this repo: The designspace file used for both the new variable TTF and the new static TTF is: https://github.com/thundernixon/Encode-Sans/blob/40a6ca8df6b54ca5e6e96657c0f3cbe08ba83526/master_ufo/EncodeSans-mathfix-ds_v3.designspace I built the variable font with this script: I built the static font with this command:
Please let me know if I can give any further information. Thanks for taking a look! |
I’ll have a look, but just some quick comments:
|
Thanks for the info on command line vs scripting use, and thanks for the suggested command.
|
I've just learned from @mjlagattuta that there is a known bug in macOS CoreText that doesn't correctly represent the metrics in glyphs with components: That seems to point to this being an issue in CoreText, not in FontMake. I'll dig further into it by exported a font without components, and report back if metrics are still wrong in the VF. Thanks for taking a look! |
Reopening this because the testing I did seemed to point to the problem being produced in the FontMake stage. It certainly might be something I'm doing wrong, but I don't see errors in a font bakery QA that would seem to cause this issue, so it seems possible that it's coming up in the FontMake export. Here's how I tested this. Test 1: Checking if a decomposed VF would work as expected, generated via FontMakeProcess:
Results:
Test 2: checking whether another VF export method would work differentlyProcess
Results: Files tested: my latest Drawbot test folder What letters are impacted?I haven't been able to find a perfect way to find all impacted letters yet. If this seems useful any ideas for testing this are welcome! It is clear that it's most disruptive from the I don't see these kerns when I open the VF TTF in In Illustrator (here's a positive 59 units): However, I don't see the kern values if I open the VF TTF in Glyphs: Have I somehow mistested this, or could these unexpected kerns be coming from some part of the FontMake export process? |
I was able to replicate this error when building Encode Sans as well. Running varLib.mutator on the VF also generates a static ttf with the broken kerning. It is worth noting that there is no difference between the fontmake instance export and vf export when exporting the default set of outlines (i.e. the variation origin), but the problem got worse as weight and width was increased. For reference as to the severity of the added kerning, Black Condensed (wght=900 wdth=75) had kerning between the \l and the \i of +240 |
Upon further examination I discovered that the kern value of +240 is coming from the kern between \lcaron and \l or \dcaron and \l It appears that the way fontmake parses the kerning table led to the \l class taking on the same value as \lcaron. Once \lcaron and \dcaron were deleted from the source file, the VF had no weird kerning being applied to the \l class. Any ideas on what may be causing this behavior? |
thanks @thundernixon and @mjlagattuta for the detailed report. Just so you know I'm not ignoring this, I had been busy with other things last week. I will try to take a look at this in the next few days. |
Thanks for letting us know that, @anthrotype. I know you have a lot on your plate! I'll keep poking around to see if I can add more detail that might help diagnose this issue and update here as I can. |
there is actually too much details and info in this issue report.. I need a simple way to reproduce this. |
btw, I've noticed something that doesn't look right in the EncodeSans.glyphs file from thundernixon/EncodeSans master branch (as of commit thundernixon/Encode-Sans@7dc54a0), though I'm not sure yet if it's related. The Width axis varies between 0 and 1000, whereas it is normally specified as a percentage, with 100 being the Normal width, 50 % being Ultra-Condensed, 200 % Ultra-expanded, etc. https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass There may be an issue in glyphsLib here, because it seems it is assuming that all the .glyphs source files follow this rule when it's generating the designspace axes map. In the case of EncodeSans, the width axis' user locations respectively of the most condensed and extended masters are begin set to 0 and 1000 (their design locations), whereas they should probably be something below and above 100. glyphsLib also supports the "Axis Location" master custom parameter, which specifies the user location for a master along a certain axis (the list of axes can be defined in a "Axes" font custom parameter). |
cc @belluzj (author of the above mentioned code in glyphsLib) |
ok I can reproduce the varfont kerning issue. Here's what I did: $ git clone https://github.com/thundernixon/Encode-Sans
$ fontmake -g sources/Encode-Sans.glyphs -o variable then set the string This is how it looks with kern feature disabled: $ hb-shape variable_ttf/EncodeSans-VF.ttf --variations=wght=900,wdth=750 --features=-kern diblil
[d=0+1394|i=1+658|b=2+1394|l=3+658|i=4+658|l=5+658]
$ hb-view variable_ttf/EncodeSans-VF.ttf --variations=wght=900,wdth=750 --features=-kern diblil This is the same font, same axis coordinates, but with kern feature enabled (it definitely looks wrong): $ hb-shape variable_ttf/EncodeSans-VF.ttf --variations=wght=900,wdth=750 --features=+kern diblil
[d=0+1715|i=1+979|b=2+1386|l=3+979|i=4+979|l=5+658]
$ hb-view variable_ttf/EncodeSans-VF.ttf --variations=wght=900,wdth=750 --features=+kern diblil I also tried to build a static TTF version from the same EncodeSans.glyphs file, with this command:
Note: "SemiExpanded Black" instance corresponds to wght=900 and wdth=750 user locations. Comparing without and with the kern feature, in the case of the static TTF, does not show the huge difference seen above for the VF: $ hb-shape instance_ttf/EncodeSansSemiExpanded-Black.ttf --features=-kern diblil
[d=0+1394|i=1+658|b=2+1394|l=3+658|i=4+658|l=5+658]
hb-view instance_ttf/EncodeSansSemiExpanded-Black.ttf --features=-kern diblil $ hb-shape instance_ttf/EncodeSansSemiExpanded-Black.ttf --features=+kern diblil
[d=0+1394|i=1+658|b=2+1386|l=3+658|i=4+658|l=5+658]
hb-view instance_ttf/EncodeSansSemiExpanded-Black.ttf --features=+kern diblil Something is happing when fonttools.varLib is generating the VF GPOS table... Need more time to investigate. |
Thanks so much for taking a look! Thanks also for providing a good example of the right amount of information to show the issue. Part of the reason for all the information from me is that it took some time to narrow down the best way to show the problem. Thanks for pointing out the width axis values. I'll find a way to correct that, and add it to my build script. Interesting point about the missing For what it's worth, to reproduce my exact conditions, you can set up a Python 3 environment, then run the |
@thundernixon so, the I actually tried to run that script (I had to comment out $ fontmake -g sources/Encode-Sans.glyphs -o variable
[...]
INFO:fontTools.varLib:Generating avar
Traceback (most recent call last):
File "/home/clupo/.pyenv/versions/fontmake-py27/bin/fontmake", line 11, in <module>
load_entry_point('fontmake', 'console_scripts', 'fontmake')()
File "/home/clupo/Github/fontmake/Lib/fontmake/__main__.py", line 258, in main
project.run_from_glyphs(glyphs_path, **args)
File "/home/clupo/Github/fontmake/Lib/fontmake/font_project.py", line 561, in run_from_glyphs
self.run_from_designspace(designspace_path, **kwargs)
File "/home/clupo/Github/fontmake/Lib/fontmake/font_project.py", line 646, in run_from_designspace
**kwargs)
File "/home/clupo/Github/fontmake/Lib/fontmake/font_project.py", line 715, in run_from_ufos
master_bin_dir=master_bin_dir)
File "/home/clupo/Github/fontmake/Lib/fontmake/font_project.py", line 268, in build_variable_font
font, _, _ = varLib.build(designspace_path, finder)
File "/home/clupo/Github/fonttools/Lib/fontTools/varLib/__init__.py", line 731, in build
_add_avar(vf, ds.axes)
File "/home/clupo/Github/fonttools/Lib/fontTools/varLib/__init__.py", line 146, in _add_avar
assert sorted(vals) == vals
AssertionError |
Correct, the source file is fixed by running the build script, and the VF is built from the temporary, fixed file. I need to dig into the code more to understand why, but the values are applied correctly when I'm in my Python 3 environment, but incorrectly in my Python 2 environment. However, this script should also be applying proper width values, so I have some troubleshooting to do on my end. Thanks for flagging this for me. UPDATE: I'm realizing that the |
hm.. ok. I was forced to use python2 to run the fix-designspace.py script because it contains print statements (also didn't want to fix it myself..). Also the build.sh script calls it as Are you suggesting that building the same designspace yields different output when running from either python2 or 3? |
One possibility for the difference between running fix-designspace.py in Python2 versus Python3 is the rounding function. Python2 rounds based on being above or below x.5 meanwhile Python3 rounds to the nearest even number. |
fontTools.misc.py23 module has both round2 and round3 that works on either python. And it also has an your script throws SyntaxError on python3. |
even after turning the print statements into calls to print() function (after |
I've updated the glyphs source back to being the original, and the build script is now working better and less-manually. The width values are properly getting exported, based on tests at axis-praxis. Here's the latest font build: It still does have some fontbakery issues, but none that seem to explain the kern regrouping. Not sure if you really needed the update, but I appreciate your critique and wanted to fix the issues pointed out. |
Thanks, I’ll have a look again next week. |
I pulled the latest master of EncodeSans repo (I see you fixed the width axis values -- good), re-run the fix-designspace.py script, re-built the varfont with fontmake from the fixed Encode-Sans.glyphs, and I can confirm the kerning issue is still there. I tried to subset the interpolatable master TTFs so that they only contain glyphs "b" "d" "i" "l", "idotaccent", "idotless", and "dotaccentcomb" (using the the command I then run I'm uploading below the set of interpolatable master TTFs (both the full fonts, and the subsetted ones) with the accompanying designspace file and the generated variable fonts: Here are the commands to build the two variable fonts, one that uses the full masters, the other using the subsetted ones: $ fonttools varLib --master-finder "master_ttf_interpolatable_full/{stem}.ttf" -o EncodeSans-full-VF.ttf EncodeSans.designspace
$ fonttools varLib --master-finder "master_ttf_interpolatable_subset/{stem}.ttf" -o EncodeSans-subset-VF.ttf EncodeSans.designspace Running hb-view/hb-shape with @behdad do you mind taking a look? |
Thanks for bearing with my learning curve here, for running the build again, and for experimenting some more! As @mjlagattuta said above, subsetting the font even helps when it's as simple as removing a couple of problematic letters:
If static TTFs are exported, the kerning (appears to be) correct. I wanted to try to diff the |
At least I remembered there's something smelly in that part of code so that was the big indeed. Unlike what the comment suggests, I remember the full issue now. Fix is correct for now. @anthrotype, is possible please add a test case for this so I don't break or again. Subsetting for dcaron etc may contain the bug without the commit, for test generation purpose? |
thanks @behdad for taking care of this! |
Thanks so much for taking a look and suggesting a current workaround, @behdad and @anthrotype! |
I have been testing the same issue, trying to understand why it happens.
I get significantly less records. It generates inconsistently between two states. When interpolation happens it also overflows to other pairs. I am trying to find where the count is reduced and why. If you have any pointers it would help. |
So as to not be quick to react, but you know more about the issue. But here is what I found out:
And now it seems to always compile interpolated kerning. |
I thought the issue had been fixed, as @thundernixon and you @VivaRado also confirmed. |
I'm not getting an error, it just compiles the same source inconsistently.
I did a XML check and when I compared two generated instances there where
different contents, but different consistently. Either there was
interpolation or wasn't.
I raised a new issue for varLib merger. As I progress in compiling my font
property I will submit whatever I find helps me do that.
Thank you
On 17 Dec 2018 16:31, "Cosimo Lupo" <notifications@github.com> wrote:
I thought the issue had been fixed, as @thundernixon
<https://github.com/thundernixon> and you @VivaRado
<https://github.com/VivaRado> also confirmed.
Can you explain in more details what the issue is?
If you're seeing a new or different issue than the one originally reported
please file a separate issue report.
Note that the fact that you get offset overflows while compiling the GPOS
(or GSUB) table doesn't mean there is anything faulty, it's just the way it
is, that amount of data and the way fonttools packs it into binary may
produce offsets that exceed unsigned short, thus requiring an extension
lookup. The message you get on the console has an "INFO" level of severity,
not WARNING or ERROR.
(I'm thinking that we should just demote those logging messages to DEBUG,
as several users seem confused by those /cc @behdad
<https://github.com/behdad>)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#470 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoFvb1gzCd9msuGPAsAN2D1I9Rn53zChks5u53JxgaJpZM4XUJ4q>
.
|
I've exported a static TTF and a variable TTF via FontMake, and I'm finding that the Variable TTF gets unexpected kerning.
Amongst other differences, an obvious thing is that the
i
seems to get extra kerning to the left side, against even straight letters where there shouldn't need to be kerning. This kern doesn't exist in the Glyphs sources (unless I'm somehow missing it). Why might this being added in the variable font?Here's a screencap showing a comparison between static and VF at the Regular weight/width, then a comparison with kerning taken away from both:
It also gets different kerning than a previously-generated static version. Here's an overlay to compare the two (variable font in green, just a bit wider from the added positive kerns):
The text was updated successfully, but these errors were encountered: