Skip to content

Instantly share code, notes, and snippets.

"""
Generate variable fonts with fontmake from .glyphs sources.
Script traverses a directory tree and will generate var fonts if it
encounters a .glyphs file with at least 2 masters and more than 3
instances, if directory matches the repository GF-Checklist spec:
https://github.com/googlefonts/gf-docs/blob/master/ProjectChecklist.md
"""
import glyphsLib
from fontTools.ttLib import TTFont
import csv
import os
import re
from ntpath import basename
gf_dir = '/Users/marc/Documents/googlefonts/fonts'
gf_repo_file = open('/Users/marc/Documents/googlefonts/gf_doc_patches/GF_Upstream_Repos - Sheet1-4.csv')
@m4rc1e
m4rc1e / ofl_check.py
Created June 6, 2017 14:23
Check the OFL.txt files in the gf repo are good
"""
For each OFL.txt file, if there is not a double linebreak after the firt
line, add it.
e.g:
Before:
Copyright 2017 The Manuala Project Authors (http:www.gitrepo.com)
import csv
import json
from fontTools.ttLib import TTFont
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
return list(obj)
return json.JSONEncoder.default(self, obj)
@m4rc1e
m4rc1e / github_reporter.py
Created June 28, 2017 16:39
Report how many issues/prs were opened and closed for a specific Github repository between two dates.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Report how many issues/prs were opened and closed for a specific
Github repository between two dates.
Examples:
Issues between 2017-01-01 to 2017-06-01:
python github_reporter.py <user> <pass> pallets/flask 2017-01-01 2017-06-01
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="3.13">
<GDEF>
<Version value="0x00010000"/>
<GlyphClassDef Format="0">
<ClassDef glyph="A" class="1"/>
<ClassDef glyph="A.ss01" class="1"/>
<ClassDef glyph="AE" class="1"/>
<ClassDef glyph="AEacute" class="1"/>
@m4rc1e
m4rc1e / post_img_imgur.py
Created February 2, 2018 11:25
Anonymously post an image to imgur v3 api
import requests
import json
img_path = 'foo/img_path.jpg'
r = requests.post('https://api.imgur.com/3/image',
data={'image': open(img_path, 'rb').read(), 'type': 'file' },
headers = {'Authorization': 'Client-ID {{Your-CLIENT-ID}}'}
)
print r.json()
"""
Flatten a font's GPOS kerning.
"""
from fontTools.ttLib import TTFont
def _kerning_lookup_indexes(ttfont):
"""Return the lookup ids for the kern feature"""
for feat in ttfont['GPOS'].table.FeatureList.FeatureRecord:
if feat.FeatureTag == 'kern':
@m4rc1e
m4rc1e / Kern_Modified.txt
Created May 8, 2018 12:35
Diffenator results for MarkaziText Test
ﻻﴅ ﻻﺻﺊ ﻻﴆ ﻻﺻ ﻻصي ﻻبي ﻻﺑﺊ ﻻﰊ ﻻﰉ ﻻﺑ ﻻﻇﻲ ﻻغي ﻻﳷ ﻻﳶ ﻻﳵ ﻻﴇ ﻻﻃ ﻻطي ﻻظي ﻻﻇﺊ ﻻﻏﺊ ﻻﻋﺊ ﻻﴈ ﻻﻇﻰ ﻻضي ﻻﺿﺊ ﻻﳺ ﻻﳹ ﻻﺿ ﻻﻇ ﻻعي ﻻﻃﺊ ﻻﳸ ’ ” 7 ﻻﱓ ﻻﱔ ﻻﳽ ﻻﺷ ʻ ﻻﺳﺊ ﻻﺷﺊ ‘ ﻻﳻ ﻻﳾ ﻻﳼ ﻻﺳ ﻻﻫ ﻻشي “ ﻻهي ﻻسي ﻻﻫﺊ
# -*- coding: utf-8 -*-
import requests
r = requests.get('https://api.github.com/repos/google/fonts/issues?milestone=2&per_page=100')
print('Title,Url,Date')
for issue in r.json():
if not issue['closed_at']:
print('{},{},{}'.format(issue['title'], issue['html_url'], issue['created_at']))