-
Notifications
You must be signed in to change notification settings - Fork 12
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
6 changed files
with
56 additions
and
36 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
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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
"""Lilex font library""" | ||
from .build import FontFormat, build_family | ||
from .features import OpenTypeFeatures, generate_spacers, render_ligatures | ||
from .features import ( | ||
OpenTypeFeatures, | ||
force_features, | ||
generate_spacers, | ||
render_ligatures, | ||
) | ||
from .glyphs_font import GlyphsFont |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
"""OpenType features utils""" | ||
from .features_loader import OpenTypeFeatures | ||
from .ligatures import render_ligatures | ||
from .mappers import force_features | ||
from .name import feature_prefix, name_from_code | ||
from .spacers import generate_spacers | ||
from .tpl import NAME_TPL |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""OpenType feature mappers""" | ||
import sys | ||
|
||
from glyphsLib import GSFeature | ||
|
||
FeatureDict = dict[str, GSFeature] | ||
|
||
def to_feature_dict(features: list[GSFeature]) -> FeatureDict: | ||
return {fea.name: fea for fea in features} | ||
|
||
def from_feature_dict(feature_dict: FeatureDict) -> list[GSFeature]: | ||
return list(feature_dict.values()) | ||
|
||
def force_features(features: list[GSFeature], forced: list[str]): | ||
fea_dict = to_feature_dict(features) | ||
for fea in forced: | ||
if fea not in fea_dict: | ||
print(f"Unknown feature: '{fea}'") | ||
sys.exit(1) | ||
# Move the code of the feature to the calt, | ||
# which is executed in most cases | ||
fea_dict[fea].disabled = True | ||
fea_dict["calt"].code += "\n" + fea_dict[fea].code | ||
# Remove feature from aalt | ||
aalt = fea_dict["aalt"] | ||
aalt.code = aalt.code.replace(f"feature {fea};\n", "") | ||
return from_feature_dict(fea_dict) |