How to use the fontmake.errors.FontmakeError function in fontmake

To help you get started, we’ve selected a few fontmake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlefonts / fontmake / Lib / fontmake / __main__.py View on Github external
exclude_args(
            parser,
            args,
            [
                "interpolate",
                "use_mutatormath",
                "interpolate_binary_layout",
                "round_instances",
                "expand_features_to_instances",
            ],
            input_format,
        )
        project.run_from_ufos(
            ufo_paths, is_instance=args.pop("masters_as_instances"), **args
        )
    except FontmakeError as e:
        import sys

        sys.exit("fontmake: error: %s" % e)
github googlefonts / fontmake / Lib / fontmake / font_project.py View on Github external
if set(output) == {"ufo"}:
            return

        # the `ufos` parameter can be a list of UFO objects
        # or it can be a path (string) with a glob syntax
        ufo_paths = []
        if isinstance(ufos, str):
            ufo_paths = glob.glob(ufos)
            ufos = [self.open_ufo(x) for x in ufo_paths]
        elif isinstance(ufos, list):
            # ufos can be either paths or open Font objects, so normalize them
            ufos = [self.open_ufo(x) if isinstance(x, str) else x for x in ufos]
            ufo_paths = [x.path for x in ufos]
        else:
            raise FontmakeError(
                "UFOs parameter is neither a defcon.Font object, a path or a glob, "
                "nor a list of any of these.",
                ufos,
            )

        need_reload = False
        if "otf" in output:
            self.build_otfs(ufos, **kwargs)
            need_reload = True

        if "ttf" in output:
            if need_reload:
                ufos = [self.open_ufo(path) for path in ufo_paths]
            self.build_ttfs(ufos, **kwargs)
            need_reload = True
github googlefonts / fontmake / Lib / fontmake / font_project.py View on Github external
UFOs. Use this if you share feature files among masters in external
                files. Otherwise, the relative include paths can break as instances
                may end up elsewhere. Only done on interpolation.
        Returns:
            list of defcon.Font objects corresponding to the UFO instances.
        Raises:
            FontmakeError: if any of the sources defines a custom 'layer', for
                this is not supported by MutatorMath.
            ValueError: "expand_features_to_instances" is True but no source in the
                designspace document is designated with ''.
        """
        from glyphsLib.interpolation import apply_instance_data
        from mutatorMath.ufo.document import DesignSpaceDocumentReader

        if any(source.layerName is not None for source in designspace.sources):
            raise FontmakeError(
                "MutatorMath doesn't support DesignSpace sources with 'layer' "
                "attribute"
            )

        with temporarily_disabling_axis_maps(designspace.path) as temp_designspace_path:
            builder = DesignSpaceDocumentReader(
                temp_designspace_path,
                ufoVersion=3,
                roundGeometry=round_instances,
                verbose=True,
            )
            logger.info("Interpolating master UFOs from designspace")
            if include is not None:
                instances = self._search_instances(designspace, pattern=include)
                for instance_name in instances:
                    builder.readInstance(("name", instance_name))
github googlefonts / fontmake / Lib / fontmake / font_project.py View on Github external
def _search_instances(designspace, pattern):
        instances = OrderedDict()
        for instance in designspace.instances:
            # is 'name' optional? 'filename' certainly must not be
            if fullmatch(pattern, instance.name):
                instances[instance.name] = instance.filename
        if not instances:
            raise FontmakeError("No instance found with %r" % pattern)
        return instances