当前位置: 首页>>代码示例>>Python>>正文


Python transform.Transform方法代码示例

本文整理汇总了Python中fontTools.misc.transform.Transform方法的典型用法代码示例。如果您正苦于以下问题:Python transform.Transform方法的具体用法?Python transform.Transform怎么用?Python transform.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fontTools.misc.transform的用法示例。


在下文中一共展示了transform.Transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: extractComposites

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def extractComposites(glyph):
    """Return a new glyph with outline copies of each composite from the source glyph."""

    decomposedComposites = RGlyph()

    if len(glyph.components):
        font = glyph.getParent()

        for comp in reversed(glyph.components):

            # obtain source data
            baseGlyphName = comp.baseGlyph
            baseGlyph = font[baseGlyphName]
            t = transform.Transform(*comp.transformation)

            # create a temporary glyph on which to draw the decomposed composite
            single_decomposedComposite = RGlyph()
            decompPen = single_decomposedComposite.getPen()
            baseGlyph.draw(decompPen)
            single_decomposedComposite.transform(t)

            # add single composite to the returned glyph
            decomposedComposites.appendGlyph(single_decomposedComposite)

    return decomposedComposites 
开发者ID:loicsander,项目名称:Robofont-scripts,代码行数:27,代码来源:fontUtils.py

示例2: _get_anchor_data

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _get_anchor_data(anchor_data, ufo, components, anchor_name):
    """Get data for an anchor from a list of components."""

    anchors = []
    for component in components:
        for anchor in ufo[component.baseGlyph].anchors:
            if anchor.name == anchor_name:
                anchors.append((anchor, component))
                break
    if len(anchors) > 1:
        for i, (anchor, component) in enumerate(anchors):
            t = Transform(*component.transformation)
            name = "%s_%d" % (anchor.name, i + 1)
            anchor_data[name] = t.transformPoint((anchor.x, anchor.y))
    elif anchors:
        anchor, component = anchors[0]
        t = Transform(*component.transformation)
        anchor_data[anchor.name] = t.transformPoint((anchor.x, anchor.y)) 
开发者ID:googlefonts,项目名称:glyphsLib,代码行数:20,代码来源:anchors.py

示例3: _transformBy

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _transformBy(self, matrix, **kwargs):
        """
        This is the environment implementation of
        :meth:`BaseAnchor.transformBy`.

        **matrix** will be a :ref:`type-transformation`.
        that has been normalized with
        :func:`normalizers.normalizeTransformationMatrix`.

        Subclasses may override this method.
        """
        t = transform.Transform(*matrix)
        x, y = t.transformPoint((self.x, self.y))
        self.x = x
        self.y = y

    # -------------
    # Interpolation
    # ------------- 
开发者ID:robotools,项目名称:fontParts,代码行数:21,代码来源:anchor.py

示例4: _transformBy

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _transformBy(self, matrix, **kwargs):
        """
        Subclasses may override this method.
        """
        anchor = self.anchor
        bcpIn = absoluteBCPIn(anchor, self.bcpIn)
        bcpOut = absoluteBCPOut(anchor, self.bcpOut)
        points = [bcpIn, anchor, bcpOut]
        t = transform.Transform(*matrix)
        bcpIn, anchor, bcpOut = t.transformPoints(points)
        x, y = anchor
        self._point.x = x
        self._point.y = y
        self.bcpIn = relativeBCPIn(anchor, bcpIn)
        self.bcpOut = relativeBCPOut(anchor, bcpOut)

    # ----
    # Misc
    # ---- 
开发者ID:robotools,项目名称:fontParts,代码行数:21,代码来源:bPoint.py

示例5: _transformBy

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _transformBy(self, matrix, **kwargs):
        """
        This is the environment implementation of
        :meth:`BasePoint.transformBy`.

        **matrix** will be a :ref:`type-transformation`.
        that has been normalized with
        :func:`normalizers.normalizeTransformationMatrix`.

        Subclasses may override this method.
        """
        t = transform.Transform(*matrix)
        x, y = t.transformPoint((self.x, self.y))
        self.x = x
        self.y = y

    # -------------
    # Normalization
    # ------------- 
