Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding smart sets to Robofont
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#####################
# Adding smart sets #
#####################
### Modules
import os
from mojo.UI import SmartSet, addSmartSet
### Variables
input_sources_path = 'Sources'
### Functions, procedures, constants
def catchFilesAndFolders(path, extension):
items = [item for item in os.listdir(path) if item.endswith(extension)]
return items
### Instructions
txt_paths = catchFilesAndFolders(input_sources_path, '.txt')
for each_path in txt_paths:
setName = each_path.replace('.txt', '')[3:]
glyphs = open(input_sources_path + os.sep + each_path, 'r').readlines()
glyphs = [item.replace('\n', '') for item in glyphs if item.startswith('#') == False]
smartSet = SmartSet()
smartSet.name = setName
smartSet.glyphNames = glyphs
addSmartSet(smartSet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment