forked from PriaRavichandran/Glyphs-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport InDesign Tagged Text (tabbed).py
More file actions
executable file
·54 lines (42 loc) · 2.14 KB
/
Copy pathExport InDesign Tagged Text (tabbed).py
File metadata and controls
executable file
·54 lines (42 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#MenuTitle: Export InDesign Tagged Text with All Glyphs (tabbed)
# -*- coding: utf-8 -*-
__doc__="""
Saves InDesign tagged text file that contains all glyphs for typesetting a specimen, using glyph ID. This is a better solution than generating ss20 feature.
"""
import GlyphsApp
import os.path
thisFont = Glyphs.font # frontmost font
thisFontMaster = thisFont.selectedFontMaster # active master
selectedLayers = thisFont.selectedLayers # active layers of selected glyphs
thisDoc = Glyphs.currentDocument
instanceList = []
for thisInstance in thisFont.instances:
if thisInstance.active:
instanceList.append(thisInstance.name)
glyphCount = 0
for glyph in thisFont.glyphs:
if glyph.export:
glyphCount += 1
for instance in instanceList:
paraStyleName = "%s %s 12pt" % (thisFont.familyName, instance)
header = "<ASCII-MAC>\n<Version:7.5><FeatureSet:InDesign-Roman><ColorTable:=<Black:COLOR:CMYK:Process:0,0,0,1>>\n<DefineParaStyle:%s=<cSize:12.000000><cTypeface:%s><cFont:%s><cOTFContAlt:0>>\n" % (paraStyleName, instance, thisFont.familyName)
counter = 0
line = ""
for i in range(glyphCount-1):
line += "<ParaStyle:%s><cSpecialGlyph:%s><0xFFFD>\t" % (paraStyleName, i+1)
counter += 1
if counter == 28:
line = line [:-1]
line += "\n"
counter = 0
try:
directory = "the same folder as the working file"
dirPath = os.path.dirname(thisFont.filepath)
except:
directory = "the Documents folder, because the source is not a saved Glyphs file"
dirPath = os.path.abspath(os.path.expanduser("~/") + '/Documents')
filePath = os.path.abspath(dirPath+"/InDesign Tagged Text - %s %s.txt" % (thisFont.familyName, instance))
with open(filePath, 'w') as thisFile:
thisFile.write(header+line)
thisFile.close
Glyphs.displayDialog_(u'Tagged text files saved in %s (overwitten existing tagged texts if they exist). Please follow the instruction:\n\n1. Generate the font and make it available in InDesign (okay to do it before running this script).\n\n2. In InDesign, have a document open. Go to "File > Place", choose the generated text file, and place it somewhere in the document.\n\n3. Voilà! Now you have all glyphs, referred to in Glyph ID.' % directory)