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


Python defcon.Glyph类代码示例

本文整理汇总了Python中defcon.Glyph的典型用法代码示例。如果您正苦于以下问题:Python Glyph类的具体用法?Python Glyph怎么用?Python Glyph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: OutlinePen

class OutlinePen(BasePen):

    pointClass = MathPoint
    magicCurve = 0.5522847498

    def __init__(self, glyphSet, offset=10, contrast=0, contrastAngle=0, connection="square", cap="round", miterLimit=None, closeOpenPaths=True, optimizeCurve=False, preserveComponents=False):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self.contrast = abs(contrast)
        self.contrastAngle = contrastAngle
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset * 2
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths
        self.optimizeCurve = optimizeCurve

        self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
        self.capCallback = getattr(self, "cap%s" % (cap.title()))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.preserveComponents = preserveComponents
        self.components = []

        self.drawSettings()

    def _moveTo(self, (x, y)):
        if self.offset == 0:
            self.outerPen.moveTo((x, y))
            self.innerPen.moveTo((x, y))
            return
        self.originalPen.moveTo((x, y))

        p = self.pointClass(x, y)
        self.prevPoint = p
        self.firstPoint = p
        self.shouldHandleMove = True
开发者ID:RevolverTypeFoundry,项目名称:RoboFontExtensions,代码行数:60,代码来源:outline.py

示例2: test_insertGlyph

 def test_insertGlyph(self):
     font = Font(getTestFontPath())
     glyph = Glyph()
     glyph.name = "NewGlyphTest"
     self.assertEqual(sorted(font.keys()), ["A", "B", "C"])
     font.insertGlyph(glyph)
     self.assertEqual(sorted(font.keys()), ["A", "B", "C", "NewGlyphTest"])
开发者ID:anthrotype,项目名称:defcon,代码行数:7,代码来源:test_font.py

