Skip to content

Instantly share code, notes, and snippets.

View arialcrime's full-sized avatar

Benedikt Bramböck arialcrime

View GitHub Profile
#MenuTitle: Uppercase
# -*- coding: utf-8 -*-
"""Converts the selected text to upppercase."""
Doc = Glyphs.currentDocument
Font = Glyphs.font
Doc = Glyphs.currentDocument
TextStoreage = Doc.windowController().activeEditViewController().graphicView().textStorage()
String = TextStoreage.text().string()
Range = TextStoreage.selectedRange()
@arialcrime
arialcrime / lowercase.py
Last active August 29, 2015 14:24
lowercase.py
#MenuTitle: Lowercase
# -*- coding: utf-8 -*-
"""Converts the selected text to lowercase."""
Doc = Glyphs.currentDocument
Font = Glyphs.font
Doc = Glyphs.currentDocument
TextStoreage = Doc.windowController().activeEditViewController().graphicView().textStorage()
String = TextStoreage.text().string()
Range = TextStoreage.selectedRange()
@arialcrime
arialcrime / LockZoomObserver.py
Created March 17, 2018 13:49
Observer to lock zoom level in Robofont
from mojo.UI import CurrentGlyphWindow
from mojo.events import addObserver
class LockZoomObserver:
def __init__(self):
addObserver(self, "ZoomObserver", "modifiersChanged")
def ZoomObserver(self, info):
gw = CurrentGlyphWindow()
viewScale = gw.getGlyphViewScale()
@arialcrime
arialcrime / SampleWordChecker.py
Last active March 30, 2018 12:07
A small script to check if all characters from A-Z and a-z are being used in a given amount of sample words.
import string
# to check for uppercase as well, just uncomment in line 4
wanted = string.ascii_lowercase #+ string.ascii_uppercase
used = 'Insert words here'
used = used.replace(' ', '')
list(used)
required = [letter for letter in wanted if letter not in used]
required = ''.join(required)
print ('STILL MISSING:\n' + required)
@arialcrime
arialcrime / FindMissingGlyphsInFonts.py
Created September 2, 2018 12:02
Quick script to check glyph sets of fonts against each other
from mojo.UI import GetFile
font_paths = GetFile(allowsMultipleSelection=True)
fonts = FontsList()
for font_path in font_paths:
f = OpenFont(font_path, showInterface=False)
fonts.append(f)
glyph_set_dict = {}
# in the current font
# add lowercase unicodes to uppercase characters
# requires compositor for mapping uppercase to lowercase, https://github.com/typesupply/compositor
from compositor.caseConversionMaps import upperToSingleLower
f = CurrentFont()
for g in f:
@arialcrime
arialcrime / NameGenerator.py
Created December 17, 2018 15:47
Generates a number of “names” following vowel/consonants-pattern
import string, random
v = 'aeiou'
c = string.ascii_lowercase
c = [l for l in c if l not in v]
d = dict(v = list(v),c = list(c))
wordNum = 300
pattern = 'cvcvc'
@arialcrime
arialcrime / FindLowercaseGlyphs.py
Last active April 19, 2019 17:35
Gets you the length of a list containing lowercase glyph names
font = CurrentFont()
all_glyphs = font.glyphOrder
lc_list = []
exceptions = ['germandbls','dotlessi','dotlessj','napostroph']
case_extension = '.uc'
for glyph_name in all_glyphs:
lc_glyph = None
if glyph_name[0].isupper() or glyph_name in exceptions:
@arialcrime
arialcrime / Store_glyph_info_in_glyphsapp_file.py
Created May 14, 2019 10:47
Finds all target script glyphs and adds Script, Category and Subcategory to the glyphs file
# in the current font
# add script, category and subcategory to glyphs matching “target_script”
# this enables exchange between people using non-standard glyph names
# TODO: could also work with selection
# Set target script
# initiate collection list
target_script = "arabic"
glyphs_to_store = []
@arialcrime
arialcrime / Generate_UFO_instances.py
Created August 1, 2019 14:39
Creates UFO files of all instances with production names.
#MenuTitle: Generate UFO instances
# -*- coding: utf-8 -*-
from __future__ import print_function
__doc__="""
Creates UFO files of all instances with production names.
"""
import os