Skip to content

Instantly share code, notes, and snippets.

@mjlagattuta
mjlagattuta / fixBrackets.py
Last active March 10, 2022 04:31
Setup glyphs file with bracket layers for fontmake build, and generate a python file to run on the final ttf to add the feature vars
# Copyright 2019 Michael LaGattuta
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@raphlinus
raphlinus / decompose_var.py
Created December 7, 2019 20:01
Script to decompose components with mismatched 2x2 matrix
# Script to decompose components with mismatched 2x2 matrix
# See https://github.com/googlefonts/fontmake/issues/595
for glyph in Glyphs.font.glyphs:
#print glyph
xforms = []
mismatch = []
for (i, layer) in enumerate(glyph.layers):
for (j, component) in enumerate(layer.components):
if i == 0:
xforms.append(component.transform)
@letorbi
letorbi / fontsmoothie.js
Last active January 15, 2022 17:39
This code enforces font-smothing for web fonts even if it's not enabled in the system settings. More info: http://pixelsvsbytes.com/blog/2013/02/nice-web-fonts-for-every-browser
// Font Smoothie copyright 2013,14,15 Torben Haase <http://pixelsvsbytes.com>
// Source-URL <https://gist.github.com/letorbi/5177771>
//
// Font Smoothie is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// Font Smoothie is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
@fzero
fzero / 1 bashrc.sh
Last active August 4, 2021 00:06
My bash customizations with git-aware prompt and some aliases.
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Prompt goodness
#
# This is for my local machine, so I don't display the host to save space (I do on remote servers).
# It looks like this:
#
# ~/Code/some_dir(my-git-branch)$
#
@kylehowells
kylehowells / ast2text.py
Last active April 8, 2021 22:10
Extract the plain text from markdown, for plain text search.
import commonmark
with open('test.md', 'r') as myfile:
text = myfile.read()
parser = commonmark.Parser()
ast = parser.parse(text)
# Returns the text from markdown, stripped of the markdown syntax itself
def ast2text(astNode):
@anthrotype
anthrotype / scale_ufo.py
Last active June 4, 2020 14:39
Script that uses ufo2ft (>= 2.14) TransformationsFilter to scale the UPEM of a UFO
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@khaledhosny
khaledhosny / cldr-coverage.py
Last active May 8, 2020 15:49
Calculate font script and language coverage based on ICU exemplar data
# Copyright 2020 Khaled Hosny
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@leonbreedt
leonbreedt / FontPreview.swift
Last active July 13, 2018 02:43
Render font from command line on OS X without requiring font to be installed.
//
// FontPreview
// Copyright © 2018 Leon Breedt
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@gramian
gramian / hack4tex
Last active April 23, 2017 08:52
A small script to use the hack truetype font in pdflatex
#!/bin/sh
# hack4tex 0.1
# Copyright (c) 2016 Christian Himpe
# released under BSD 2-Clause License ( opensource.org/licenses/BSD-2-Clause )
# based on Stephan Lehmke's answer to "How do I use TrueType Fonts with PDFTeX
# using otftotfm?" on tex.stackexchange.com/a/52902
#
# requires otftotfm which is part of lcdf-typetools
#
# design settings
gutter = 60
radius = 6
pageW = 1600
# draw filled outline or contours
contour = False
# draw nodes and bluezones and vertical metrics?