开发者ID:robotools,项目名称:fontParts,代码行数:21,代码来源:point.py

示例6: transformBy

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def transformBy(self, matrix, origin=None):
        """
        Transform the object.

            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
            >>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))

        **matrix** must be a :ref:`type-transformation`.
        **origin** defines the point at with the transformation
        should originate. It must be a :ref:`type-coordinate`
        or ``None``. The default is ``(0, 0)``.
        """
        matrix = normalizers.normalizeTransformationMatrix(matrix)
        if origin is None:
            origin = (0, 0)
        origin = normalizers.normalizeCoordinateTuple(origin)
        if origin is not None:
            t = transform.Transform()
            oX, oY = origin
            t = t.translate(oX, oY)
            t = t.transform(matrix)
            t = t.translate(-oX, -oY)
            matrix = tuple(t)
        self._transformBy(matrix) 
开发者ID:robotools,项目名称:fontParts,代码行数:26,代码来源:base.py

示例7: _flattenComponent

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _flattenComponent(glyphSet, component):
    """Returns a list of tuples (baseGlyph, transform) of nested component."""

    glyph = glyphSet[component.baseGlyph]
    if not glyph.components:
        transformation = Transform(*component.transformation)
        return [(component.baseGlyph, transformation)]

    all_flattened_components = []
    for nested in glyph.components:
        flattened_components = _flattenComponent(glyphSet, nested)
        for i, (_, tr) in enumerate(flattened_components):
            tr = tr.transform(component.transformation)
            flattened_components[i] = (flattened_components[i][0], tr)
        all_flattened_components.extend(flattened_components)
    return all_flattened_components 
开发者ID:googlefonts,项目名称:ufo2ft,代码行数:18,代码来源:flattenComponents.py

示例8: _get_anchor_data

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _get_anchor_data(anchor_data, glyphSet, components, anchor_name):
    """Get data for an anchor from a list of components."""

    anchors = []
    for component in components:
        for anchor in glyphSet[component.baseGlyph].anchors:
            if anchor.name == anchor_name:
                anchors.append((anchor, component))
                break
    if len(anchors) > 1:
        for i, (anchor, component) in enumerate(anchors):
            t = Transform(*component.transformation)
            name = "%s_%d" % (anchor.name, i + 1)
            anchor_data[name] = t.transformPoint((anchor.x, anchor.y))
    elif anchors:
        anchor, component = anchors[0]
        t = Transform(*component.transformation)
        anchor_data[anchor.name] = t.transformPoint((anchor.x, anchor.y)) 
开发者ID:googlefonts,项目名称:ufo2ft,代码行数:20,代码来源:propagateAnchors.py

示例9: _adjust_anchors

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _adjust_anchors(anchor_data, glyphSet, component):
    """
    Adjust base anchors to which a mark component may have been attached, by
    moving the base anchor attached to a mark anchor to the position of
    the mark component's base anchor.
    """

    glyph = glyphSet[component.baseGlyph]
    t = Transform(*component.transformation)
    for anchor in glyph.anchors:
        # only adjust if this anchor has data and the component also contains
        # the associated mark anchor (e.g. "_top" for "top")
        if anchor.name in anchor_data and any(
            a.name == "_" + anchor.name for a in glyph.anchors
        ):
            anchor_data[anchor.name] = t.transformPoint((anchor.x, anchor.y)) 
开发者ID:googlefonts,项目名称:ufo2ft,代码行数:18,代码来源:propagateAnchors.py

