Skip to content

Instantly share code, notes, and snippets.

@gferreira
gferreira / markdownDB.py
Last active May 7, 2026 10:32
setting markdown text with CSS styles using DrawBot FormattedString
import AppKit
import markdown
from string import Template
htmlTemplate = Template("""\
<html>
<head>
<meta charset="UTF-8">
<style>
$cssCode
@typoman
typoman / pdf-imposer-drawbot.py
Created December 29, 2025 11:51
Tile a PDF for printing or PDF imposer in drawbot app
path = 'file.pdf'
w, h = imageSize(path, pageNumber=1)
points_to_mm = 25.4 / 72
mm_to_points = 72 / 25.4
bleed = 3 * mm_to_points # bleed size of the original PDF
margin = 5 * mm_to_points # margin size in the final export to display the bleed marks
canvas_w = w * 2 + margin * 2
canvas_h = h * 2 + margin * 2
count = numberOfPages(path)
print(f"Number of pages: {count}")
@connordavenport
connordavenport / open_font_with_ttx.py
Created June 17, 2025 16:33
a plugin for sublime text to open and edit a binary font as a ttx file
import sublime
import sublime_plugin
import os
import tempfile
from fontTools import ttx
PREFIX = ".st3_ttx."
SFNT_SUFFIXES = ".otf .ttf .woff .woff2".split(" ")
class OpenTTX(sublime_plugin.EventListener):
@typoman
typoman / Fix Contour Directions.py
Last active June 12, 2025 13:34
RoboFont script to fix contour direction for postscript curves (CFF/Cubic/OTF) on selected glyphs.
"""
RoboFont Script
based on:
https://gist.github.com/ryanbugden/a4ddf19cab034f837a51fb9d4f0db015
- Type: Mastering
- Purpose: To fix contour direction for postscript curves (CFF/Cubic/OTF) in selected glyphs.
- Specifications:
- Sorts contours by area and clusters them into contours that contain other contours
- Reverses the direction of contours in clusters where the largest contour is not clockwise
@typemytype
typemytype / markdownNSAttributedString.py
Created July 27, 2023 11:17
markdown with NSAttributedString for drawBot
md = """
# title
## sub title
*foo*
__italic foo__
[our website](https://example.com).
@connordavenport
connordavenport / drawbotMarkdown.py
Last active May 5, 2026 19:44
A WIP script to add markdown functionality to DrawBot.
import re
sampleText = '''
A spectre is haunting [Europe](www.robofont.com) — the spectre of **communism**. All the __powers of old Europe have__ entered into a holy alliance to exorcise this spectre: Pope and Tsar, Metternich and Guizot, French Radicals and German police-spies.
Where is the party in opposition that has not been decried as communistic by its opponents in power? Where is the opposition that has not hurled back the branding reproach of **communism**, against the more advanced opposition parties, as well as against its reactionary adversaries?
Two things result from this fact:
I. **Communism** is *already acknowledged* by all _European_ powers to be itself a power.

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?

@typesupply
typesupply / merzHitTestTest.py
Last active May 7, 2026 10:35
Test Merz hit testing with a glyph editor.
from mojo.events import BaseEventTool, installTool
backgroundColor = (1, 1, 0, 0.5)
mouseDownColor = (0, 0, 0, 0.25)
defaultSymbolSettings = dict(
name="oval",
size=(20, 20),
fillColor=(1, 0, 0, 0.75),
strokeColor=(1, 1, 1, 0.5),
strokeWidth=10
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
@connordavenport
connordavenport / RContourRSegment_interpolate.py
Created March 5, 2021 15:50
A startup script that adds interpolate() functions to RContour RSegment objects. There is also a faux RSegment.copy() function.
from fontParts.base.errors import FontPartsError
from fontPens.digestPointPen import DigestPointStructurePen
def isStrictCompatible(path1,path2):
# check interpolation compatibility
if type(path1).__name__.split(".")[-1] == "RSegment":
if path1.type == path2.type: