Skip to content

Instantly share code, notes, and snippets.

@roberto-arista
Created February 25, 2015 09:24
Show Gist options
  • Save roberto-arista/a3b3d286ecb2cd308529 to your computer and use it in GitHub Desktop.
Save roberto-arista/a3b3d286ecb2cd308529 to your computer and use it in GitHub Desktop.
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