MCPcopy
hub / github.com/subframe7536/maple-font / patch_font_feature

Method patch_font_feature

build.py:593–656  ·  view source on GitHub ↗
(
        self,
        font: TTFont,
        issue_fea_dir: str,
        is_italic: bool,
        is_cn: bool,
        is_variable: bool,
        is_hinted: bool,
        fea_path: str,
    )

Source from the content-addressed store, hash-verified

591 return [0, self.glyph_width]
592
593 def patch_font_feature(
594 self,
595 font: TTFont,
596 issue_fea_dir: str,
597 is_italic: bool,
598 is_cn: bool,
599 is_variable: bool,
600 is_hinted: bool,
601 fea_path: str,
602 ):
603 if self.apply_fea_file:
604 if fea_path:
605 print(f"Apply feature file [{fea_path}]")
606 addOpenTypeFeatures(
607 font,
608 fea_path,
609 )
610 self.freeze_feature_static(font, is_variable)
611 return
612
613 # If is hinted and keep inf liga, skip patching feature
614 if is_hinted and self.infinite_arrow:
615 return
616
617 # If `infinite_arrow` is None
618 # - hinted font will disable inf
619 # - unhinted font will enable inf
620 # If `infinite_arrow` is True
621 # - hinted font will enable inf
622 # - unhinted font will enable inf
623 # If `infinite_arrow` is False
624 # - hinted font will disable inf
625 # - unhinted font will disable inf
626 enable_infinite = (
627 bool(self.infinite_arrow)
628 if self.infinite_arrow is not None
629 else not is_hinted
630 )
631
632 fea_str = generate_fea_string(
633 is_italic=is_italic,
634 is_cn=is_cn,
635 is_normal=self.use_normal_preset,
636 is_calt=self.enable_ligature,
637 enable_infinite=enable_infinite,
638 enable_tag=not self.remove_tag_liga,
639 variable_enabled_feature_list=[
640 key for key, val in self.feature_freeze.items() if is_enable(val)
641 ]
642 if is_variable
643 else [],
644 remove_italic_calt=is_enable(self.feature_freeze["cv35"]),
645 )
646 try:
647 addOpenTypeFeaturesFromString(font, fea_str)
648 except Exception as e:
649 issue_fea_path = joinPaths(issue_fea_dir, "issue.fea")
650 with open(issue_fea_path, "w+") as f:

Callers 4

build_monoFunction · 0.80
build_mono_autohintFunction · 0.80
build_cnFunction · 0.80
build_variable_fontsFunction · 0.80

Calls 4

freeze_feature_staticMethod · 0.95
generate_fea_stringFunction · 0.90
is_enableFunction · 0.90
joinPathsFunction · 0.90

Tested by

no test coverage detected