Skip to content

Instantly share code, notes, and snippets.

@simoncozens
simoncozens / sparsify.py
Last active April 26, 2024 17:48
sparsify.py - turn masters into sparse masters
import uuid
from glyphsLib import load, GSPath, GSNode, GSLayer
from fontTools.varLib.models import VariationModel, normalizeValue
import numpy as np
from tqdm import tqdm
import argparse
def interpolate_paths_without(glyph, intermediate_layer, intermediate_location):
tags = [axis.axisTag for axis in glyph.parent.axes]
@connordavenport
connordavenport / CatDog.py
Created December 21, 2023 23:03
a subclass of EditingTool for adjusting the /Ldot spacing
#!/usr/bin/env python3
import AppKit
from mojo.subscriber import Subscriber, WindowController
from mojo.UI import getDefault
from mojo.events import EditingTool, installTool
from mojo.subscriber import registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber
from mojo.roboFont import OpenWindow
from mojo.tools import IntersectGlyphWithLine

EZML Syntax Basics

# 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
@typesupply
typesupply / merzHitTestTest.py
Last active September 21, 2023 16:20
Test Merz hit testing with a glyph editor.
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
@frankrolf
frankrolf / redraw_for_start_point.py
Last active January 10, 2023 18:03
Avoid off-curve start points in UFO files
'''
Avoid offcurve start points
'''
from fontTools.ufoLib.pointPen import PointToSegmentPen
def find_offcurve_start(glyph):
'''
compare coordinates of first bPoint to coordinates of first point
@cjdunn
cjdunn / Latin_S.glyphConstruction
Last active February 16, 2022 17:01
glyphConstruction file for Latin S character set
### These are Glyph Construction formulas by CJ Dunn (www.CJType.com) used to support
### Latin S character set as defined by Christoph Koeberlin here: https://github.com/koeberlin/Latin-Character-Sets
###
### I use these with the Glyph Construction extension for Robofont: https://github.com/typemytype/GlyphConstruction/tree/master/GlyphConstruction.roboFontExt
###
### variables start with a dollar sign and to use them put the name between curly brackets
### offset for accents for uc and lc, change values for each style
$top_uc = `O:top+37`
$top_lc = `o:top+48`
### anchor names variables are below
@khaledhosny
khaledhosny / cldr-coverage.py
Last active May 8, 2020 15:49
Calculate font script and language coverage based on ICU exemplar data
# Copyright 2020 Khaled Hosny
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@justvanrossum
justvanrossum / generateOTTagsModule.py
Last active August 20, 2020 08:50
Scrape OT tag definitions and descriptions from OT spec site (script, language and feature tags)
import os
import re
def parse(data):
start = data.find("<tbody>")
end = data.find("</tbody>")
data = data[start+7:end]
for chunk in re.findall(r"<tr>.+?</tr>", data, re.DOTALL):
fields = re.findall(r"<td>(.+?)</td>", chunk, re.DOTALL)
@okay-type
okay-type / test-preferences.py
Last active October 22, 2019 15:37
Testing saving/loading preferences in robofont
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()
@LettError
LettError / prrrrrr.py
Created September 6, 2019 19:45
RoboFont: temporary designspace + designspaceChecker to report on glyph compatibility issues.
"""
test all open fonts on compatibility
create temp designspace file
align all fonts on a temp axis
order does not matter
run designspaceProblems
present the data somehow