Created
May 18, 2022 14:21
-
-
Save typesupply/0448ac6243ac3cd40578db6b7e3c93bc to your computer and use it in GitHub Desktop.
Bot that automatically fixes the smooth setting when it isn't correct.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fontPens.guessSmoothPointPen import GuessSmoothPointPen | |
from fontParts.world import RGlyph | |
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber, disableSubscriberEvents | |
class SmoothBot(Subscriber): | |
debug = False | |
def glyphEditorGlyphDidChangeContours(self, info): | |
glyph = info["glyph"] | |
ghost = RGlyph() | |
pointPen = GuessSmoothPointPen( | |
outPen=ghost.getPointPen() | |
) | |
glyph.drawPoints( | |
pointPen, | |
components=False | |
) | |
with disableSubscriberEvents(): | |
for contourIndex, ghostContour in enumerate(ghost.contours): | |
contour = glyph.contours[contourIndex] | |
for segmentIndex, ghostSegment in enumerate(ghostContour.segments): | |
segment = contour.segments[segmentIndex] | |
if segment.smooth != ghostSegment.smooth: | |
segment.smooth = ghostSegment.smooth | |
registerGlyphEditorSubscriber(SmoothBot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment