Skip to content

Instantly share code, notes, and snippets.

@simoncozens
simoncozens / hands-face-space.ipynb
Last active April 19, 2025 06:32
Hands, Face, Space
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simoncozens
simoncozens / popularity.json
Created June 16, 2021 13:57
Popularity of OpenType feature tags in the Google Fonts database
{
"font_total": 3833,
"kern": 3162,
"liga": 2586,
"frac": 2579,
"sups": 2541,
"mark": 2531,
"aalt": 2518,
"ordn": 2494,
"locl": 2463,
#include <stdio.h>
#include "hb.hh"
uint64_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)] = { 0,0,0,0,0};
uint64_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (uint64_t) - 1) / sizeof (uint64_t)];
#include "main-font-text.hh"
#include "hb-open-type.hh"
#define HB_DEBUG 100
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simoncozens
simoncozens / proof-headlines.py
Created March 5, 2021 13:28
A quick and dirty bit of python to dump out headlines containing certain characters
import requests
from urllib.parse import urlencode
languages = ["en"]
doneglyphs = " ABCDEFGHIJKLMNOPRQSTUVXYZabcdefghijklmnopqrstuvwxyz0123456789.,-"
API_TOKEN = "Use your own, not mine."
def get_a_page_of_headlines(page):
params = urlencode(
{"api_token": API_TOKEN, "languages": ",".join(languages), "page": page}
# Dot a Glyph
# Copyright 2019 Simon Cozens
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# Dot a Glyph
from fontTools.ttLib import TTFont
from beziers.path import BezierPath
from beziers.path.representations.fontparts import FontParts
from fontParts.world import *
from beziers.point import Point
from beziers.path.geometricshapes import Circle
import sys
@simoncozens
simoncozens / cmap-survey.py
Created July 10, 2020 10:44
Survey CMAP tables of installed fonts
from fontTools.ttLib import TTFont
import glob
from tabulate import tabulate
import os
import random
paths = [
os.path.expanduser("~/Library/Fonts"),
"/Library/Fonts",
from tensorfont.dataset import prepare_training_data
from tensorfont.generators import RandomPair
prepare_training_data()
def kern_generator():
rpg = RandomPair(196, 196, 76, "training")
gen = rpg.generator()
while True:
font, left, right = next(gen)
img1, perturbation = rpg.get_image(font, left, right, perturbation_range= [-100,100])
@simoncozens
simoncozens / interrofont.py
Created April 3, 2020 11:18
Interrofont: Show various data about a font from the command line
#!env python3
import sys
from fontTools.ttLib import TTFont
from argparse import ArgumentParser
import itertools
parser = ArgumentParser()
parser.add_argument("input",
help="font file to process", metavar="FILE")
parser.add_argument('-n', "--name", action='store_true',