示例10: _adjust_anchors

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _adjust_anchors(anchor_data, ufo, component):
    """Adjust anchors to which a mark component may have been attached."""

    glyph = ufo[component.baseGlyph]
    t = Transform(*component.transformation)
    for anchor in glyph.anchors:
        # only adjust if this anchor has data and the component also contains
        # the associated mark anchor (e.g. "_top" for "top")
        if anchor.name in anchor_data and any(
            a.name == "_" + anchor.name for a in glyph.anchors
        ):
            anchor_data[anchor.name] = t.transformPoint((anchor.x, anchor.y)) 
开发者ID:googlefonts,项目名称:glyphsLib,代码行数:14,代码来源:anchors.py

示例11: _transformBy

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def _transformBy(self, matrix, **kwargs):
        """
        Subclasses may override this method.
        """
        t = transform.Transform(*matrix)
        transformation = t.transform(self.transformation)
        self.transformation = tuple(transformation)

    # -------------
    # Normalization
    # ------------- 
开发者ID:robotools,项目名称:fontParts,代码行数:13,代码来源:image.py

示例12: from_layer

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def from_layer(cls, font, layerName=None, copy=False, skipExportGlyphs=None):
        """Return a mapping of glyph names to glyph objects from `font`."""
        if layerName is not None:
            layer = font.layers[layerName]
        else:
            layer = font.layers.defaultLayer

        if copy:
            self = _copyLayer(layer, obj_type=cls)
            self.lib = deepcopy(layer.lib)
        else:
            self = cls((g.name, g) for g in layer)
            self.lib = layer.lib

        # If any glyphs in the skipExportGlyphs list are used as components, decompose
        # them in the containing glyphs...
        if skipExportGlyphs:
            for glyph in self.values():
                if any(c.baseGlyph in skipExportGlyphs for c in glyph.components):
                    deepCopyContours(self, glyph, glyph, Transform(), skipExportGlyphs)
                    if hasattr(glyph, "removeComponent"):  # defcon
                        for c in [
                            component
                            for component in glyph.components
                            if component.baseGlyph in skipExportGlyphs
                        ]:
                            glyph.removeComponent(c)
                    else:  # ufoLib2
                        glyph.components[:] = [
                            c
                            for c in glyph.components
                            if c.baseGlyph not in skipExportGlyphs
                        ]
            # ... and then remove them from the glyph set, if even present.
            for glyph_name in skipExportGlyphs:
                if glyph_name in self:
                    del self[glyph_name]

        self.name = layer.name if layerName is not None else None
        return self 
开发者ID:googlefonts,项目名称:ufo2ft,代码行数:42,代码来源:util.py

示例13: filter

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def filter(self, glyph):
        if not glyph.components:
            return False
        ufo2ft.util.deepCopyContours(self.context.glyphSet, glyph, glyph, Transform())
        glyph.clearComponents()
        return True 
开发者ID:googlefonts,项目名称:ufo2ft,代码行数:8,代码来源:decomposeComponents.py

示例14: __init__

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def __init__(self, outPen, transformation):
		"""The 'outPen' argument is another pen object. It will receive the
		transformed coordinates. The 'transformation' argument can either
		be a six-tuple, or a fontTools.misc.transform.Transform object.
		"""
		if not hasattr(transformation, "transformPoint"):
			from fontTools.misc.transform import Transform
			transformation = Transform(*transformation)
		self._transformation = transformation
		self._transformPoint = transformation.transformPoint
		self._outPen = outPen
		self._stack = [] 
开发者ID:gltn,项目名称:stdm,代码行数:14,代码来源:transformPen.py

示例15: decomposeGlyphs

# 需要导入模块: from fontTools.misc import transform [as 别名]
# 或者: from fontTools.misc.transform import Transform [as 别名]
def decomposeGlyphs(ufos, glyphNamesToDecompose):
  for ufo in ufos:
    for glyphname in glyphNamesToDecompose:
      glyph = ufo[glyphname]
      _deepCopyContours(ufo, glyph, glyph, Transform())
      glyph.clearComponents() 
开发者ID:rsms,项目名称:inter,代码行数:8,代码来源:glyph.py


注:本文中的fontTools.misc.transform.Transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。