當前位置: 首頁>>代碼示例>>Python>>正文


Python TTGlyphPen.qCurveTo方法代碼示例

本文整理匯總了Python中fontTools.pens.ttGlyphPen.TTGlyphPen.qCurveTo方法的典型用法代碼示例。如果您正苦於以下問題:Python TTGlyphPen.qCurveTo方法的具體用法?Python TTGlyphPen.qCurveTo怎麽用?Python TTGlyphPen.qCurveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fontTools.pens.ttGlyphPen.TTGlyphPen的用法示例。


在下文中一共展示了TTGlyphPen.qCurveTo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_remove_extra_move_points

# 需要導入模塊: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 別名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import qCurveTo [as 別名]
 def test_remove_extra_move_points(self):
     pen = TTGlyphPen(None)
     pen.moveTo((0, 0))
     pen.lineTo((100, 0))
     pen.qCurveTo((100, 50), (50, 100), (0, 0))
     pen.closePath()
     self.assertEqual(len(pen.points), 4)
     self.assertEqual(pen.points[0], (0, 0))
開發者ID:anthrotype,項目名稱:fonttools,代碼行數:10,代碼來源:ttGlyphPen_test.py

示例2: test_keep_duplicate_end_point

# 需要導入模塊: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 別名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import qCurveTo [as 別名]
 def test_keep_duplicate_end_point(self):
     pen = TTGlyphPen(None)
     pen.moveTo((0, 0))
     pen.lineTo((100, 0))
     pen.qCurveTo((100, 50), (50, 100), (0, 0))
     pen.lineTo((0, 0))  # the duplicate point is not removed
     pen.closePath()
     self.assertEqual(len(pen.points), 5)
     self.assertEqual(pen.points[0], (0, 0))
開發者ID:anthrotype,項目名稱:fonttools,代碼行數:11,代碼來源:ttGlyphPen_test.py

示例3: test_keep_move_point

# 需要導入模塊: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 別名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import qCurveTo [as 別名]
 def test_keep_move_point(self):
     pen = TTGlyphPen(None)
     pen.moveTo((0, 0))
     pen.lineTo((100, 0))
     pen.qCurveTo((100, 50), (50, 100), (30, 30))
     # when last and move pts are different, closePath() implies a lineTo
     pen.closePath()
     self.assertEqual(len(pen.points), 5)
     self.assertEqual(pen.points[0], (0, 0))
開發者ID:anthrotype,項目名稱:fonttools,代碼行數:11,代碼來源:ttGlyphPen_test.py

示例4: makeGlyfBBox1

# 需要導入模塊: from fontTools.pens.ttGlyphPen import TTGlyphPen [as 別名]
# 或者: from fontTools.pens.ttGlyphPen.TTGlyphPen import qCurveTo [as 別名]
def makeGlyfBBox1(calcBBoxes=True, composite=False):
    font = getTTFont(sfntTTFSourcePath, recalcBBoxes=calcBBoxes)
    glyf = font["glyf"]
    hmtx = font["hmtx"]
    for name in ("bbox1", "bbox2"):
        pen = TTGlyphPen(None)
        if name == "bbox1":
            pen.moveTo((0, 0))
            pen.lineTo((0, 1000))
            pen.lineTo((1000, 1000))
            pen.lineTo((1000, 0))
            pen.closePath()
        else:
            pen.moveTo((0, 0))
            pen.qCurveTo((500, 750), (600, 500), (500, 250), (0, 0))
            pen.closePath()
        glyph = pen.glyph()
        if not calcBBoxes:
            glyph.recalcBounds(glyf)
            glyph.xMax -= 100
        glyf.glyphs[name] = glyph
        hmtx.metrics[name] = (0, 0)
        glyf.glyphOrder.append(name)

    if composite:
        name = "bbox3"
        pen = TTGlyphPen(glyf.glyphOrder)
        pen.addComponent("bbox1", [1, 0, 0, 1, 0, 0])
        pen.addComponent("bbox2", [1, 0, 0, 1, 1000, 0])
        glyph = pen.glyph()
        glyph.recalcBounds(glyf)
        glyf.glyphs[name] = glyph
        hmtx.metrics[name] = (0, 0)
        glyf.glyphOrder.append(name)

    tableData = getSFNTData(font)[0]
    font.close()
    del font
    header, directory, tableData = defaultSFNTTestData(tableData=tableData, flavor="TTF")
    data = packSFNT(header, directory, tableData, flavor="TTF")
    return data
開發者ID:w3c,項目名稱:woff2-tests,代碼行數:43,代碼來源:AuthoringToolTestCaseGenerator.py


注:本文中的fontTools.pens.ttGlyphPen.TTGlyphPen.qCurveTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。