Editorial Workflows

Custom Font

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Experimental workflow for using system fonts that don't show up in Editorial's settings.

PLEASE READ THE INSTRUCTIONS AND WARNINGS CAREFULLY (shown when running the workflow).

Requires Editorial 1.3

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Show Alert ?
Title
WARNING
Message
This is an experimental workflow. It is possible that some fonts will crash Editorial, or even prevent it from launching. This is not likely, but it's not tested with all possible combinations. In particular, if you select a custom font for headings, you should NOT touch the "bold" and "italic" options for headings in Editorial's normal settings. This is known to cause crashes with a lot of fonts.
Button 1
OK
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Run Python Script ?
Source Code
#coding: utf-8
import dialogs
from objc_util import *

@on_main_thread
def notify_settings_changed():
	center = ObjCClass('NSNotificationCenter').defaultCenter()
	notification = 'SettingsControllerChangedEditorSettingsNotification'
	center.postNotificationName_object_(notification, None)

font_names = []
UIFont = ObjCClass('UIFont')
defaults = ObjCClass('NSUserDefaults').standardUserDefaults()
family_names = list(UIFont.familyNames())
for family in family_names:
	names = UIFont.fontNamesForFamilyName_(family)
	for n in names:
		font_names.append(str(n))
font_names.sort()

try:
	s = dialogs.alert('Custom Font Setting (Experimental!)', 'Set custom font for...', 'Text (Markdown)', 'Headings (Markdown)', 'Text (Plain)')
	font = dialogs.list_dialog('Text Font', font_names)
	key = {1: 'MarkdownTextFontName', 2: 'MarkdownHeadingFontName', 3: 'PlainTextFontName'}[s]
	if font is not None:
		defaults.setObject_forKey_(font, key)
		if key == 'MarkdownHeadingFontName':
			defaults.setBool_forKey_(False, 'MarkdownHeadingFontBold')
			defaults.setBool_forKey_(False, 'MarkdownHeadingFontItalic')
		notify_settings_changed()
except KeyboardInterrupt:
	pass