This file contains hidden or 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
| ''' | |
| I never understand affine transformations, which is why I made this little | |
| script here. | |
| basic docs: | |
| https://fonttools.readthedocs.io/en/latest/misc/transform.html | |
| rf docs (explains how to convert normal operations (rotate, scale) to | |
| affine transformations): | |
| https://doc.robofont.com/documentation/topics/transformations/ |
This file contains hidden or 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 typing import Tuple, Optional | |
| from fontTools.pens.basePen import BasePen | |
| from fontTools.misc.arrayTools import calcBounds | |
| import math | |
| def round_angle_to_step(angle: float, degree: int) -> int: | |
| """ | |
| Rounds an angle to the nearest degree increment. | |
| Args: |
This file contains hidden or 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
| """ | |
| RoboFont subscriber to rotate both the glyph view and space center to help out drawing Mongolian, | |
| where the letter shapes are stored in binaries 90° rotated. | |
| """ | |
| from AppKit import NSNotificationCenter, NSViewFrameDidChangeNotification | |
| import ezui | |
| from mojo.subscriber import Subscriber, registerSpaceCenterSubscriber, unregisterSpaceCenterSubscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, WindowController | |
| from mojo.tools import CallbackWrapper |
This file contains hidden or 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 functools import singledispatch | |
| from io import StringIO | |
| from fontTools.feaLib import ast | |
| from fontTools.feaLib.error import FeatureLibError | |
| from fontTools.feaLib.parser import Parser | |
| def renameGlyphs(feaSource, renameFunc, glyphNames=()): | |
| features = Parser(StringIO(feaSource), glyphNames=glyphNames).parse() |
This file contains hidden or 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
| def smartSet(self, pair, value, exceptionType=None): | |
| ''' | |
| pair must be a tuple, its contents can be a glyphName or a group's name | |
| value must be an integer, why would you even kern on fractions.... | |
| exceptionType is the level of searching the function will do | |
| None : use the top level group or glyph names, no exceptions | |
| g2G : glyph to Group exception | |
| g2g : glyph to glyph exception | |
| G2g : Group to glyph exception |
This file contains hidden or 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
| # menuTitle: Event Subscriber | |
| ''' | |
| A Subscriber-based version of eventObserver. | |
| Useful for tracking internal notifications and using it for tool-building. | |
| 2024.01.22 — Ryan Bugden | |
| 2024.01.23 — Made a lot faster by Tal Leming. Thanks! | |
| ''' |
This file contains hidden or 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
| # | |
| # script for drawbot extension in robofont | |
| # draws a fitted / interpolating image from a responsive lettering ufo | |
| # erik@letterror.com / 20231204 | |
| def ip(a, b, f): | |
| return a + f * (b-a) | |
| page = (659, 500) # image size | |
| margin = 59 # nice to have a margin |
This file contains hidden or 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
| import ezui | |
| from merz.tools.drawingTools import NSImageDrawingTools | |
| from mojo.UI import AllFontWindows, CurrentFontWindow, AllWindows, CurrentGlyphWindow | |
| class frontAndCenter(ezui.WindowController): | |
| def build(self, parent, viewType): | |
| self.buttonMap = {} | |
| self.parent = parent |
This file contains hidden or 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 mojo.UI import CurrentSpaceCenter | |
| def measureLine(pointSize, records): | |
| scale = pointSize / window.font.info.unitsPerEm | |
| sublists = [] | |
| currentSublist = [] | |
| lineBreakChar = "NewLineGlyph" | |
| for item in records: | |
| if item.glyph.objectName == lineBreakChar: |
This file contains hidden or 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 mojo.subscriber import Subscriber, registerCurrentFontSubscriber | |
| import unicodedata | |
| class AutoNameSetter(Subscriber): | |
| debug = True | |
| def build(self): | |
| pass | |
NewerOlder