summaryrefslogtreecommitdiffstats
path: root/docs/examples.md
blob: de5212b73c1664ce09ef11279ec3703032ca9cee (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# Pysilfont example scripts

In addition to the main pysilfont [scripts](scripts.md), there are many further scripts under pysilfont/examples and its sub-directories.

They are not maintained in the same way as the main scripts, and come in many categories including:

- Scripts under development
- Examples of how to do things
- Deprecated scripts
- Left-overs from previous development plans!

Note - all FontForge-based scripts need updating, since FontForge (as "FF") is no longer a supported tool for execute()

Some are documented below.

## Table of scripts

| Command | Status | Description |
| ------- | ------ | ----------- |
| [accesslibplist.py](#accesslibplist) | ? | Demo script for accessing fields in lib.plist |
| [chaindemo.py](#chaindemo) | ? | Demo of how to chain calls to multiple scripts together |
| [ffchangeglyphnames](#ffchangeglyphnames) | ? | Update glyph names in a ttf font based on csv file |
| [ffcopyglyphs](#ffcopyglyphs) | ? | Copy glyphs from one font to another, without using ffbuilder |
| [ffremovealloverlaps](#ffremovealloverlaps) | ? | Remove overlap on all glyphs in a ttf font |
| [FFmapGdlNames.py](#ffmapgdlnames) | ? | Write mapping of graphite names to new graphite names |
| [FFmapGdlNames2.py](#ffmapgdlnames2) | ? | Write mapping of graphite names to new graphite names |
| [FLWriteXml.py](#flwritexml) | ? | Outputs attachment point information and notes as XML file for TTFBuilder |
| [FTaddEmptyOT.py](#ftaddemptyot) | ? | Add empty Opentype tables to ttf font |
| [FTMLnorm.py](#ftmlnorm) | ? | Normalize an FTML file |
| [psfaddGlyphDemo.py](#psfaddglyphdemo) | ? | Demo script to add a glyph to a UFO font |
| [psfexpandstroke.py](#psfexpandstroke) | ? | Expands an unclosed UFO stroke font into monoline forms with a fixed width |
| [psfexportnamesunicodesfp.py](#psfexportnamesunicodesfp) | ? | Outputs an unsorted csv file containing the names of all the glyphs in the default layer |
| [psfgenftml.py](#psfgenftml) | ? | generate ftml tests from glyph_data.csv and UFO |
| [psftoneletters.py](#psftoneletters) | ? | Creates Latin script tone letters (pitch contours) |
| [xmlDemo.py](#xmldemo) | ? | Demo script for use of ETWriter |


---
#### accesslibplist
Usage: **` python accesslibplist.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Demo script for accessing fields in lib.plist


---
#### chaindemo
Usage: **` python chaindemo.py ...`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

Demo of how to chain calls to multiple scripts together.
Running

`python chaindemo.py infont outfont --featfile feat.csv --uidsfile uids.csv`

will run execute() against psfnormalize, psfsetassocfeat and psfsetassocuids passing the font, parameters
and logger objects from one call to the next.  So:
- the font is only opened once and written once
- there is a single log file produced


---
#### ffchangeglyphnames
Usage: **`ffchangeglyphnames [-i INPUT] [--reverse] ifont [ofont]`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

Update the glyph names in a ttf font based on csv file.

Example usage:

```
ffchangeglyphnames -i glyphmap.csv font.ttf
```
will update the glyph names in the font based on mapping file glyphmap.csv

If \-\-reverse  is used, it change names in reverse.

---
####  ffcopyglyphs
Usage: **`ffcopyglyphs -i INPUT [-r RANGE] [--rangefile RANGEFILE] [-n NAME] [--namefile NAMEFILE] [-a] [-f] [-s SCALE] ifont [ofont]`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

_This section is Work In Progress!_

optional arguments:

```
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Font to get glyphs from
  -r RANGE, --range RANGE
                        StartUnicode..EndUnicode no spaces, e.g. 20..7E
  --rangefile RANGEFILE
                        File with USVs e.g. 20 or a range e.g. 20..7E or both
  -n NAME, --name NAME  Include glyph named name
  --namefile NAMEFILE   File with glyph names
  -a, --anchors         Copy across anchor points
  -f, --force           Overwrite existing glyphs in the font
  -s SCALE, --scale SCALE
                        Scale glyphs by this factor
```

---
#### ffremovealloverlaps
Usage: **`ffremovealloverlaps ifont [ofont]`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

Remove overlap on all glyphs in a ttf font

---
#### FFmapGdlNames
Usage: **` python FFmapGdlNames2.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Write mapping of graphite names to new graphite names based on:
   - two ttf files
   - the gdl files produced by makeGdl run against those fonts
        This could be different versions of makeGdl
   - a csv mapping glyph names used in original ttf to those in the new font


---
#### FFmapGdlNames2
Usage: **` python FFmapGdlNames.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Write mapping of graphite names to new graphite names based on:
   - an original ttf font
   - the gdl file produced by makeGdl when original font was produced
   - a csv mapping glyph names used in original ttf to those in the new font
   - pysilfont's gdl library - so assumes pysilfonts makeGdl will be used with new font


---
#### FLWriteXml
Usage: **` python FLWriteXml.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Outputs attachment point information and notes as XML file for TTFBuilder


---
#### FTaddEmptyOT
Usage: **` python FTaddEmptyOT.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Add empty Opentype tables to ttf font


---
#### FTMLnorm
Usage: **` python FTMLnorm.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Normalize an FTML file


---
#### psfaddGlyphDemo
Usage: **` python psfaddGlyphDemo.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Demo script to add a glyph to a UFO font


---
#### psfexpandstroke

Usage: **`psfexpandstroke infont outfont expansion`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

Expands the outlines (typically unclosed) in an UFO stroke font into monoline forms with a fixed width.

Example that expands the stokes in a UFO font `SevdaStrokeMaster-Regular.ufo` by 13 units on both sides, giving them a total width of 26 units, and writes the result to `Sevda-Regular.ufo`.

```
psfexpandstroke SevdaStrokeMaster-Regular.ufo Sevda-Regular.ufo 13
```

Note that this only expands the outlines - it does not remove any resulting overlap.


---
#### psfexportnamesunicodesfp
Usage: **` python psfexportnamesunicodesfp.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Outputs an unsorted csv file containing the names of all the glyphs in the default layer and their primary unicode values.

Format name,usv


---
#### psfgenftml
Usage: **` python psfgenftml.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

generate ftml tests from glyph_data.csv and UFO


---
####  psftoneletters
Usage: **`psftoneletters infont outfont`**

_([Standard options](docs.md#standard-command-line-options) also apply)_

This uses the parameters from the UFO lib.plist org.sil.lcg.toneLetters key to create Latin script tone letters (pitch contours).

Example usage:

```
psftoneletters Andika-Regular.ufo Andika-Regular.ufo
```


---
#### xmlDemo
Usage: **` python xmlDemo.py ...`**

_([Standard options](docs.md#standard-command-line-options) may also apply)_

Demo script for use of ETWriter