ufo2ft.filters:Running RemoveOverlapsFilter

在使用 fontmake 把 UFO 打包成 ttf 時遇到錯誤,完整錯誤訊息:

INFO:fontmake.font_project:Building TTF for JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft:Pre-processing glyphs
 INFO:ufo2ft.filters:Running DecomposeComponentsFilter on JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft.filters:Running RemoveOverlapsFilter on JasonHandwriting2-JasonHandwriting2
 Traceback (most recent call last):
   File "/usr/local/bin/fontmake", line 8, in <module>
     sys.exit(main())
   File "/usr/local/lib/python2.7/site-packages/fontmake/main.py", line 422, in main
     ufo_paths, is_instance=args.pop("masters_as_instances"), **args
   File "/usr/local/lib/python2.7/site-packages/fontmake/font_project.py", line 1026, in run_from_ufos
     self.build_ttfs(ufos, **kwargs)
   File "/usr/local/lib/python2.7/site-packages/fontmake/font_project.py", line 311, in build_ttfs
     self.save_otfs(ufos, ttf=True, *kwargs)   File "/usr/local/lib/python2.7/site-packages/fontTools/misc/loggingTools.py", line 375, in wrapper     return func(args, **kwds)
   File "/usr/local/lib/python2.7/site-packages/fontmake/font_project.py", line 578, in save_otfs
     for font, ufo in zip(fonts, ufos):
   File "/usr/local/lib/python2.7/site-packages/fontmake/font_project.py", line 441, in iter_compile     yield compile_func(ufo, **options)   File "/usr/local/lib/python2.7/site-packages/ufo2ft/init.py", line 198, in compileTTF     glyphSet = preProcessor.process()   File "/usr/local/lib/python2.7/site-packages/ufo2ft/preProcessor.py", line 49, in process     func(ufo, glyphSet)   File "/usr/local/lib/python2.7/site-packages/ufo2ft/filters/init.py", line 219, in call     if include(glyph) and filter(glyph):
   File "/usr/local/lib/python2.7/site-packages/ufo2ft/filters/removeOverlaps.py", line 50, in filter
     self.union(contours, pen)
   File "/usr/local/lib/python2.7/site-packages/booleanOperations/booleanOperationManager.py", line 101, in union
     return _performOperation("union", contours, [], outPen)
   File "/usr/local/lib/python2.7/site-packages/booleanOperations/booleanOperationManager.py", line 70, in _performOperation
     subjectInputContours = [InputContour(contour) for contour in subjectContours if contour and len(contour) > 1]
   File "/usr/local/lib/python2.7/site-packages/booleanOperations/flatten.py", line 69, in init
     self.segments = _convertPointsToSegments(points)
   File "/usr/local/lib/python2.7/site-packages/booleanOperations/flatten.py", line 441, in _convertPointsToSegments
     willBeReversed=willBeReversed
   File "/usr/local/lib/python2.7/site-packages/booleanOperations/flatten.py", line 171, in init
     for pt1, pt2 in decomposeQuadraticSegment(pointCoordinates[1:]):
   File "/usr/local/lib/python2.7/site-packages/fontTools/pens/basePen.py", line 360, in decomposeQuadraticSegment
     assert n > 0
 AssertionError

解法:先使用 fontmake -h 查看沒有可以使用的參數,找到關於 overlaps

Handling of contours:
   --keep-overlaps       Do not remove any overlap.
   --overlaps-backend BACKEND
                         Select library to remove overlaps. Choose between:
                         booleanOperations, pathops (default:
                         booleanOperations)

由於 pathops 在 python2 已無法使用,python3 的安裝方法:

pip3 install --upgrade skia-pathops

由於直接執行 fontmake 會使用 python2 來執行,所以指令改成:

python3 -m fontmake

在 python3 使用 booleanOperations

錯誤訊息:

