Skip to content

Instantly share code, notes, and snippets.

View typoman's full-sized avatar
:electron:
Never stop learning!

Bahman Eslami typoman

:electron:
Never stop learning!
View GitHub Profile

OpenType font name table notes

Provided are the name table record ID and instructions on how to fill it out. Arial is used as an example to show how the names records can be filled. You can see the example records here:

https://learn.microsoft.com/en-us/typography/opentype/spec/namesmp

There are also more exmaples added to the bottom of this file.

Why this document?

@typoman
typoman / intersectPen.py
Created February 7, 2024 16:58
Get intersection points of list of lines with a glyph in a font
from fontTools.pens.basePen import BasePen
from fontTools.misc.bezierTools import calcCubicParameters, solveCubic, _alignment_transformation, cubicPointAtT, _line_t_of_pt, linePointAtT
def _curve_line_intersections_t(curve, line):
aligned_curve = _alignment_transformation(line).transformPoints(curve)
a, b, c, d = calcCubicParameters(*aligned_curve)
intersections = solveCubic(a[1], b[1], c[1], d[1])
return sorted(i for i in intersections if 0.0 <= i <= 1)
def curveLineIntersections(curve, line):
from mojo.UI import *
"""
RoboFont Script
- Type: Composites
- Purpose: To create RoboFont glyph construction syntax out of the exisiting
composites inside a font using the anchor names.
- Specifications:
- Determines the base letter and marks according to anchor names.
- Reconstruct the glyphConstruction syntax from the anchor names.
- Publish Date: 7 Dec 2020
@typoman
typoman / backup-im-vi-sh
Last active September 28, 2023 16:46
Backup proxy of images and videos
#!/bin/bash
# Use this if you want to make a copy of your images and viodes with
# siginficant reduced size. This bash script duplicates the folder structure
# of all the sub folders underneath the current folder, and puts images and
# videos there. It also redcues the size of images and creates screenshots of
# videos instead of copying the resized video. Run it inside the folder that
# contains all your images, it will create another folder next to it and put
# the images and videos with reduced size there.
@typoman
typoman / addSnippet.py
Last active September 21, 2023 16:28
UI form for adding snippets to espanso
import os
import sys
"""
Add {cb} anywhere inside the replacement to make it replaced with the contents
of the clipboard.
"""
transMap = str.maketrans({
"\n": '\\n',
"\\": '\\\\',
"\"": '\\"',
@typoman
typoman / expand-groups-to-components.py
Last active June 17, 2023 16:07
A RoboFont script to expand kerning groups from base glyph to their composites.
from simpleKerning import *
"""
A RoboFont script to expand kerning groups from base glyph to their composites.
1. Select the composites which are not grouped
2. Run the script
3. The groups will be expanded to the composites, if:
- Their width is same as the base glyph
- They're not already grouped
"""
@typoman
typoman / robofont-key-binding-doom-emacs-config.el
Last active April 14, 2023 17:07
Run the script from doom emacs inside RoboFont using the key sequence "leader r f"
(defun run-robofont ()
"Run current python file inside roboFont."
(interactive)
(when (eq major-mode 'python-mode)
(let ((file-path (buffer-file-name)))
(when file-path
(shell-command (concat "roboFont '" file-path "';open '/Applications/RoboFont.app'"))))))
(map! :map python-mode-map
:leader
@typoman
typoman / toggle_nonExport.py
Created January 24, 2023 15:23 — forked from ryanbugden/toggle_nonExport.py
Go through all selected glyphs, and change whether they are set to export or non-export, based on the opposite of the state of the first glyph.
# menuTitle: Skip Export - Mass Toggle Selected
# source: https://gist.github.com/ryanbugden/7f20d42ef45ed0d657ad4f744bf9a373#file-toggle_nonexport-py
'''
Go through all selected glyphs, and change whether they are set to export or non-export, based on the opposite of the state of the first glyph.
2021.10.28
'''
f = CurrentFont()
@typoman
typoman / roboFontCompDoubleClick.py
Last active May 21, 2022 09:56
RoboFont startup script to enable jump to base glyph of componets by double clicking on the component in glyph view.
from defconAppKit.windows.baseWindow import BaseWindowController
from vanilla import FloatingWindow
from mojo.events import addObserver, removeObserver
from mojo.UI import SetCurrentGlyphByName
"""
RoboFont Helper
Type: Start up
Purpose: After it's run, if you double click on a component it will jump to its base glyph.
"""
@typoman
typoman / update-composite-metrics.py
Last active January 28, 2022 14:32
Updates composites margins based on the base letter margins.
"""
RoboFont Script
- Type: Composite/Margins
- Purpose: Updates composites (a glyph which **only** has components e.g accented
letters) margins based on the base letter margins.
- Specifications:
- Determines the base letter according to (in order): unciode,
anchor names, glyph surface area (the darkest shape is the letter),
glyph width (if it's zero then it's accent).
- If the base letter is shifted in the composte (mostly by accident), it