Пример #1
0
 def __attrs_post_init__(self) -> None:
     if self._path is not None:
         # if lazy argument is not set, default to lazy=True if path is provided
         if self._lazy is None:
             self._lazy = True
         reader = UFOReader(self._path, validate=self._validate)
         self.layers = LayerSet.read(reader, lazy=self._lazy)
         self.data = DataSet.read(reader, lazy=self._lazy)
         self.images = ImageSet.read(reader, lazy=self._lazy)
         self.info = Info.read(reader)
         self.features = Features(reader.readFeatures())
         self.groups = reader.readGroups()
         self.kerning = reader.readKerning()
         self.lib = reader.readLib()
         self._fileStructure = reader.fileStructure
         if self._lazy:
             # keep the reader around so we can close it when done
             self._reader = reader
Пример #2
0
 def read(cls, reader, lazy=True):
     layers = LayerSet.read(reader, lazy=lazy)
     data = DataSet.read(reader, lazy=lazy)
     images = ImageSet.read(reader, lazy=lazy)
     info = Info()
     reader.readInfo(info)
     features = Features(reader.readFeatures())
     groups = reader.readGroups()
     kerning = reader.readKerning()
     lib = reader.readLib()
     self = cls(
         layers=layers,
         info=info,
         features=features,
         groups=groups,
         kerning=kerning,
         lib=lib,
         data=data,
         images=images,
     )
     return self
Пример #3
0
    def read(cls, reader: UFOReader, lazy: bool = True) -> "Font":
        """Instantiates a Font object from a :class:`fontTools.ufoLib.UFOReader`.

        Args:
            path: The path to the UFO to load.
            lazy: If True, load glyphs, data files and images as they are accessed. If
                False, load everything up front.
        """
        self = cls(
            layers=LayerSet.read(reader, lazy=lazy),
            data=DataSet.read(reader, lazy=lazy),
            images=ImageSet.read(reader, lazy=lazy),
            info=Info.read(reader),
            features=Features(reader.readFeatures()),
            groups=reader.readGroups(),
            kerning=reader.readKerning(),
            lib=reader.readLib(),
            lazy=lazy,
        )
        self._fileStructure = reader.fileStructure
        if lazy:
            # keep the reader around so we can close it when done
            self._reader = reader
        return self
Пример #4
0
def _convert_LayerSet(value: LayerSet | Iterable[Layer]) -> LayerSet:
    return value if isinstance(value,
                               LayerSet) else LayerSet.from_iterable(value)