INFO:fontmake.font_project:Building TTF for JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft:Pre-processing glyphs
 INFO:ufo2ft.filters:Running DecomposeComponentsFilter on JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft.filters:Running RemoveOverlapsFilter on JasonHandwriting2-JasonHandwriting2
 ERROR:ufo2ft.filters.removeOverlaps:Failed to remove overlaps for glyph00004
 Traceback (most recent call last):
   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in run_module_as_main     "main", mod_spec)   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code     exec(code, run_globals)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 471, in <module>     sys.exit(main())   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 460, in main     ufo_paths, is_instance=args.pop("masters_as_instances"), **args   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 1019, in run_from_ufos     self.build_ttfs(ufos, **kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 208, in build_ttfs     self.save_otfs(ufos, ttf=True, *kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontTools/misc/loggingTools.py", line 367, in wrapper     return func(args, **kwds)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 480, in save_otfs
     for font, ufo in zip(fonts, ufos):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 345, in _iter_compile
     yield compile_func(ufo, debugFeatureFile=debugFeatureFile, **options)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/init.py", line 198, in compileTTF
     glyphSet = preProcessor.process()
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/preProcessor.py", line 49, in process
     func(ufo, glyphSet)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/init.py", line 219, in call
     if include(glyph) and filter(glyph):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/removeOverlaps.py", line 50, in filter
     self.union(contours, pen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 100, in union
     return _performOperation("union", contours, [], outPen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 69, in _performOperation
     subjectInputContours = [InputContour(contour) for contour in subjectContours if contour and len(contour) > 1]
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 69, in <listcomp>
     subjectInputContours = [InputContour(contour) for contour in subjectContours if contour and len(contour) > 1]
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/flatten.py", line 68, in init
     self.segments = _convertPointsToSegments(points)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/flatten.py", line 448, in _convertPointsToSegments
     point.segmentType
 booleanOperations.exceptions.UnsupportedContourError: ('Trying to perform operation on unsupported segment type.', 'qcurve')

改用 pathops,一樣有錯誤:

INFO:fontmake.font_project:Building TTF for JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft:Pre-processing glyphs
 INFO:ufo2ft.filters:Running DecomposeComponentsFilter on JasonHandwriting2-JasonHandwriting2
 INFO:ufo2ft.filters:Running RemoveOverlapsFilter on JasonHandwriting2-JasonHandwriting2
 ERROR:ufo2ft.filters.removeOverlaps:Failed to remove overlaps for glyph00004
 Traceback (most recent call last):
   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in run_module_as_main     "main", mod_spec)   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code     exec(code, run_globals)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 471, in <module>     sys.exit(main())   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 460, in main     ufo_paths, is_instance=args.pop("masters_as_instances"), **args   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 1019, in run_from_ufos     self.build_ttfs(ufos, **kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 208, in build_ttfs     self.save_otfs(ufos, ttf=True, *kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontTools/misc/loggingTools.py", line 367, in wrapper     return func(args, **kwds)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 480, in save_otfs
     for font, ufo in zip(fonts, ufos):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 345, in _iter_compile
     yield compile_func(ufo, debugFeatureFile=debugFeatureFile, **options)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/init.py", line 198, in compileTTF
     glyphSet = preProcessor.process()
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/preProcessor.py", line 49, in process
     func(ufo, glyphSet)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/init.py", line 219, in call
     if include(glyph) and filter(glyph):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/removeOverlaps.py", line 50, in filter
     self.union(contours, pen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 100, in union
     return performOperation("union", contours, [], outPen)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 69, in _performOperation     subjectInputContours = [InputContour(contour) for contour in subjectContours if contour and len(contour) > 1]   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/booleanOperationManager.py", line 69, in <listcomp>     subjectInputContours = [InputContour(contour) for contour in subjectContours if contour and len(contour) > 1]   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/flatten.py", line 68, in init     self.segments = _convertPointsToSegments(points)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/booleanOperations/flatten.py", line 448, in _convertPointsToSegments     point.segmentType booleanOperations.exceptions.UnsupportedContourError: ('Trying to perform operation on unsupported segment type.', 'qcurve') ➜  ttf ./build_jason_font2.sh INFO:fontmake.font_project:Building TTF for JasonHandwriting2-JasonHandwriting2 INFO:ufo2ft:Pre-processing glyphs INFO:ufo2ft.filters:Running DecomposeComponentsFilter on JasonHandwriting2-JasonHandwriting2 INFO:ufo2ft.filters:Running RemoveOverlapsFilter on JasonHandwriting2-JasonHandwriting2 Traceback (most recent call last):   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main     "main", mod_spec)   File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code     exec(code, run_globals)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 471, in <module>     sys.exit(main())   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/main.py", line 460, in main     ufo_paths, is_instance=args.pop("masters_as_instances"), **args   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 1019, in run_from_ufos     self.build_ttfs(ufos, **kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 208, in build_ttfs     self.save_otfs(ufos, ttf=True, *kwargs)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontTools/misc/loggingTools.py", line 367, in wrapper     return func(args, **kwds)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 480, in save_otfs
     for font, ufo in zip(fonts, ufos):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontmake/font_project.py", line 345, in _iter_compile
     yield compile_func(ufo, debugFeatureFile=debugFeatureFile, *options)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/init.py", line 198, in compileTTF     glyphSet = preProcessor.process()   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/preProcessor.py", line 49, in process     func(ufo, glyphSet)   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/init.py", line 219, in call     if include(glyph) and filter(glyph):
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufo2ft/filters/removeOverlaps.py", line 50, in filter
     self.union(contours, pen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/pathops/operations.py", line 10, in union
     contour.draw(pen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufoLib2/objects/contour.py", line 54, in draw
     self.drawPoints(pointPen)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/ufoLib2/objects/contour.py", line 78, in drawPoints
     pointPen.endPath()
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontTools/pens/pointPen.py", line 140, in endPath
     self._flushContour(segments)
   File "/Users/chunyuyao/Library/Python/3.7/lib/python/site-packages/fontTools/pens/pointPen.py", line 211, in _flushContour
     pen.qCurveTo(points)
   File "src/python/pathops/_pathops.pyx", line 700, in pathops._pathops.PathPen.qCurveTo
   File "src/python/pathops/_pathops.pyx", line 703, in pathops._pathops.PathPen._qCurveToOne
 TypeError: 'NoneType' object is not subscriptable

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *