Skip to content

Instantly share code, notes, and snippets.

import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())
@marcdama
marcdama / [DaMa]_All_Glyphs_Check_if_Sidebearings_Equal_Value
Created August 24, 2015 09:37
Check if Sidebearings equal specified amount
from robofab.world import *
f = CurrentFont()
sidebearing = 50
l = []
for i in f:
if i.leftMargin != sidebearing:
l.append(i.name)
from robofab.world import *
f = CurrentFont()
g = f.selection[0]
for i in f:
for j in i.components:
if j.baseGlyph == g:
i.mark = 1
from robofab.world import *
'''Transfer the first loaded fonts names to the second loaded font'''
f = AllFonts()
good_names = {}
for i in f[0]:
good_names[i.index] = i.name
@marcdama
marcdama / gist:36e7d96962f16ba494fc
Created July 1, 2015 09:04
FL: Font: Check if font has unicoded glyph from list
from robofab.world import *
f = CurrentFont()
unis = ['00A2','00A3','00A5','00A6','00A9','00AB','00AC','00AF','00B0','00B1','00B2','00B3','00B4','03BC','00B6','00B7','00B8','00B9','00BA','00BB','00BC','00BD','00BE','2011','2012','201A','201B','201E','201F','2020','2021','2022','2026','2038','2039','203A','2070','2074','2075','2076','2077','2078','2079','207A','207B','207C','207D','207E','207F','2080','2081','2082','2083','2084','2085','2086','2087','2088','2089','208A','208B','208C','208D','208E','20A1','2117','2120','2122','03A9','212E','2153','2154','215B','215C','215D','215E','2194','2195','21A8','21D0','21D2','21D4','220B','2212','2215','2218','2219','2221','2243','2259','2272','2273']
g_unis = []
for i in f:
if i.unicode:
cp = hex(i.unicode)[2:].zfill(4).upper()
@marcdama
marcdama / gist:463e8185828ff57ee00a
Created June 2, 2015 15:10
FL: Selection: move specific anchor by a set amount
from robofab.world import *
f = CurrentFont()
anc_name = '_htop'
amount = 10
for i in f.selection:
for j in f[i].anchors:
if anc_name in j.name:
@marcdama
marcdama / FL: for selected glyphs: Center glyph vertically, according to specified box
Created April 24, 2015 11:42
FL: for selected glyphs: Center glyph vertically, according to specified box
from robofab.world import *
f = CurrentFont()
top = 880
bottom = -120
for i in f.selection:
glyf_h = f[i].box[3]- f[i].box[1]
t_s = top - f[i].box[3] #distance from top of bbox
@marcdama
marcdama / FL: All Glyphs: replace outline with advanced width square
Last active August 29, 2015 14:19
FL: All Glyphs: replace outline with advanced width square
from robofab.world import *
f=CurrentFont()
for i in f:
g = i.width
h = f.insertGlyph(i).getPen()
h.moveTo((0,0))
h.lineTo((g,0))
h.lineTo((g, 750))
@marcdama
marcdama / FL: For Selected Glyphs: intelligently make glyph fixed width
Created April 21, 2015 13:09
Convert glyphs to fixed width (1000) optically
from robofab.world import *
f = CurrentFont()
for i in f.selection:
w = 1000 - f[i].width
f[i].leftMargin += w/2
f[i].rightMargin += w/2
f.update()
from robofab.world import *
f = AllFonts()
unis = [i.unicode for i in f[0]]
for i in f[1]:
if i.unicode in unis:
i.mark = 1