various improves #313:

- support full width quote in CN
- make CN ligature fine-grain
- bring back `locl` in ZHH and ZHT
This commit is contained in:
subframe7536 2025-01-07 10:00:47 +08:00
parent bf581b06d2
commit 2e1b8e671b
6 changed files with 69 additions and 21 deletions

View file

@ -208,6 +208,8 @@ class FontConfig:
"cv34": "ignore",
"cv35": "ignore",
"cv36": "ignore",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",
@ -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):
@ -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,
@ -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"

View file

@ -15,6 +15,8 @@
"cv34": "ignore",
"cv35": "ignore",
"cv36": "ignore",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",

View file

@ -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)

View file

@ -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
@ -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 {

View file

@ -15,6 +15,8 @@
"cv34": "enable",
"cv35": "enable",
"cv36": "enable",
"cv96": "ignore",
"cv97": "ignore",
"cv98": "ignore",
"cv99": "ignore",
"ss01": "ignore",

View file

@ -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": {