示例3: test_appendAnchor

 def test_appendAnchor(self):
     glyph = Glyph()
     glyph.dirty = False
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     self.assertEqual(len(glyph.anchors), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(anchor.getParent(), glyph)
开发者ID:anthrotype,项目名称:defcon,代码行数:8,代码来源:test_glyph.py

示例4: test_appendComponent

 def test_appendComponent(self):
     glyph = Glyph()
     glyph.dirty = False
     component = Component()
     glyph.appendComponent(component)
     self.assertEqual(len(glyph.components), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(component.getParent(), glyph)
开发者ID:anthrotype,项目名称:defcon,代码行数:8,代码来源:test_glyph.py

示例5: test_appendContour

 def test_appendContour(self):
     glyph = Glyph()
     glyph.dirty = False
     contour = Contour()
     glyph.appendContour(contour)
     self.assertEqual(len(glyph), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(contour.getParent(), glyph)
开发者ID:anthrotype,项目名称:defcon,代码行数:8,代码来源:test_glyph.py

示例6: test_appendGuideline

 def test_appendGuideline(self):
     glyph = Glyph()
     glyph.dirty = False
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     self.assertEqual(len(glyph.guidelines), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(guideline.getParent(), glyph)
开发者ID:anthrotype,项目名称:defcon,代码行数:8,代码来源:test_glyph.py

示例7: __init__

    def __init__(
        self,
        glyphSet,
        offset=10,
        contrast=0,
        contrastAngle=0,
        connection="square",
        cap="round",
        miterLimit=None,
        closeOpenPaths=True,
        optimizeCurve=False,
        preserveComponents=False,
    ):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self.contrast = abs(contrast)
        self.contrastAngle = contrastAngle
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset * 2
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths
        self.optimizeCurve = optimizeCurve

        self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
        self.capCallback = getattr(self, "cap%s" % (cap.title()))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.preserveComponents = preserveComponents
        self.components = []

        self.drawSettings()
开发者ID:typemytype,项目名称:outlinerRoboFontExtension,代码行数:55,代码来源:outline.py

示例8: OutlinePen

class OutlinePen(BasePen):
    
    pointClass = MathPoint
    magicCurve = 0.5522847498
    
    def __init__(self, glyphSet, offset=10, connection="square", cap="round", mitterLimit=None, closeOpenPaths=True):
        BasePen.__init__(self, glyphSet)
        
        self.offset = abs(offset)
        self._inputMitterLimit = mitterLimit
        if mitterLimit is None:
            mitterLimit = self.offset
        self.mitterLimit = abs(mitterLimit)
        
        self.closeOpenPaths = closeOpenPaths
        
        self.connectionCallback = getattr(self, "connection%s" %(connection[0].capitalize() + connection[1:]))
        self.capCallback = getattr(self, "cap%s" %(cap[0].capitalize() + cap[1:]))
        
        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()
        
        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None
        
        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None
        
        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None
                
        self.shouldHandleMove = True
        
        self.drawSettings()
        
    def _moveTo(self, (x, y)):
        if self.offset == 0:
            self.outerPen.moveTo((x, y))
            self.innerPen.moveTo((x, y))
            return
        self.originalPen.moveTo((x, y))
        
        p = self.pointClass(x, y)
        self.prevPoint = p
        self.firstPoint = p
        self.shouldHandleMove = True
开发者ID:christophknoth,项目名称:RoboFontExtensions,代码行数:54,代码来源:outline.py

示例9: test_remove_tiny_sub_paths_large_contour

def test_remove_tiny_sub_paths_large_contour():
    g = Glyph()
    p = g.getPen()
    p.moveTo((100, 100))
    p.lineTo((200, 200))
    p.lineTo((0, 100))
    p.closePath()
    assert len(g[0]) == 3
    assert g.bounds == (0, 100, 200, 200)
    bg = BooleanGlyph(g)
    assert remove_tiny_sub_paths(bg, 25, []) == []
开发者ID:adobe-type-tools,项目名称:afdko,代码行数:11,代码来源:checkoutlinesufo_test.py

示例10: test_remove_tiny_sub_paths_small_contour

def test_remove_tiny_sub_paths_small_contour():
    g = Glyph()
    p = g.getPen()
    p.moveTo((1, 1))
    p.lineTo((2, 2))
    p.lineTo((0, 1))
    p.closePath()
    assert len(g[0]) == 3
    assert g.bounds == (0, 1, 2, 2)
    bg = BooleanGlyph(g)
    assert remove_tiny_sub_paths(bg, 25, []) == \
        ['Contour 0 is too small: bounding box is less than minimum area. '
         'Start point: ((1, 1)).']
开发者ID:adobe-type-tools,项目名称:afdko,代码行数:13,代码来源:checkoutlinesufo_test.py

示例11: glyph_to_quadratic

def glyph_to_quadratic(glyph, max_n, max_err, correctDirection=True,
                       verbose=False):
    """ Convert the glyph outline to TrueType quadratic splines. """
    new = Glyph()
    writerPen = new.getPointPen()
    cu2quPen = Cu2QuPen(writerPen, max_n, max_err, verbose)
    if correctDirection:
        reversePen = ReverseContourPointPen(cu2quPen)
        glyph.drawPoints(reversePen)
    else:
        glyph.drawPoints(cu2quPen)
    # clear glyph but keep anchors for mark, mkmk features
    glyph.clearContours()
    glyph.clearComponents()
    writerPen = glyph.getPointPen()
    new.drawPoints(writerPen)
开发者ID:davelab6,项目名称:scope-one,代码行数:16,代码来源:convert.py

示例12: test_correct_direction_same_area

 def test_correct_direction_same_area(self):
     glyph = Glyph()
     pen = glyph.getPointPen()
     pen.beginPath()
     pen.addPoint((0, 0), segmentType="line")
     pen.addPoint((0, 50), segmentType="line")
     pen.addPoint((50, 50), segmentType="line")
     pen.endPath()
     pen.beginPath()
     pen.addPoint((50, 50), segmentType="line")
     pen.addPoint((50, 100), segmentType="line")
     pen.addPoint((100, 100), segmentType="line")
     pen.endPath()
     try:
         glyph.correctContourDirection()
     except Exception as e:
         self.fail("glyph.correctContourDirection() raised unexpected exception: "
                   + str(e))
开发者ID:moyogo,项目名称:defcon,代码行数:18,代码来源:test_contour.py

示例13: test_identifier

 def test_identifier(self):
     glyph = Glyph()
     contour = Contour()
     glyph.appendContour(contour)
     contour.identifier = "contour 1"
     self.assertEqual(contour.identifier, "contour 1")
     self.assertEqual(sorted(glyph.identifiers), ["contour 1"])
     contour = Contour()
     glyph.appendContour(contour)
     with self.assertRaises(AssertionError):
         contour.identifier = "contour 1"
     contour.identifier = "contour 2"
     self.assertEqual(sorted(glyph.identifiers), ["contour 1", "contour 2"])
     contour.identifier = "not contour 2 anymore"
     self.assertEqual(contour.identifier, "contour 2")
     self.assertEqual(sorted(glyph.identifiers), ["contour 1", "contour 2"])
     contour.identifier = None
     self.assertEqual(contour.identifier, "contour 2")
     self.assertEqual(sorted(glyph.identifiers), ["contour 1", "contour 2"])
开发者ID:moyogo,项目名称:defcon,代码行数:19,代码来源:test_contour.py

示例14: find_shape_diffs

    def find_shape_diffs(self):
        """Report differences in glyph shapes, using BooleanOperations."""

        self.build_names()

        area_pen = GlyphAreaPen(None)
        pen = PointToSegmentPen(area_pen)
        mismatched = {}
        for name in self.names:
            glyph_a = Glyph()
            glyph_b = Glyph()
            self.glyph_set_a[name].draw(
                Qu2CuPen(glyph_a.getPen(), self.glyph_set_a))
            self.glyph_set_b[name].draw(
                Qu2CuPen(glyph_b.getPen(), self.glyph_set_b))
            booleanOperations.xor(list(glyph_a), list(glyph_b), pen)
            area = abs(area_pen.pop())
            if area:
                mismatched[name] = (area)

        stats = self.stats['compared']
        for name, area in mismatched.items():
            stats.append((area, name, self.basepath))
开发者ID:anthrotype,项目名称:nototools,代码行数:23,代码来源:shape_diff.py

示例15: __init__

    def __init__(self, glyphSet, offset=10, connection="square", cap="round", miterLimit=None, closeOpenPaths=True):
        BasePen.__init__(self, glyphSet)

        self.offset = abs(offset)
        self._inputmiterLimit = miterLimit
        if miterLimit is None:
            miterLimit = self.offset
        self.miterLimit = abs(miterLimit)

        self.closeOpenPaths = closeOpenPaths

        self.connectionCallback = getattr(self, "connection%s" %(connection[0].capitalize() + connection[1:]))
        self.capCallback = getattr(self, "cap%s" %(cap[0].capitalize() + cap[1:]))

        self.originalGlyph = Glyph()
        self.originalPen = self.originalGlyph.getPen()

        self.outerGlyph = Glyph()
        self.outerPen = self.outerGlyph.getPen()
        self.outerCurrentPoint = None
        self.outerFirstPoint = None
        self.outerPrevPoint = None

        self.innerGlyph = Glyph()
        self.innerPen = self.innerGlyph.getPen()
        self.innerCurrentPoint = None
        self.innerFirstPoint = None
        self.innerPrevPoint = None

        self.prevPoint = None
        self.firstPoint = None
        self.firstAngle = None
        self.prevAngle = None

        self.shouldHandleMove = True

        self.drawSettings()
开发者ID:jeremymickel,项目名称:hTools2,代码行数:37,代码来源:outliner.py


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