Esempio n. 1
0
    def customSubsetting(self, font, text):
        options = Options()
        options.layout_features = "*"  # keep all GSUB/GPOS features
        options.glyph_names = False  # keep post glyph names
        options.legacy_cmap = True  # keep non-Unicode cmaps
        options.name_legacy = True  # keep non-Unicode names
        options.name_IDs = ["*"]  # keep all nameIDs
        options.name_languages = ["*"]  # keep all name languages
        options.notdef_outline = True
        options.ignore_missing_glyphs = False
        options.recommended_glyphs = True
        options.prune_unicode_ranges = True
        subsetter = Subsetter(options=options)
        subsetter.populate(text=text, unicodes=[0, 13, 32])
        subsetter.subset(font)

        return font
Esempio n. 2
0
    def _subset(self, otf, fmt):
        from fontTools.subset import Options, Subsetter

        for name, subset in self.subsets.items():
            logger.info(f"Creating {name}.{fmt.value} subset")
            new = deepcopy(otf)
            options = Options()
            options.name_IDs = ["*"]
            options.name_legacy = True
            options.name_languages = ["*"]
            options.recommended_glyphs = True
            options.layout_features = ["*"]
            options.notdef_outline = True
            options.notdef_glyph = True
            options.glyph_names = True
            options.hinting = True
            options.legacy_kern = True
            options.symbol_cmap = True
            options.layout_closure = False
            options.prune_unicode_ranges = False
            options.passthrough_tables = False
            options.recalc_average_width = True
            options.ignore_missing_glyphs = True
            options.layout_scripts = subset["langsys"]

            options.drop_tables.remove("DSIG")
            options.no_subset_tables += ["DSIG"]

            subsetter = Subsetter(options=options)
            subsetter.populate(subset["glyphlist"])

            with TemporaryLogLevel(logging.WARNING):
                subsetter.subset(new)

            new = self._optimize(new, name, fmt)
            names = subset.get("names")
            if names:
                logger.info(
                    f"Adding name entries to {name}.{fmt.value} susbet")
                self._setnames(new, names)
            self._buildwoff(new, name, fmt)
            self._save(new, name, fmt)
Esempio n. 3
0
    def subsetter(self, font, subset):
        """ use the noto fonts glyphsnames
            to subset fonts with premade subsettings
        """
        options = Options()
        options.layout_features = "*"  # keep all GSUB/GPOS features
        # options.no_layout_closure = True # TESTING
        options.glyph_names = False  # keep post glyph names
        options.legacy_cmap = True  # keep non-Unicode cmaps
        options.name_legacy = True  # keep non-Unicode names
        options.name_IDs = ["*"]  # keep all nameIDs
        options.name_languages = ["*"]  # keep all name languages
        options.notdef_outline = False
        options.ignore_missing_glyphs = True
        options.prune_unicode_ranges = True
        options.recommended_glyphs = True
        subsetter = Subsetter(options=options)
        subsetter.populate(glyphs=subset)
        subsetter.subset(font)

        return font