-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,716 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Generate features for ligatures | ||
# | ||
# Adapted from https://github.com/tonsky/FiraCode/blob/master/gen_calt.clj | ||
|
||
from textwrap import dedent | ||
import tempfile | ||
|
||
|
||
def update_features(font): | ||
"""Find ligatures in the font and generate features for them.""" | ||
# [ ["dash" "greater" "greater"] ... ] | ||
ligas = [name[:-len('.liga')].split('_') | ||
for name in font if name.endswith('.liga') and | ||
font[name].isWorthOutputting()] | ||
|
||
rules = '\n\n'.join(rule(liga) | ||
for liga in sorted(ligas, key=lambda l: -len(l))) | ||
|
||
fea_code = dedent('''\ | ||
languagesystem DFLT dflt; | ||
languagesystem latn dflt; | ||
languagesystem grek dflt; | ||
languagesystem cyrl dflt; | ||
feature calt {{ | ||
{} | ||
}} calt; | ||
''').format(indent(rules, ' ')) | ||
|
||
print(fea_code) | ||
|
||
# Add the dummy "LIG" glyph | ||
lig = font.createChar(-1, 'LIG') | ||
lig.width = font['space'].width | ||
with tempfile.NamedTemporaryFile(suffix='.fea') as f: | ||
f.write(fea_code) | ||
f.seek(0) | ||
font.mergeFeature(f.name) | ||
|
||
|
||
def rule(liga): | ||
""" | ||
[f f i] => { [LIG LIG i] f_f_i.liga | ||
[LIG f i] LIG | ||
[ f f i] LIG } | ||
""" | ||
if len(liga) == 2: | ||
return dedent('''\ | ||
lookup {0}_{1} {{ | ||
ignore sub {0} {0}' {1}; | ||
ignore sub {0}' {1} {1}; | ||
sub {0}' {1} by LIG; | ||
sub LIG {1}' by {0}_{1}.liga; | ||
}} {0}_{1}; | ||
''').format(*liga) | ||
elif len(liga) == 3: | ||
return dedent('''\ | ||
lookup {0}_{1}_{2} {{ | ||
ignore sub {0} {0}' {1} {2}; | ||
ignore sub {0}' {1} {2} {2}; | ||
sub {0}' {1} {2} by LIG; | ||
sub LIG {1}' {2} by LIG; | ||
sub LIG LIG {2}' by {0}_{1}_{2}.liga; | ||
}} {0}_{1}_{2}; | ||
''').format(*liga) | ||
elif len(liga) == 4: | ||
return dedent('''\ | ||
lookup {0}_{1}_{2}_{3} {{ | ||
ignore sub {0} {0}' {1} {2} {3}; | ||
ignore sub {0}' {1} {2} {3} {3}; | ||
sub {0}' {1} {2} {3} by LIG; | ||
sub LIG {1}' {2} {3} by LIG; | ||
sub LIG LIG {2}' {3} by LIG; | ||
sub LIG LIG LIG {3}' by {0}_{1}_{2}_{3}.liga; | ||
}} {0}_{1}_{2}_{3}; | ||
''').format(*liga) | ||
|
||
|
||
def indent(text, prefix): | ||
return '\n'.join(prefix + line for line in text.split('\n')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ if [ "x$error" != "x0" ]; then | |
fi | ||
fi | ||
|
||
exit 0 | ||
exit $error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Sources/FantasqueSansMono-Regular.sfdir/bar_bar_bar_greater.liga.glyph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
StartChar: bar_bar_bar_greater.liga | ||
Encoding: 57396 57396 1025 | ||
Width: 1060 | ||
VWidth: 4 | ||
Flags: HW | ||
LayerCount: 2 | ||
Fore | ||
SplineSet | ||
-2466 1000 m 2 | ||
-2466 1093 l 1 | ||
-2306 1093 l 1 | ||
-2306 948 l 2 | ||
-2306 831 -2298 504.484375 -2298 369 c 2 | ||
-2298 219 l 2 | ||
-2298 104 -2299 48 -2304 -53 c 1 | ||
-2465 -52 l 1 | ||
-2461 10 -2460 53 -2460 108 c 0 | ||
-2460 394.356445312 -2466 673.005859375 -2466 1000 c 2 | ||
-680 1000 m 2 | ||
-680 1093 l 1 | ||
-520 1093 l 1 | ||
-520 948 l 2 | ||
-520 831 -512 504.484375 -512 369 c 2 | ||
-512 219 l 2 | ||
-512 104 -513 48 -518 -53 c 1 | ||
-679 -52 l 1 | ||
-675 10 -674 53 -674 108 c 0 | ||
-674 394.356445312 -680 673.005859375 -680 1000 c 2 | ||
-1574.01074219 1000 m 2 | ||
-1574.01074219 1093 l 1 | ||
-1414.01074219 1093 l 1 | ||
-1414.01074219 948 l 2 | ||
-1414.01074219 831 -1406.01074219 504.484375 -1406.01074219 369 c 2 | ||
-1406.01074219 219 l 2 | ||
-1406.01074219 104 -1407.01074219 48 -1412.01074219 -53 c 1 | ||
-1573.01074219 -52 l 1 | ||
-1569.01074219 10 -1568.01074219 53 -1568.01074219 108 c 0 | ||
-1568.01074219 394.356445312 -1574.01074219 673.004882812 -1574.01074219 1000 c 2 | ||
318 590 m 1 | ||
318 473 l 1 | ||
222 404 -343 38 -518 -53 c 1 | ||
-548.740234375 -16.2578125 -562.995117188 40.068359375 -586 86 c 1 | ||
-415 194 -24 417 133 525 c 1 | ||
7 615 -401.563476562 827.749023438 -533.944335938 909.646484375 c 0 | ||
-565.27734375 928.940429688 -590.541992188 943.31640625 -614.99609375 969.065429688 c 1 | ||
-519 1092 l 1 | ||
-390.591796875 988.930664062 231 657 318 590 c 1 | ||
EndSplineSet | ||
EndChar |
39 changes: 39 additions & 0 deletions
39
Sources/FantasqueSansMono-Regular.sfdir/bar_bar_greater.liga.glyph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
StartChar: bar_bar_greater.liga | ||
Encoding: 57395 57395 1024 | ||
Width: 1060 | ||
VWidth: 4 | ||
Flags: HW | ||
LayerCount: 2 | ||
Fore | ||
SplineSet | ||
-1569 1000 m 2 | ||
-1569 1093 l 1 | ||
-1409 1093 l 1 | ||
-1409 948 l 2 | ||
-1409 831 -1401 504.484375 -1401 369 c 2 | ||
-1401 219 l 2 | ||
-1401 104 -1402 48 -1407 -53 c 1 | ||
-1568 -52 l 1 | ||
-1564 10 -1563 53 -1563 108 c 0 | ||
-1563 394.356445312 -1569 673 -1569 1000 c 2 | ||
-678 1000 m 2 | ||
-678 1093 l 1 | ||
-518 1093 l 1 | ||
-518 948 l 2 | ||
-518 831 -510 504.484375 -510 369 c 2 | ||
-510 219 l 2 | ||
-510 104 -511 48 -516 -53 c 1 | ||
-677 -52 l 1 | ||
-673 10 -672 53 -672 108 c 0 | ||
-672 394.356445312 -678 673.005859375 -678 1000 c 2 | ||
319 591 m 1 | ||
319 474 l 1 | ||
223 405 -342 39 -517 -52 c 1 | ||
-547.740234375 -15.2578125 -561.995117188 41.068359375 -585 87 c 1 | ||
-414 195 -23 418 134 526 c 1 | ||
8 616 -400.563476562 828.749023438 -532.944335938 910.646484375 c 0 | ||
-564.27734375 929.940429688 -589.541992188 944.31640625 -613.99609375 970.065429688 c 1 | ||
-518 1093 l 1 | ||
-389.591796875 989.930664062 232 658 319 591 c 1 | ||
EndSplineSet | ||
EndChar |
29 changes: 29 additions & 0 deletions
29
Sources/FantasqueSansMono-Regular.sfdir/bar_greater.liga.glyph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
StartChar: bar_greater.liga | ||
Encoding: 57394 57394 1023 | ||
Width: 1060 | ||
VWidth: 4 | ||
Flags: HW | ||
LayerCount: 2 | ||
Fore | ||
SplineSet | ||
-391 1000 m 6 | ||
-391 1093 l 5 | ||
-231 1093 l 5 | ||
-231 948 l 6 | ||
-231 831 -223 504.484375 -223 369 c 6 | ||
-223 219 l 6 | ||
-223 104 -224 48 -229 -53 c 5 | ||
-390 -52 l 5 | ||
-386 10 -385 53 -385 108 c 4 | ||
-385 394.356445312 -391 673.005859375 -391 1000 c 6 | ||
606 591 m 5 | ||
606 474 l 5 | ||
510 405 -55 39 -230 -52 c 5 | ||
-260.740234375 -15.2578125 -274.995117188 41.068359375 -298 87 c 5 | ||
-127 195 264 418 421 526 c 5 | ||
295 616 -113.563476562 828.749023438 -245.944335938 910.646484375 c 4 | ||
-277.27734375 929.940429688 -302.541992188 944.31640625 -326.99609375 970.065429688 c 5 | ||
-231 1093 l 5 | ||
-102.591796875 989.930664062 519 658 606 591 c 5 | ||
EndSplineSet | ||
EndChar |
Oops, something went wrong.