Skip to content

Commit

Permalink
various improves #313:
Browse files Browse the repository at this point in the history
- support full width quote in CN
- make CN ligature fine-grain
- bring back `locl` in ZHH and ZHT
  • Loading branch information
subframe7536 committed Jan 7, 2025
1 parent bf581b0 commit 2e1b8e6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 21 deletions.
34 changes: 20 additions & 14 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def __init__(self, args):
"cv34": "ignore",
"cv35": "ignore",
"cv36": "ignore",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",
Expand Down Expand Up @@ -537,21 +539,23 @@ def parse_style_name(style_name_compact: str, skip_subfamily_list: list[str]):
)


def fix_cv98(font: TTFont):
def fix_cn_cv(font: TTFont):
gsub_table = font["GSUB"].table
feature_list = gsub_table.FeatureList
config = {
"cv96": ["quoteleft", "quoteright", "quotedblleft", "quotedblright"],
"cv97": ["ellipsis"],
"cv98": ["emdash"],
}

for feature_record in feature_list.FeatureRecord:
if feature_record.FeatureTag != "cv98":
continue
sub_table = gsub_table.LookupList.Lookup[
feature_record.Feature.LookupListIndex[0]
].SubTable[0]
sub_table.mapping = {
"emdash": "emdash.cv98",
"ellipsis": "ellipsis.cv98",
}
break
for feature_record in gsub_table.FeatureList.FeatureRecord:
if feature_record.FeatureTag in config:
sub_table = gsub_table.LookupList.Lookup[
feature_record.Feature.LookupListIndex[0]
].SubTable[0]
sub_table.mapping = {
value: f"{value}.full"
for value in config[feature_record.FeatureTag]
}


def remove_locl(font: TTFont):
Expand Down Expand Up @@ -884,7 +888,8 @@ def build_cn(f: str, font_config: FontConfig, build_option: BuildOption):
cn_font["OS/2"].xAvgCharWidth = 600

# https://github.com/subframe7536/maple-font/issues/188
fix_cv98(cn_font)
# https://github.com/subframe7536/maple-font/issues/313
fix_cn_cv(cn_font)

handle_ligatures(
font=cn_font,
Expand Down Expand Up @@ -1075,6 +1080,7 @@ def main():
# =========================================================================================

if not font_config.ttf_only and build_option.should_build_cn(font_config):

def _build_cn():
print(
f"\n🔎 Build CN fonts {'with Nerd-Font' if font_config.should_cn_use_nerd_font() else ''}...\n"
Expand Down
2 changes: 2 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"cv34": "ignore",
"cv35": "ignore",
"cv36": "ignore",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",
Expand Down
4 changes: 3 additions & 1 deletion source/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ fixme))

#### CN Only

- cv98: Full width ``(ellipsis) and ``(emdash)
- cv96: Full width ``(double quote left), ``(double quote right), ``(single quote left), ``(single quote right)
- cv97: Full width ``(ellipsis)
- cv98: Full width ``(emdash)
- cv99: Traditional punctuations

### Style Sets (ssXX)
Expand Down
38 changes: 33 additions & 5 deletions source/features/cn.fea
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ lookup CN2TW {
sub uniFF1F by uniFF1F.tw;
} CN2TW;

lookup full_width_e {
sub emdash by emdash.cv98;
sub ellipsis by ellipsis.cv98;
} full_width_e;
lookup full_width_quote {
sub quoteleft by quoteleft.full;
sub quoteright by quoteright.full;
sub quotedblleft by quotedblleft.full;
sub quotedblright by quotedblright.full;
} full_width_quote;

lookup full_width_ellipsis {
sub ellipsis by ellipsis.full;
} full_width_ellipsis;

lookup full_width_emdash {
sub emdash by emdash.full;
} full_width_emdash;

feature ccmp {
# GSUB feature: Glyph Composition / Decomposition
Expand Down Expand Up @@ -48,8 +58,26 @@ feature ccmp {

} ccmp;

feature locl {
language ZHH; # Chinese, Traditional, Hong Kong SAR
lookup CN2TW;
language ZHT; # Chinese, Traditional
lookup CN2TW;
} locl;

# “” ‘’
feature cv96 {
lookup full_width_quote;
} cv96;

# ……
feature cv97 {
lookup full_width_ellipsis;
} cv97;

# ——
feature cv98 {
lookup full_width_e;
lookup full_width_emdash;
} cv98;

feature cv99 {
Expand Down
2 changes: 2 additions & 0 deletions source/preset-normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"cv34": "enable",
"cv35": "enable",
"cv36": "enable",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",
Expand Down
10 changes: 9 additions & 1 deletion source/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,16 @@
"description": "[Italic Only] Alternative 'x' (without top and bottom tails)",
"$ref": "#/definitions/freeze_options"
},
"cv96": {
"description": "[CN Only] Full width '“'(double quote left), '”'(double quote right), '‘'(single quote left), '’'(single quote right)",
"$ref": "#/definitions/freeze_options"
},
"cv97": {
"description": "[CN Only] Full width '…'(ellipsis)",
"$ref": "#/definitions/freeze_options"
},
"cv98": {
"description": "[CN Only] Full width '…'(ellipsis) and '—'(emdash)",
"description": "[CN Only] Full width '—'(emdash)",
"$ref": "#/definitions/freeze_options"
},
"cv99": {
Expand Down

0 comments on commit 2e1b8e6

Please sign in to comment.