Skip to content

Instantly share code, notes, and snippets.

@typemytype
typemytype / rotateSubscribers.py
Created April 10, 2024 15:59
RoboFont subscriber to rotate both the glyph view and space center to help out drawing Mongolian, where the letter shapes are stored in binaries 90° rotated.
"""
RoboFont subscriber to rotate both the glyph view and space center to help out drawing Mongolian,
where the letter shapes are stored in binaries 90° rotated.
"""
from AppKit import NSNotificationCenter, NSViewFrameDidChangeNotification
import ezui
from mojo.subscriber import Subscriber, registerSpaceCenterSubscriber, unregisterSpaceCenterSubscriber, registerGlyphEditorSubscriber, unregisterGlyphEditorSubscriber, WindowController
from mojo.tools import CallbackWrapper
@typemytype
typemytype / RemoveGlyphLayersSubscriber.py
Created March 27, 2024 17:13
add contextual menu to remove all glyph layer data for the selected glyphs
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
class RemoveGlyphLayersSubscriber(Subscriber):
debug = True
def fontOverviewWantsContextualMenuItems(self, items):
if items["itemDescriptions"]:
items["itemDescriptions"].append("---")
@typemytype
typemytype / tabCollector.py
Last active January 18, 2024 09:19
Collect windows by the type of window in RoboFont
import vanilla
import AppKit
class WindowTabCollector:
windowNames = [
"GlyphWindow",
"FontWindow",
"SpaceCenter",
"ScriptingWindow",
@typemytype
typemytype / glyphLineController.py
Last active August 28, 2023 11:13
show multiple glyphs in a glyph editor RF4
# this scripts add a input field at the top of your glyph window
# the input text is converted to a list of glyphs objects
# and set into the glyph editor
# jump around with `esc` and select to edit by hitting a glyph
from mojo.UI import GlyphSequenceEditText
from mojo.subscriber import Subscriber, registerGlyphEditorSubscriber
class GlyphLineController(Subscriber):
@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).
# menuTitle : Headless RoboFont
import os
import AppKit
import ezui
from mojo.extensions import getExtensionDefault, setExtensionDefault
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo.UI import AskString, OpenGlyphWindow, OpenSpaceCenter, OpenFontInfoSheet
defaults_key = 'com.typemytype.headLessRoboFont.glyphName'
@typemytype
typemytype / launcher.py
Last active February 15, 2023 01:17
Set this script as start up script to popup a window listing all recent files
# written by Tal Leming, posted in the RoboFont Community slack
import pathlib
import AppKit
import ezui
from mojo.subscriber import Subscriber, registerRoboFontSubscriber
from mojo import roboFont
from mojo.UI import OpenScriptWindow
roboFontIcon = AppKit.NSApp().applicationIconImage()
@typemytype
typemytype / cssClippathPolygon.py
Created January 27, 2023 21:16
Glyph to css clippath polygon
"""
draw a shape
useage in clip-path: polygon(...);
"""
glyph = CurrentGlyph()
for contour in glyph:
#!/usr/bin/env python3
"""
based on
https://github.com/andrejbauer/slack-to-discord
!slackpreview
!slackimport
import os
import discord
from discord.ext import commands
TOKEN = os.getenv("BOOKMARK_BOT_TOKEN")
intents = discord.Intents.default()
intents.message_content = True
intents.reactions = True
client = discord.Client(intents=intents)