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 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 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
IGNORE_ANCHORS = [] | |
# ---------------------------------------- | |
def match_anchor(anchor_source, anchor_targets): | |
if anchor_source.name.startswith("_"): | |
target_name = anchor_source.name[1:] | |
else: | |
target_name = "_" + anchor_source.name | |
for a in anchor_targets: |
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 fontTools.pens.transformPen import TransformPen | |
from fontTools.pens.pointPen import AbstractPointPen | |
from fontTools.misc.transform import Transform | |
import math | |
from defcon.objects.glyph import Glyph | |
class TransformPen2(TransformPen): | |
# because we don't want to change the transform matrix of the actual components | |
def addComponent(self, glyphName, transformation): |
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 simpleKerning import * | |
""" | |
A RoboFont script to expand kerning groups from base glyph to their composites. | |
1. Select the composites which are not grouped | |
2. Run the script | |
3. The groups will be expanded to the composites, if: | |
- Their width is same as the base glyph | |
- They're not already grouped | |
""" |
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
""" | |
RoboFont Script | |
- Type: Composite/Margins | |
- Purpose: Updates composites (a glyph which **only** has components e.g accented | |
letters) margins based on the base letter margins. | |
- Specifications: | |
- Determines the base letter according to (in order): unciode, | |
anchor names, glyph surface area (the darkest shape is the letter), | |
glyph width (if it's zero then it's accent). | |
- If the base letter is shifted in the composte (mostly by accident), it |
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
# menuTitle : Interpolated Preview | |
''' | |
v 0.2 | |
jackson @ okaytype | |
to do: | |
- clean up imports | |
- better performance | |
- needs a smarter, cheaper redraw trigger | |
- only redraw/reinterpolate the current glyph when changed, keep others |
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
import os | |
import shutil | |
from mojo.events import addObserver | |
""" | |
Goal: Create a UFOZ automatically when a UFO is saved. | |
Off the top of my head, I can think of a few ways to do this: | |
1. Make a copy of the font object, save as UFOZ, discard the |
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 vanilla import Window, EditText, Button | |
from mojo.extensions import setExtensionDefault, getExtensionDefault, registerExtensionDefaults, removeExtensionDefault | |
class preferenceTest(object): | |
def __init__(self): | |
self.windowname = 'pref save / load test' | |
self.prefKey = 'com.okaytype.toolName' | |
self.makeWindow() |
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 AppKit import NSScreen, NSDeviceSize, NSDeviceResolution | |
from Quartz import CGDisplayScreenSize | |
for i, screen in enumerate(NSScreen.screens(), 1): | |
description = screen.deviceDescription() | |
pw, ph = description[NSDeviceSize].sizeValue() | |
rx, ry = description[NSDeviceResolution].sizeValue() | |
mmw, mmh = CGDisplayScreenSize(description["NSScreenNumber"]) | |
scaleFactor = screen.backingScaleFactor() | |
pw *= scaleFactor |
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
import math | |
def largest_component(g): | |
if not g.components: | |
return | |
else: | |
boxList = [] | |
for c in g.components: | |
boxList.append( |
NewerOlder