Skip to content
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

font-patcher: Allow to rehint some Cascadia glyphs #1613

Merged
merged 7 commits into from
Apr 22, 2024

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Apr 18, 2024

[why]
Some Caskaydia Cove glyphs that are used in ligatures (to create endless arrows for example) show uneven line thickness on some platforms.

The reason is the not-matching hinting of glyphs that are places next to each other and so minuscule differences are quite visible.

Note that the 'original' hinting is generated by VTT on the static Cascadia Code instances, which upstream just have ttfautohint hints that are different from the hints in the variable fonts and people complained that the look is different.

[how]
Add a new field to the config.json file that holds regexes of glyph names for glyphs that should be re-hinted by fontforge on patching time.

In principle we could also implement that as an additional pre-step that needs to be manually done after running VTT on the static font files.

I'm not sure which is better.

Note that fontforge generates a lot of debug output because the hinting is not ideal - the global tables are kept and probably less compatible to fontforge's own hinting... But the results are good.

Fixes: #1291
Fixes: #1609

Requirements / Checklist

  • Read the Contributing Guidelines
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan.
    Issue number where discussion took place: #xxx
  • If this contains a font/glyph add its origin as background info below (e.g. URL)
  • Verified the license of any newly added font, glyph, or glyph set. License is: xxx

What does this Pull Request (PR) do?

How should this be manually tested?

Any background context you can provide?

What are the relevant tickets (if any)?

Screenshots (if appropriate or helpful)

@Finii Finii added the Bug fix label Apr 18, 2024
@Finii
Copy link
Collaborator Author

Finii commented Apr 18, 2024

WHY are the config files called config.json and not config.toml?

Just curious 😒

Renaming them needs a gotta-patch-em change.

Edit: Answer: They are INI files with JSON values

[why]
At the moment we have two different config files:

config.cfg:
Is read by gotta-patch-em and allows to specify some needed
commandline options for a font-patcher run

config.json:
Is read by font-patcher and can contain ligature table removal
instructions

It would be nice to combine/unify them.

[how]
Add the possibility to add commandline options in the config.cfg
file. Of course we need commandline options to specify the config
file first, so the options are parsed in two steps.

The config.file takes precedence (if possible) over directly specified
options.

This is how the new section in the config file can look like:

[Config]
commandline: --powerlineextra --mono

Signed-off-by: Fini Jastrow <[email protected]>
@Finii Finii force-pushed the bugfix/Caskaydia-long-arrows branch from 0c6e419 to e48d920 Compare April 20, 2024 07:20
@Finii
Copy link
Collaborator Author

Finii commented Apr 20, 2024

image

[why]
The config files are called `config.json` while the contents is
INI-like. The usual extension would be `.cfg`.

[how]
We use `.cfg` already for the shell variable configuration.

Combine both config file variants into one (real) cfg file, that is
directly read by the font-patcher and no shell variables files are used
anymore.

This needs some rewrite in gotta-patch-em to get the quoting right.
To make this simpler we remove the `--debug 1` option from the variable
and insert it directly (as it is applied always anyhow).

Signed-off-by: Fini Jastrow <[email protected]>
[why]
Some Caskaydia Cove glyphs that are used in ligatures (to create endless
arrows for example) show uneven line thickness on some platforms.

The reason is the not-matching hinting of glyphs that are places next
to each other and so minuscule differences are quite visible.

Note that the 'original' hinting is generated by VTT on the static
Cascadia Code instances, which upstream just have ttfautohint hints that
are different from the hints in the variable fonts and people complained
that the look is different.

[how]
Add a new field to the config.cfg file that holds regexes of glyph
names for glyphs that should be re-hinted by fontforge on patching time.

In principle we could also implement that as an additional pre-step that
needs to be manually done after running VTT on the static font files.

I'm not sure which is better.

Note that fontforge generates a lot of debug output because the hinting
is not ideal - the global tables are kept and probably less compatible
to fontforge's own hinting... But the results are good.

Fixes: #1291
Fixes: #1609

Signed-off-by: Fini Jastrow <[email protected]>
[why]
We now have two places where we can detect if a config file is given.
This should be unified.

Also handling of missing (?) sections in the config file is not always
handled gracefully.

Signed-off-by: Fini Jastrow <[email protected]>
[why]
The logging to files does not work correctly for the messages given
while the options themselves are parsed.

[how]
As soon as we have enough information (after the first argument parsing)
we set the logger up. When processing the config file arguments we have
a full functioning logger now.

Signed-off-by: Fini Jastrow <[email protected]>
[why]
The previous change(s) removed executing the config.cfg **shell script**
which would pull in some environment variables like `post_process`.
With that change the appropriate option has to be given with the
commandline value of the new config.cfg **INI** file.

[how]
Remove defunct leftover code.

Signed-off-by: Fini Jastrow <[email protected]>
@Finii Finii force-pushed the bugfix/Caskaydia-long-arrows branch from 96a1e06 to cd80b9e Compare April 22, 2024 12:09
@Finii
Copy link
Collaborator Author

Finii commented Apr 22, 2024

Compared previous and current passed options via this change

index c2535a1dc..4c71ad6e7 100755
--- a/font-patcher
+++ b/font-patcher
@@ -2082,6 +2082,11 @@ def main():
         logger.info("Can not write logfile, disabling")
     logger.debug("Naming mode %d", args.makegroups)
 
+    qqq = list(vars(args))
+    qqq.sort()
+    print("|||", [[k,vars(args)[k]] for k in qqq])
+    sys.exit(0)
+
     patcher = font_patcher(args)
 
     sourceFonts = []

Run via gotta-patch-em on all fonts and logging into one file each before and after the PR.

After some sort and uniq -u and so on it could be seen that the delivered options were exactly the same (well, except that some had a configfile set that previously hadn't. These are the fonts which got the parameters before via shell script and now via INI.

@Finii Finii merged commit 6871fdd into master Apr 22, 2024
5 checks passed
@Finii Finii deleted the bugfix/Caskaydia-long-arrows branch April 22, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CaskaydiaCove Nerd Font -- "Arrow" Ligature Caskaydia Cove introduces ligature issue not in Cascadia Code
1 participant