Skip to content

Commit 7843c80

Browse files
committed
update documentation
1 parent d505901 commit 7843c80

File tree

5 files changed

+238
-72
lines changed

5 files changed

+238
-72
lines changed

README.md

Lines changed: 97 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
[![codecov](https://codecov.io/gh/adobe-type-tools/python-modules/graph/badge.svg?token=Zeqzh6AHfO)](https://codecov.io/gh/adobe-type-tools/python-modules)
22

3-
Python modules
4-
==============
3+
AFDKO Python Modules
4+
====================
55

6-
These tools are used to write feature files which is be based on information found within UFO sources.
7-
The two main tools are `kernFeatureWriter.py` and `markFeatureWriter.py`.
6+
## `kernFeatureWriter.py`
7+
This tool exports the kerning and groups data within a UFO to a
8+
`makeotf`-compatible GPOS kern feature file.
89

9-
### `kernFeatureWriter.py`
10+
#### Default functionality:
1011

11-
```bash
12+
- writing of a sorted kern.fea file, which organizes pairs in order of
13+
specificity (exceptions first, then glyph-to-glyph, then group pairs)
14+
- filtering of small pairs (often results of interpolation).
15+
Exceptions (even though they may be small) are not filtered.
16+
- processing of right-to-left pairs (given that kerning groups containing
17+
those glyphs are suffixed with `_ARA`, `_HEB`, or `_RTL`)
1218

13-
# write out a kern feature file
19+
#### Optional functionality:
20+
21+
- dissolving single-element groups into glyph pairs – this helps with
22+
subtable optimization, and can be seen as a means to avoid kerning overflow
23+
- subtable measuring and automatic insertion of subtable breaks
24+
- specifying a maximum subtable size
25+
- identification of glyph-to-glyph RTL pairs by way of a global `RTL_KERNING`
26+
reference group
27+
- specifying a glyph name suffix for glyphs to be ignored when writing the
28+
kern feature
29+
30+
#### Usage:
31+
```zsh
32+
33+
# write a basic kern feature file
1434
python kernFeatureWriter.py font.ufo
1535

1636
# write a kern feature file with minimum absolute kerning value of 5
@@ -19,21 +39,75 @@ The two main tools are `kernFeatureWriter.py` and `markFeatureWriter.py`.
1939
# write a kern feature with subtable breaks
2040
python kernFeatureWriter.py -s font.ufo
2141

42+
# further usage information
43+
python kernFeatureWriter.py -h
44+
2245
```
2346

24-
### `markFeatureWriter.py`
47+
----
2548

26-
```bash
49+
## `markFeatureWriter.py`
50+
This tool interprets glyphs and anchor points within a UFO to write a
51+
`makeotf`-compatible GPOS mark feature file.
52+
53+
The input UFO file needs to have base glyphs and zero-width combining
54+
marks. Base- and mark glyphs attach via anchor pairs (e.g. `above` and
55+
`_above`, or `top`, and `_top`).
56+
Combining marks must be members of a `COMBINING_MARKS` reference group.
57+
58+
#### Default functionality:
59+
60+
- writing a `mark.fea` file, which contains mark classes/groups, and
61+
per-anchor mark-to-base positioning lookups (GPOS lookup type 4)
62+
- writing mark-to-ligature positioning lookups (GPOS lookup type 5).
63+
This requires anchor names to be suffixed with an ordinal (`1ST`, `2ND`,
64+
`3RD`, etc). For example – if a mark with an `_above` anchor is to be
65+
attached to a ligature, the ligature’s anchor names would be `above1ST`,
66+
`above2ND`, etc – depending on the amount of ligature elements.
67+
68+
#### Optional functionality:
69+
70+
- writing `mkmk.fea`, for mark-to-mark positioning (GPOS lookup type 6)
71+
- writing `abvm.fea`/`blwm.fea` files, as used in Indic scripts (anchor pairs
72+
are `abvm`, `_abvm`, and `blwm`, `_blwm`, respectively)
73+
- writing mark classes into a separate file (in case classes need to be
74+
shared across multiple lookup types)
75+
- trimming casing tags (`UC`, `LC`, or `SC`)
76+
77+
Trimming tags is a somewhat specific feature, but it is quite essential:
78+
In a UFO, anchors can be used to build composite glyphs – for example
79+
`aacute`, and `Aacute`. Since those glyphs would often receive a
80+
differently-shaped accent, the anchor pairs (on bases `a`/`A` and
81+
marks `acutecmb`/`acutecmb.cap`) would be `aboveLC`/`_aboveLC`, and
82+
`aboveUC/_aboveUC`, respectively.
83+
84+
When writing the mark feature, we care more about which group of combining
85+
marks triggers a certain behavior, so removing those casing tags allows
86+
grouping all `_above` marks together, hence attaching to a base glyph –
87+
no matter if it is upper- or lowercase. The aesthetic substitution of the
88+
mark (e.g. smaller mark on the uppercase letter) can happen later, in the
89+
`ccmp` feature.
90+
91+
#### Usage:
92+
```zsh
2793

2894
# write a basic mark feature
2995
python markFeatureWriter.py font.ufo
3096

3197
# write mark and mkmk feature files
3298
python markFeatureWriter.py -m font.ufo
3399

100+
# trim casing tags
101+
python markFeatureWriter.py -t font.ufo
102+
103+
# further usage information
104+
python markFeatureWriter.py -h
105+
34106
```
35107

36-
For both of these scripts, the resulting feature file only contains the raw feature data. This data can be used by means of an `include` statement:
108+
----
109+
110+
Both kern- and mark feature writers export raw feature data, which still needs to be wrapped with feature “fence”. This is easily achieved with an `include` statement:
37111

38112
```
39113
feature kern{
@@ -42,49 +116,31 @@ feature kern{
42116
} kern;
43117
```
44118

45-
The benefit of this is that different feature flags can be used, see for example https://github.com/adobe-fonts/source-serif/blob/main/familyGPOS.fea#L12-L13
46-
47-
48-
### `kernExport.py`
119+
The benefit of this is that different feature flags can be used (example)[https://github.com/adobe-fonts/source-serif/blob/main/familyGPOS.fea#L12-L13]. Also, the (sometimes volatile) GPOS feature data can be re-generated periodically without affecting the overal structure of the feature tree.
49120

50-
FontLab 5-Module to export FontLab class-kerning to UFO. It needs to be called with a FL font object (`fl.font`), and a prefixOption. The prefixOption is used for renaming kerning classes to various UFO-styles.
51121

52-
If the prefixOption is `None`, class names will be prefixed with to @L_ and @R_ to keep track of their side (in case they need to be re-imported into FL).
53-
54-
The prefixOptions are:
55-
`'MM'`: convert class names to MetricsMachine-compatible group names
56-
`'UFO3'`: convert to UFO3-style class names
57-
58-
usage:
59-
60-
```python
61-
62-
kernExport.ClassKerningToUFO(fl.font)
63-
kernExport.ClassKerningToUFO(fl.font, prefixOption='MM')
64-
kernExport.ClassKerningToUFO(fl.font, prefixOption='UFO3')
122+
----
65123

66-
```
124+
## [utilities (folder `/utilities`)](/utilities)
67125

68-
----
126+
* `kernExport.py`
127+
FLS5 script to export class kerning to UFO. Superseded by [vfb3ufo](https://github.com/LucasFonts/vfbLib).
69128

70-
## other modules (`/vintage` folder)
71129

72-
Other modules are FontLab scripts which were used in pre-UFO days in a FLS 5 environment. Those modules are not in active development.
130+
## [other modules (folder `/vintage`)](/vintage)
73131

74-
### `AdobeFontLabUtils.py`
132+
Other modules are FontLab scripts which were used in pre-UFO days in a FLS5 environment. Those modules are not in active development.
75133

134+
* `AdobeFontLabUtils.py`
76135
Support module for FontLab scripts. Defines commonly used functions and globals.
77136

78-
### `BezChar.py`
79-
137+
* `BezChar.py`
80138
This module converts between a FontLab glyph and a bez file data string. Used
81139
by the OutlineCheck and AutoHint scripts, to convert FL glyphs to bez programs
82140
as needed by C libraries that do the hard work.
83141

84-
### `WriteFeaturesKernFDK.py`
85-
86-
Kern feature writer.
87-
88-
### `WriteFeaturesMarkFDK.py`
142+
* `WriteFeaturesKernFDK.py`
143+
Former kern feature writer.
89144

90-
Mark feature writer.
145+
* `WriteFeaturesMarkFDK.py`
146+
Former mark feature writer.

kernFeatureWriter.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
#!/usr/bin/env python3
22

33
'''
4-
Kern Feature Writer for the FDK font production workflow.
4+
This tool exports the kerning and groups data within a UFO to a
5+
`makeotf`-compatible GPOS kern feature file.
56
6-
Optional functionality of this tool includes:
7+
#### Default functionality:
8+
9+
- writing of a sorted kern.fea file, which organizes pairs in order of
10+
specificity (exceptions first, then glyph-to-glyph, then group pairs)
11+
- filtering of small pairs (often results of interpolation).
12+
Exceptions (even though they may be small) are not filtered.
13+
- processing of right-to-left pairs (given that kerning groups containing
14+
those glyphs are suffixed with `_ARA`, `_HEB`, or `_RTL`)
15+
16+
#### Optional functionality:
17+
18+
- dissolving single-element groups into glyph pairs – this helps with
19+
subtable optimization, and can be seen as a means to avoid kerning overflow
720
- subtable measuring and automatic insertion of subtable breaks
8-
- dissolving of single-element groups into glyph pairs
9-
(helping with subtable optimization)
10-
- identify glyph-to-glyph RTL kerning
11-
(requirement: all RTL glyphs are part of a RTL-specific kerning group,
12-
or are members of the catch-all RTL_KERNING group)
21+
- specifying a maximum subtable size
22+
- identification of glyph-to-glyph RTL pairs by way of a global `RTL_KERNING`
23+
reference group
24+
- specifying a glyph name suffix for glyphs to be ignored when writing the
25+
kern feature
26+
27+
#### Usage:
28+
```zsh
29+
30+
# write a basic kern feature file
31+
python kernFeatureWriter.py font.ufo
1332
33+
# write a kern feature file with minimum absolute kerning value of 5
34+
python kernFeatureWriter.py -min 5 font.ufo
35+
36+
# write a kern feature with subtable breaks
37+
python kernFeatureWriter.py -s font.ufo
38+
39+
# further usage information
40+
python kernFeatureWriter.py -h
41+
42+
```
1443
'''
1544

1645
import argparse
@@ -22,13 +51,11 @@
2251

2352

2453
# constants
25-
2654
RTL_GROUP = 'RTL_KERNING'
2755
RTL_TAGS = ['_ARA', '_HEB', '_RTL']
2856

2957

3058
# helpers
31-
3259
def is_group(item_name):
3360
'''
3461
Check if an item name implies a group.

markFeatureWriter.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,63 @@
11
#!/usr/bin/env python3
22

33
'''
4-
Mark Feature Writer for the FDK font production workflow.
5-
4+
This tool interprets glyphs and anchor points within a UFO to write a
5+
`makeotf`-compatible GPOS mark feature file.
6+
7+
The input UFO file needs to have base glyphs and zero-width combining
8+
marks. Base- and mark glyphs attach via anchor pairs (e.g. `above` and
9+
`_above`, or `top`, and `_top`).
10+
Combining marks must be members of a `COMBINING_MARKS` reference group.
11+
12+
#### Default functionality:
13+
14+
- writing a `mark.fea` file, which contains mark classes/groups, and
15+
per-anchor mark-to-base positioning lookups (GPOS lookup type 4)
16+
- writing mark-to-ligature positioning lookups (GPOS lookup type 5).
17+
This requires anchor names to be suffixed with an ordinal (`1ST`, `2ND`,
18+
`3RD`, etc). For example – if a mark with an `_above` anchor is to be
19+
attached to a ligature, the ligature’s anchor names would be `above1ST`,
20+
`above2ND`, etc – depending on the amount of ligature elements.
21+
22+
#### Optional functionality:
23+
24+
- writing `mkmk.fea`, for mark-to-mark positioning (GPOS lookup type 6)
25+
- writing `abvm.fea`/`blwm.fea` files, as used in Indic scripts (anchor pairs
26+
are `abvm`, `_abvm`, and `blwm`, `_blwm`, respectively)
27+
- writing mark classes into a separate file (in case classes need to be
28+
shared across multiple lookup types)
29+
- trimming casing tags (`UC`, `LC`, or `SC`)
30+
31+
Trimming tags is a somewhat specific feature, but it is quite essential:
32+
In a UFO, anchors can be used to build composite glyphs – for example
33+
`aacute`, and `Aacute`. Since those glyphs would often receive a
34+
differently-shaped accent, the anchor pairs (on bases `a`/`A` and
35+
marks `acutecmb`/`acutecmb.cap`) would be `aboveLC`/`_aboveLC`, and
36+
`aboveUC/_aboveUC`, respectively.
37+
38+
When writing the mark feature, we care more about which group of combining
39+
marks triggers a certain behavior, so removing those casing tags allows
40+
grouping all `_above` marks together, hence attaching to a base glyph –
41+
no matter if it is upper- or lowercase. The aesthetic substitution of the
42+
mark (e.g. smaller mark on the uppercase letter) can happen later, in the
43+
`ccmp` feature.
44+
45+
#### Usage:
46+
```zsh
47+
48+
# write a basic mark feature
49+
python markFeatureWriter.py font.ufo
50+
51+
# write mark and mkmk feature files
52+
python markFeatureWriter.py -m font.ufo
53+
54+
# trim casing tags
55+
python markFeatureWriter.py -t font.ufo
56+
57+
# further usage information
58+
python markFeatureWriter.py -h
59+
60+
```
661
'''
762

863
import argparse

utilities/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## `flKernExport.py`
2+
This FLS5 module can be used to export FontLab class-kerning to adjacent UFO
3+
files. It works for both single- and Multiple Master VFBs.
4+
5+
The module needs to be called with a `fl.font` object, and a `prefixOption`.
6+
The `prefixOption` is used for renaming kerning classes to work in various
7+
UFO-related scenarios.
8+
9+
If the prefixOption is `None`, class names will be prefixed with
10+
`@L_ and `@R_`, to keep track of their side (in case they need to be
11+
converted the opposite way and re-imported to FL).
12+
13+
The prefix options are:
14+
* `MM`: convert class names to MetricsMachine-readable group names
15+
* `UFO3`: convert to UFO3-style class names
16+
17+
18+
usage (one of the three):
19+
20+
flKernExport.ClassKerningToUFO(fl.font)
21+
flKernExport.ClassKerningToUFO(fl.font, prefixOption='MM')
22+
flKernExport.ClassKerningToUFO(fl.font, prefixOption='UFO3')
23+
24+
----
25+

0 commit comments

Comments
 (0)