Skip to content

Instantly share code, notes, and snippets.

from robofab.world import *
f = CurrentGlyph()
f.appendAnchor('XXX', (0, 0)) #Change XXX to whatever name you want
f.update()
#Non Robofab add anchor
f = fl.glyph
NewAnchor = Anchor('XXX', 0, 0)
f.anchors.append(NewAnchor)
fl.UpdateFont()
@m4rc1e
m4rc1e / django-anonymous-required.py
Created June 27, 2016 08:56
Django decorator for views that allow only unauthenticated users to access view.
from django.shortcuts import redirect
def anonymous_required(redirect_url):
"""
Decorator for views that allow only unauthenticated users to access view.
Usage:
@anonymous_required(redirect_url='company_info')
@m4rc1e
m4rc1e / .json
Created September 7, 2016 21:37
[
{
"description": "fontforge validation outputs error messages?",
"log_messages": [
"ERROR: fontforge did print these messages to stderr:\nThe following table(s) in the font have been ignored by FontForge\n Ignoring 'DSIG' digital signature table\n"
],
"result": "ERROR",
"target": "/Users/marc/Documents/googlefonts/manual_font_cleaning/The-Lobster-Font/Lobster/Lobster-Regular.ttf"
},
@m4rc1e
m4rc1e / gist:a0c2f20247c2c509853bb4d2a26c6baf
Created September 20, 2016 19:33
Glyphsapp: Tallest and Deepest glyph in all masters
font = Glyphs.font
tallest = 0
tallest_name = ''
deepest = 0
deepest_name = ''
for i, master in enumerate(font.masters):
for glyph in font.glyphs:
font = Glyphs.font
instances = font.instances
for instance in instances:
if 'Bold Italic' == instance.name:
instance.linkStyle = ''
print 'Removed Bold from Bold Italic linked style'
@m4rc1e
m4rc1e / change_font_name.py
Last active November 15, 2016 18:42
Append '_new' to font names
import os
import sys
from glob import glob
from fontTools.ttLib import TTFont
import re
NAME_SUFFIX = '_new'
NAME_ENTRIES = [
(1, 0, 0), # Mac
(3, 1, 1033)
@m4rc1e
m4rc1e / ymin_ymax.py
Last active November 18, 2016 12:16
In Glyphsapp, find the ymin and ymax in all layers
#MenuTitle: Find Family ymin and ymax
def shortest_tallest_glyphs(font, *args):
'''find the tallest and shortest glyphs in all masters from a list.
If no list is given, search all glyphs.'''
lowest = 0.0
highest = 0.0
highest_name = ''
lowest_name = ''
masters_count = len(font.masters)
@m4rc1e
m4rc1e / gfonts_collection_bad_fstype_macstyle.py
Created February 7, 2017 17:01
fonts/google: Search for incorrect macStyle and fsType font calues
"""
Recrusively traverse a collection of fonts and find incorrect fsType and
macStyle values
fsType should always be 0x000
macStyle values should map to the MACSTYLE constant
"""
import sys
import glyphsLib
import os
parent_dir = '/Users/marc/Documents/googlefonts/manual_font_cleaning/'
possible_var_fonts = []
almost_possible_var_fonts = []
for root, dirs, files in os.walk(parent_dir, topdown=False):
for f in files: