# comment
whitespace has no meaning except single spaces used to separate important things
@ is an identifier
() means button of some sort
[__] means text entry of some sort (except checkbox)
{} means image
- means line
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.pointPen import ( | |
AbstractPointPen, | |
GuessSmoothPointPen | |
) | |
from fontParts.base.bPoint import ( | |
relativeBCPIn, | |
absoluteBCPIn, | |
relativeBCPOut, | |
absoluteBCPOut | |
) |
We have been making type design tool UIs for over 25 years. We have a lot of experience and examples to learn from. Our API for building UI hasn't changed much in 25 years. (We're still using the W API from RoboFont.) It works, but can we have something better?
Break it into a design problem...
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 mojo.events import BaseEventTool, installTool | |
backgroundColor = (1, 1, 0, 0.5) | |
mouseDownColor = (0, 0, 0, 0.25) | |
defaultSymbolSettings = dict( | |
name="oval", | |
size=(20, 20), | |
fillColor=(1, 0, 0, 0.75), | |
strokeColor=(1, 1, 1, 0.5), | |
strokeWidth=10 |
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"] |
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
"""Create tabular figures. Version 0.1""" | |
""" | |
This script gives you a UI and some options for building tabular | |
figures. The generated glyphs contain duplicates of the source | |
glyphs, but their widths and sidebearings have been changed. | |
This does not attempt to squeeze or stretch the outlines, rather | |
it simply shifts them around. | |
----------------------------------------------------------------- |
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
font = CurrentFont() | |
figures = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] | |
bottom1 = font["one"].bounds[1] | |
bottom2 = font["one.num"].bounds[1] | |
shift = bottom1 - bottom2 | |
isItalic = font.info.italicAngle != 0 |
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
""" | |
To do: | |
- auto alignment bugs? | |
- get rid of the frigging background override in List. UGH! | |
- implement all Window methods from W | |
- add all (or at least all feasable) init methods form W | |
- lots of other stuff. | |
- zzzzzzzzzzzz. | |
""" |
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 urllib.request import build_opener | |
import bs4 | |
from nltk.tokenize import PunktSentenceTokenizer | |
# Pull some text from a Wikipedia entry. | |
# The text could also come from a string, file or whatever. | |
url = "https://en.wikipedia.org/wiki/Font,_Switzerland" | |
opener = build_opener() |
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 mojo import events | |
import metricsMachine | |
class MMCurrentPairObserver(object): | |
def __init__(self): | |
self.previousPair = None | |
events.addObserver( | |
self, | |
"currentPairChangedCallback", |
NewerOlder