-
Notifications
You must be signed in to change notification settings - Fork 812
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
Improve ttfautohint hinting #371
Comments
Hmm.. could it be the “use typographic metrics” flag? |
Wow you're fast! Thank you very much for responding. If I can add the flag using, say, font forge, I would be so grateful! Especially if someone pointed me at some directions how. |
Forgive me if I say that the NerdFonts patcher is something like taking a sledgehammer to a nail. It does the job but does so without consideration for preserving the integrity of the original font. At least, that was my experience in looking at the resultant font file last year. OK, so looking at the version you provided versus our latest version, I see some modifications that could result in spacing changes. For example, modification of the xMax and yMax values in the head table and an increase in ascender in the hhea table, but the changes that you're talking about seem to be inconsistent across OTF and TTF, and generally with glyphs appearing bigger than they should. Is that accurate? That would lead me to think that the hinting may be responsible. If the hinting is different between the two fonts (and I'm not sure if Nerd Fonts is changing anything on that front), then x-heights can change, and glyphs may appear bigger. Unfortunately, it isn't anything we can help you with because, as I said, it has a lot to do with how the patcher works. I'm hoping to release a (mostly) complete NF version here at some point which would solve the issue for you, but that's still in the works. |
Something else to keep in mind. Once we started shipping the variable font, we no longer manually hinted the static instances. So there would be a change in the rendering between the pre-variable static version of Cascadia and the post-variable static version. If you’re comparing with the older version then that might be a root cause too. |
@aaronbell, I totally agree with you on your point, but I have to check if something could be done. My faith stems from several the fact that the 2005 version worked - so it didn't get as "destroyed". Also Word doesn't seem to see the difference and I was hoping it would be something small.
Yes and the OTF appears even more distorted (look for the small letter "i" - the stem nearly touches the dot). Try alt-tabbing between the 2008 OTF version and the 2005 version and it becomes obvious.
That came to my mind as well. That is why I installed the static TTF regular version to see how that looks and it didn't look distorted. So my very humble request is this - if this is something that is fixable or things I could try, I'd be very grateful to be pointed in that direction as I know next to nothing about fonts. So, is there something like this? |
Yikes, that is definitely a significant change. TBH, I'm not even sure where to point you to get started. I'll give it a think. Could you do me a favor and package up the pre-modded, and modded versions for the 2005 / 2008 fonts that you're using? Thanks! |
The change is totally in the "what the..." range. Thank you so much for looking into this! This is everything that I've tried - CascadiaCode.zip. Only the 2005 patched version looks like the original font. 2008 and 2009 look practically the same. Also, the 2005 was the last variable width font that patched normally. 2008 and 2009 variable width fonts crash the patcher. 2008 I tried both TTF and OTF and the OTF looks worse. I'd be happy to help further! |
The command I use is this, but I've tried all the parameters and nothing, including --careful and --preserve-line-height (or something simalar sounding):
|
OK, I've had a chance to take a look through these and to be honest, I don't see any differences between the NerdFont version and the official version that would be responsible for the differences that you're observing (I do see other significant changes between the two fonts, but they wouldn't result in the x-height modification). As I read through your concerns, though, something became more clear. The 2005 version was the last version of the TTF that worked OK. That was also the last release before we switched to the variable font version, which means it was the last version to have manual hints. The 2008 and 2009 releases were variable font releases and contain manual hints. Static instances were then provided as a 'backup' option for users for whom the variable fonts don't work, and therefore are just autohinted with ttfautohint. I believe that the reason why the fonts look different than the 2005 version is because ttfautohint is choosing to set the hints differently than my manual hints (used in 2005, and on the variable font versions of 2008 / 2009). In running ttfautohint, I didn't do any manual adjustment to how it interprets the font—modifying this would likely cause improved results, but given they're provided purely as backup, improving ttfautohint is a low priority. On the plus side, if you want to do so (and figure out some good settings for us to use), the documentation is pretty extensive. As for the OTFs, these are all autohinted with psautohint and have had the same settings throughout. OTFs on Windows tend to be a mixed bag and TBH I'm not as knowledgeable about the rasterizer interprets (or ignores) included ps hints. So can't comment on that. |
Again, I appreciate you looking into it! I wonder why my test with installing the actual backup TTF didn't show distortions. Probably I didn't test it right. But if you are correct, the static TTF, if installed, will show the same distorted result, right? So you are saying that I need to play with ttfautohint's settings and produce static fonts that look better, right? If so, I would appreciate a head start, maybe the settings you used? Maybe some hints? I am unsure if my knowledge will suffice for a useful test, but I am always willing to try stuff :) |
Yes, the static instances that we provide should show the same effects on your device as the modified version. If you want to try that, I'd suggest uninstalling all of the versions, and installing one of the PL ones (to avoid overlap with one of the Windows Terminal fonts). I used the standard setting with pretty much no modifications. Here's the current way we call it: Looking at the documentation, I see something related to x-height which might do it. |
Thank you, sound like fun! Should I use the variable width font for base or the current TTF one and change its hints? |
I'd suggest using one of the 2009 static TTF fonts. Thanks! |
I'll write back when I have something. Thank you again! |
Currently I can confirm that thet shipped 2009.22 static version appear simalarly distorted in height, so I will proceed with f@#kng around with ttfautohint and report back with successful settings (I hope) :-). |
So @aaronbell , this is what I've found so far: You definitely want You can also see how:
The Now the difference comes when you select a reference font. This is 2005.15 as reference. It is very different from the others - the capital letters and numbers are fine, but the small letters are all over the place: This is 2007.01 as a reference. It looks the same as no reference. The same result is produced with 2008 and 2009 as a reference. I used the TTF variable-width fonts, but it doesn't seem to make a difference. Also, there is a slight difference when using Anyway, I am out of ideas for now. The only way out I see is to have a reference font that corrects the capital letters. The ttfautohint docs seems to say the same thing. What do you think? Does that help? Why does using 2005 and 2007 as a reference produce different results? |
@BladeMF Thank you so much for taking the time to investigate this! And I'm sorry that it has taken me so long to follow up on this 😢. From my understanding, the purpose of the reference font is to help ensure that different fonts within the same family behave in a similar way—so it is really important for the Bold to use the Regular as a reference font. I'm reminded that I think there was a change to the font metrics between version 2005 and 2007, so that might be why 2005 produces different results than 2007 and later. So if we can't rely on the reference font to be able to change the results, what settings do you recommend to achieve the best rendering? It sounds like |
Hey @aaronbell , I am totally out of it now :-) The only thing we have to hope is that I documented my research well. It would seem that we want |
Oh dear. Sorry it took me so long! I'll put that into the code and will hope for the best :x. |
This is a significant update to Cascadia Code including a large number of bug fixes as well as updating the font to offer support for Fira Code v5 ligature support. This update supersedes PR #373. Closes #262 - ⏎ added Closes #264 - additional codepoints for control characters added Closes #281 - `!:` and `!.` added Closes #290 - `/\` and `\/` added Closes #301 - `??=` added Closes #324 - ℞ added Closes #327 - `<:>` and other variants implemented via the `calt` refactoring Closes #359 - house added Closes #371 - Added x-height instruction into ttfautohint to control the height of the lowercase. Closes #375 - Completely redesigned quote marks for better recognition Closes #377 - updated hinting to achieve more consistent results Closes #381 - increased height of thetamod Closes #382 - reduced the width of the hooklefts Closes #383 - updated heights on esh, glottalstop, glottalstopreversed Closes #384 - tweaked hinting a little bit. Maybe it'll help :) Closes #386 - added remaining soft-dotting Closes #392 - changed designs of angled quotes (they are now round) Closes #394 - changed former `~=` symbol to a simpler component-based version. Should be less confusing now for Lua / Matlab users. Closes #395 - makes the underline thicker based on font weight Closes #400 - increased size of degree Closes #219 The full control pictures block has been added (u+2400 to u+2426). For purposes of rendering, the two letter abbreviations have been used instead of the standard three letter abbreviations: Additionally, ss20 includes the oft-unused graphical representations of these codepoints (for fun!): Closes #276 (infinite arrows) Full support for Fira Code's current ligature set (with a few exceptions). Now featuring infinite arrows!!! This involved a full refactoring of the `calt` feature—for those interested, it now uses forward-looking substitutions instead of backward-looking substitutions and progressive substitution to reduce code. This also required some redesigning of the greater / lesser related ligatures. Please note, I have also removed all the obsolete ligatures now covered by the arrows code. Closes #329 There was a mismatch in the font's postscript naming conventions that was corrected. Should now render all weights in Word. **Note** there is apparently an additional bug in Mac Word's implementation of variable fonts which should be available in an update mid-Feb. * Not listed – Reworked the hints for the mod and superscript glyphs so that they're bottom-up rather than top-down. This allows for better bottom alignments. Aside from the above changes, this version also includes many other small updates including spacing, outline quality improvements, and fixing hinting.
Ah, that's unfortunate. I'll reopen this as it appears not to be resolved. However, customizing ttfautohint is not something I know, nor is it a priority for me at this time, so I can't promise a fix anytime soon. Please let me know if you or someone you know would be able to assist :). |
Thanks @aaronbell, for reopening the issue.
I am sad to say I know next to nothing about fonts. I was struggling to get the patching to work in the first place (I was trying to patch the variable ttf which isn't supported). I'll just keep my fingers crossed and hope someone else out there knows how to help :) |
I stumbled about this issue in microsoft/terminal#14891 and started to investigate.
Here are detail views of the changes, at 400% (no interpolation). The sequence starts and stops with the variable font. without hinting
with ttfoutohintwith TTH
From this I must say that the ttfautohint is the worst in my opinion, even no hinting is better. I will try to fine tune ttfautohint a bit. |
Here the same steps as before but with font size 15, which seems the worst Detail views of the changes, at 400% (no interpolation). The sequence starts and stops with the variable font. without hintingwith ttfautohintwith TTH |
Here we can compare the hints from This is opened in fontforge's "hinting simulator". It's a bit hard to see: Black outline is the actual outline in the font. Green outline is the outline after appying the instructions (hints). The squares are a renderer simulation. You see that the hints in the VF version make the green outline actually smaller, while the hints in the static versions make the outline quite taller. Now that I have found a method to see this on Linux I can ditch the Windows and Mac machines and see if we can beat Edit: Hmm, the variable font hints also pull the dot a bit down (there is a green outline slightly lower), so that we get one very light grey pixel in the dot's bottom 🤔 |
@Finii I’ve got a separate question for you to discuss off-thread. Could I reach you via email? |
@aaronbell Sure; my address is in every commit message, for example here (Signed-off-by). Update on work done regarding the hinting: Tried a lot settings with |
@Finii Great! Will do. The one thing is that the static fonts don't have overlaps preserved, whereas the VF does. So the hinting data is a bit different. That said, the CVTs are definitely there, and could be used however you'd like :) |
Here is the variable font opened in The gamma looks differnt for each, but otherwise consistent. Note that FF gets confused by the overlapping outlines, it seems, making the marked pickel darker in the preview. On Linux it is also rendered like this This at least shows that it is consistent across different OS. And even the statics' x-height jumps up one pixel on Linux, where I would have sworn that it does not happen. I never noticed that. Okay, now opening the release version of the static font in VTT, dropping program on opening: x-height is 1 px too tall. Then I just do a And it looks ok. x-height as the VF, hinting not as advanced, but still... Conclusion: I would drop Well, than I have seen that the release workflow seems to run Disclaimer: I checked just one glyph with one resolution... But it does look promising Edit:
Ok, using VTT does not customize ttfautohint. If ttfautohint is a must I will have a look into its source code the next days. I must admit I did not find any knob to turn there either. Maybe we are out of luck with ttfouthint. |
Thank you for your investigations into this! The main reason why I was using ttfautohint is because it can autohint from a script / command line. AFAIK, VTT's autohinter has to be run from the application, which thus requires a manual step in the release process. As the static versions are (in my mind) secondary to the variable version, I wanted to simplify the hinting process on them. But maybe it is worth just biting the bullet and running the autohinter on each static instance, storing the autohint code in the repro, and applying it to each static after generation. Should anything break we can re-run the autohinter manually to update the source as necessary. Either that, or convince MSFT to put the autohinter up along with the compiler... Bit of bloat for the build system, but not overly complicated. |
I did look a bit deeper into That leaves normal (manual) hinting. Just for experiments I ended up with these control instructions:
Example command lines:
The goal was to have a font where the string
At that point I stopped that approach. There is something going on that I do not understand. Hmm, I did not reboot, but used new Family Names for each test, so that should not be a problem. So apart from patching the Regarding VTT, I guess one can use it in the workflow, one could just send the needed keypresses to the GUI application and it will do what is needed. I can try to set that up if interested. I actually did not check if VTT can be operated just on keypresses, but I guess. |
So, how about keeping the overlaps in the static fonts? After reading the code, it seems to be just a few boolean changes. That way, we can reuse the hints, and don't have to deal with ttf/psautohint. What's your opinion? |
@longnguyen2004 Many applications assume that static fonts do not have overlaps, so preserving them, while it enables us to re-use the hints, can cause a multitude of rendering issues. As the static instances are being provided as "backup" for scenarios where the variable font is not viable, it doesn't make sense to introduce a different potential issue for the sake of hinting, IMO. |
[why] A lot people (read: People on Windows) have the variable font (VF) version of Cascadia Code installed - it comes bundled with Windows Terminal. The static Cascadia Code instances that we use for patching are hinted with ttfautohint which creates small sized glyphs that are visibly very different. People compare the static Caskaydia Cove with the VF Cascadia Code and are surprised. [how] First switch from the CFF outlines to TTF outlines - that is the original version (i.e. otf -> ttf). It is unknown why we created patched CFF fonts instead of the TTFs. To get as close as possible to the intended look of the glyphs we should stick with the outline type. Then we need to re-hint all the fonts, to get hints that are comparable to the VF hints. We can not use the hints of the VF because the outlines are different: The VF has (of course) overlapping outlines, while the static ones (as usual) have not. The re-hinting can be done with VTT or TTH - both showed results that are more like the original VF font. The usual ttfautohint has been used of the static fonts in the font release and can not be used. It is the reason for this whole problem. * Used VTT 6.35 * Open font file in VTT * Import all programs * Generate 'VTT talk' via Tools -> AutoHint -> LightLatinAutoHint * Save font file as ... References: microsoft/cascadia-code#371 https://learn.microsoft.com/en-us/typography/tools/vtt/ Closes: #998 Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
CascadiaCode: Rehint and use ttf [why] A lot people (read: People on Windows) have the variable font (VF) version of Cascadia Mono installed - it comes bundled with Windows Terminal. The static Cascadia Mono instances that Microsoft releases are hinted with ttfautohint which creates small sized glyphs that are visibly very different. People compare the static Caskaydia Mono with the VF Cascadia Mono and are surprised. [how] We need to re-hint all the fonts, to get hints that are comparable to the VF hints. We can not use the hints of the VF because the outlines are different: The VF has (of course) overlapping outlines, while the static ones (as usual) have not. The re-hinting can be done with VTT or TTH - both showed results that are more like the original VF font. The usual ttfautohint has been used of the static fonts in the font release and can not be used. It is the reason for this whole problem. * Used VTT 6.35 * Open font file in VTT * Import all programs * Generate 'VTT talk' via Tools -> AutoHint -> LightLatinAutoHint * Save font file as ... References: microsoft/cascadia-code#371 https://learn.microsoft.com/en-us/typography/tools/vtt/ See also commit b6301e5 CascadiaCode: Rehint and use ttf Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
CascadiaCode: Rehint and use ttf [why] A lot people (read: People on Windows) have the variable font (VF) version of Cascadia Mono installed - it comes bundled with Windows Terminal. The static Cascadia Mono instances that Microsoft releases are hinted with ttfautohint which creates small sized glyphs that are visibly very different. People compare the static Caskaydia Mono with the VF Cascadia Mono and are surprised. [how] We need to re-hint all the fonts, to get hints that are comparable to the VF hints. We can not use the hints of the VF because the outlines are different: The VF has (of course) overlapping outlines, while the static ones (as usual) have not. The re-hinting can be done with VTT or TTH - both showed results that are more like the original VF font. The usual ttfautohint has been used of the static fonts in the font release and can not be used. It is the reason for this whole problem. * Used VTT 6.35 * Open font file in VTT * Import all programs * Generate 'VTT talk' via Tools -> AutoHint -> LightLatinAutoHint * Save font file as ... References: microsoft/cascadia-code#371 https://learn.microsoft.com/en-us/typography/tools/vtt/ See also commit b6301e5 CascadiaCode: Rehint and use ttf Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
CascadiaCode: Rehint and use ttf [why] A lot people (read: People on Windows) have the variable font (VF) version of Cascadia Mono installed - it comes bundled with Windows Terminal. The static Cascadia Mono instances that Microsoft releases are hinted with ttfautohint which creates small sized glyphs that are visibly very different. People compare the static Caskaydia Mono with the VF Cascadia Mono and are surprised. [how] We need to re-hint all the fonts, to get hints that are comparable to the VF hints. We can not use the hints of the VF because the outlines are different: The VF has (of course) overlapping outlines, while the static ones (as usual) have not. The re-hinting can be done with VTT or TTH - both showed results that are more like the original VF font. The usual ttfautohint has been used of the static fonts in the font release and can not be used. It is the reason for this whole problem. * Used VTT 6.35 * Open font file in VTT * Import all programs * Generate 'VTT talk' via Tools -> AutoHint -> LightLatinAutoHint * Save font file as ... References: microsoft/cascadia-code#371 https://learn.microsoft.com/en-us/typography/tools/vtt/ See also commit b6301e5 CascadiaCode: Rehint and use ttf Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Considering Adobe's impactful contributions to FreeType, and VTT being older than I am, I don't see that being impossible. In microsoft/VisualTrueType#30 (comment), @paullinnerud said:
Plus, from what I gather, it is the GUI widget source that has non-Microsoft licensed copyrighted code, not the autohinter. It then becomes a task of convincing someone to strip the GUI code and open source the rest of the library component. No clue how VTT code itself is versioned internally but nowadays converting to Git and using git blame seems straightforward enough. Unless, of course, the autohinter is tied to one or more particular renderer implementations. Then... who knows. Maybe gatekeeping it to Windows and replacing renderer calls with system calls to GDI, GDI+ and/or DirectWrite. @PeterCon, @robmck-ms - apologies for the ping - would you know who could clarify? @mikedug, perhaps? Microsoft Visual TrueType has today the only reliable variable font autohinter. It would have tremendous impact. (Second only to a DirectWrite autofitter and a Microsoft FreeType autofitter. I have a dream.) |
...
...
... No authoritative knowledge on this - MS folks please feel free to correct me - (1) the rasterizer was licensed from Apple in the 80's (almost 40 years ago) then heavily modified separately and went different directions by both Apple and Microsoft, (2) git itself is only about 20 years old... vtt is likely older than git, (3) the autohinter is indeed to some extent tied to particular renderer implementation. The only/most interesting item is, of course, (3) . To what extent, and how important that might be, I have no idea. I don't think the licensing of the GUI widget source is an issue; the practical usefulness of opening that part perhaps is, since GUI is necessarily windows only, and of no practical use on other platforms, except as inspiration / reference. |
Thanks for the input, Hin-Tak. Just to clear up some miscommunications on my part. The rasterizer in the first case was referring to the rendering mode In the second case, other uses of other rasterizers unbeknownst to us may On Git, the suggestion is that whatever version control software it may be The overall theme is to comment that it is possible to locate encumbrances On patents, which was discussed on the quoted VTT issue, specifically in The only encumbrance related to intellectual property here would be if the |
It is not about patents. The rasterizer was from Apple, and licensed to Microsoft, then heavily modified afterwards for 4 decades in GDI and DirectWrite. While Apple took the same code base in a different direction in their CoreText. I think it is highly unlikely that the original license agreement allows MS to open it up to 3rd party; and it is also highly unlikely that MS would go to the trouble of renegotiate that license to allow such opening. Back to the 3rd point: autohinting of course depends, to some extent, the precise hinting behavior of the rasterizer(s). Auto-hinting "merely" inserts auto-generated hinting instructions (as opposed to "human-expert-edited/tuned" hinting instructions) to a font, and how they are processed, or ignored, is quite specific to the rasterizer(s). And to that end, despite sharing a distant ancestry from 40 years ago, font hinting on windows is quite different from font hinting on mac os now. |
I know it's not your job, but please can you guys help me identify what is missing in the patched NerdFonts since 2008 onwards so that the height changes so significantly - ryanoasis/nerd-fonts#519?
I really like to use the new versions and I really like oh-my-zsh, but I am stuck at the 2005 version.
I'm attaching patched fonts from the latest version (where the result is the same). static.zip
Edit: added version
Windows Terminal Preview
Version: 1.4.2652.0
The text was updated successfully, but these errors were encountered: