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
# coding: utf-8 | |
import pprint | |
from fontTools import agl | |
characters = u'Loïc Sander Nick Sherman Tânia Raposo Frank Grießhammer' | |
for char in characters: | |
# ord(char) is the decimal Unicode value for a given character | |
# agl.UV2AGL is a dictionary that maps those Unicode values to glyph names | |
print(agl.UV2AGL.get(ord(char))) | |
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
# IPA | |
( 0028 | |
) 0029 | |
. 002E | |
/ 002F | |
[ 005B | |
] 005D | |
a 0061 | |
b 0062 | |
c 0063 |
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.UI import CurrentFontWindow | |
import unicodedata | |
import AppKit | |
from vanilla import CheckBox, FloatingWindow, List | |
category_to_codepoints = {} | |
for code_point in range(0, 0xFFFF + 1): | |
category = unicodedata.category(chr(code_point)) |
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
# use absolute or relative path. This can be OTF or TTF. | |
font_path = 'my_font.otf' | |
# set the current font to be the one specified above, so we can list its glyph names: | |
font(font_path) | |
# loop through the list of glyph names: | |
for gid, g_name in enumerate(listFontGlyphNames()): | |
# the new page is 1000 by 1000 points by default | |
newPage() | |
fs = FormattedString( | |
font=font_path, |
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
''' | |
## anchorBaby.py | |
RoboFont script for keeping anchors consistent. | |
Inspired by an idea from James T. Edmondson, this script will take note of | |
anchor movement in a given glyph, and replicate that movement in all | |
dependent glyphs. | |
For instance, if a font has the glyphs `a` `a.init` and `a.fina`; and all three |
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
# Simple align points script for Robofont. | |
# I have set this to shortcut ctrl-a | |
def average(coord_list): | |
coord_sum = sum(coord_list) | |
return int(round(coord_sum / len(coord_list))) | |
def distance(coord_list): |
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 | |
a = AllFonts() | |
class GlyphPoints(object): | |
def __init__(self, glyph): | |
point_list = [ | |
point for contour in glyph.contours for point in contour.points] | |
self.name = glyph.name | |
self.xPoints = [point.x for point in point_list] |
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( |
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
f = CurrentFont() | |
x_height_scale = 1.05 | |
ascender_scale = 0.98 | |
descender_scale = 0.88 | |
hor_scale_factor_lc = 1.12 | |
hor_scale_factor_uc = 1.1 | |
lime = (0.502, 1.0, 0.0, 1.0) | |
f.info.xHeight = int(round(x_height_scale * f.info.xHeight)) |
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
# this script is assumed to live in the directory https://github.com/typekit/speakeasy/tree/master/data | |
import os | |
import re | |
def get_code_points(language_file): | |
with open(language_file, 'r') as f: | |
raw_data = f.read().splitlines() | |
split_index = raw_data.index('---') + 5 | |
data = raw_data[split_index:] |