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

Fix broken ligature glyphs in monospaced font #12

Merged
merged 2 commits into from
Oct 23, 2019

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Oct 23, 2019

[why]
For some reason reading a font into fontforge looses data on glyphs. As
a workaround their font-patcher script has the switch --mono to
ascertain an equal width of all glyphs. We want to (and need to) use
that mode of the script to get a new font that is detected as monospaced
by Windows.

Sometimes that workaround fails. For example it breaks ligature glyphs
in some circumstances; they seem to be moved sideways.

[how]
The workaround is done in two steps: First each glyph is checked for
negative bearings. If these are found they are set to fixed zero.
Afterwards the glyph width is set to the font global width.

The ligature glyphs have already the correct width, they just have
negative bearings that they indeed need. There is no reason to change
the (correct) bearings to get a monospaced font. In strict monospaced
fonts that would be impossible, but the ligatures are only used in
applications that could work with negative bearings and so they should
be there. Strict monospaced usage does ignore the bearings anyhow.

So what is needed is a change in the font-patcher script. This can be
done in two ways:

  • patch the font-patcher script
  • do not use font-patcher's --mono and instead implement it as
    part of our rename script or additional script

Of course the best solution would be to fix upstream font-patcher. But
that might take some time. Meanwhile we can patch the font-patcher as it
is rather stable (no recent commits) and our patch will most likely not
fail in the near future.

Forking font-patcher is not desirable I think.

[note]
There is some work in progress regarding Cascadia Code in Nerd Font's
repository, but that seems slow ;) Project too big.

Fixes: #3
Signed-off-by: Fini Jastrow ulf.fini.jastrow@desy.de

[why]
For some reason reading a font into fontforge looses data on glyphs. As
a workaround their `font-patcher` script has the switch `--mono` to
ascertain an equal width of all glyphs. We want to (and need to) use
that mode of the script to get a new font that is detected as monospaced
by Windows.

Sometimes that workaround fails. For example it breaks ligature glyphs
in some circumstances; they seem to be moved sideways.

[how]
The workaround is done in two steps: First each glyph is checked for
negative bearings. If these are found they are set to fixed zero.
Afterwards the glyph width is set to the font global width.

The ligature glyphs have already the correct width, they just have
negative bearings that they indeed need. There is no reason to change
the (correct) bearings to get a monospaced font. In strict monospaced
fonts that would be impossible, but the ligatures are only used in
applications that could work with negative bearings and so they should
be there. Strict monospaced usage does ignore the bearings anyhow.

So what is needed is a change in the font-patcher script. This can be
done in two ways:
 - patch the font-patcher script
 - do not use font-patcher's `--mono` and instead implement it as
   part of our rename script or additional script

Of course the best solution would be to fix upstream font-patcher. But
that might take some time. Meanwhile we can patch the font-patcher as it
is rather stable (no recent commits) and our patch will most likely not
fail in the near future.

Forking font-patcher is not desirable I think.

[note]
There is some work in progress regarding Cascadia Code in Nerd Font's
repository, but that seems slow ;) Project too big.

Fixes: 3
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator Author

Finii commented Oct 23, 2019

Hmm, this introduces a regression of Bug #5, albeit not as severe. Working...

[why]
Some glyphs are just used as overlays for 'real' glyphs. These are for
example U+0300 .. U+036F (the 'COMBINING ...' diactritics) like
  U+0300, gravecomb, COMBINING GRAVE ACCENT
  U+0301, acutecomb, COMBINING ACUTE ACCENT
  U+0308, uni0308, COMBINING DIAERESIS

They are never used on their own, at least they are overlayed over a
blanc (U+0020, space).

For the font rendering engine they need to have the correct negative
bearings, so they are shifted to take no space by themselves.

The font-patcher script does not allow negative bearings in monospaced
fonts. This makes sense if every glyph is in itself a 'letter' that
should not reach beyond it's allotted (monospaced) space. But well,
this is not how Cascadia Code is assembled.

[how]
In the font-patcher script we do not touch the bearings of such overlay
glyphs. They can be identified by their width of zero.

For Windows to detect this font as 'monospaced' we need to change the
width to the standard width, though.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@clairernovotny
Copy link

Thanks for diving into this @Finii! Can you please post an issue/PR to font-patcher with your fixes as well? They may not take it for a while but it could help others with a similar issue.

@adam7 adam7 merged commit 9572aa2 into adam7:master Oct 23, 2019
@Finii
Copy link
Collaborator Author

Finii commented Oct 24, 2019

Can you please post an issue/PR to font-patcher with your fixes as well? They may not take it for a while but it could help others with a similar issue.

✔️ ryanoasis/nerd-fonts#394

@Finii Finii deleted the bugfix/ligatures_in_mono branch February 13, 2020 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not showing as fixed-width font
3 participants