Skip to content

Commit

Permalink
minor documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrolf committed Jan 22, 2024
1 parent 26c611d commit a83c109
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Extract a list of all (flat) kerning pairs from a VFB’s kern object, and
report the absolute number of pairs. Run as a FontLab script.

__Dependencies:__ [FontLab 5](http://old.fontlab.com/font-editor/fontlab-studio/)
__Environment:__ FontLab 5
__Environment:__ FontLab Studio 5

---

Expand Down
6 changes: 0 additions & 6 deletions convertKernedOTFtoKernedUFO.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3

'''
This script extracts kerning and groups from a compiled OTF and injects
them into a new UFO file (which is created via `tx`).
Expand All @@ -23,11 +22,6 @@

import getKerningPairsFromOTF

kKernFeatureTag = 'kern'
compressSinglePairs = True
# Switch to control if single pairs shall be written plainly,
# or in a more space-saving notation (using enum).


def sortGlyphs(glyphlist):
'''
Expand Down
32 changes: 15 additions & 17 deletions dumpKernFeatureFromOTF.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#!/usr/bin/env python3
'''
This script extracts a viable kern feature file from a compiled OTF.
It requires the script 'getKerningPairsFromOTF.py'; which is distributed
in the same folder.
usage:
python dumpKernFeatureFromOTF.py font.otf > outputfile
'''

import argparse
import os
import string
Expand All @@ -8,20 +18,8 @@
import getKerningPairsFromOTF
reload(getKerningPairsFromOTF)

__doc__ = '''
This script extracts a viable kern feature file from a compiled OTF.
It requires the script 'getKerningPairsFromOTF.py'; which is distributed
in the same folder.
usage:
python dumpKernFeatureFromOTF.py font.otf > outputfile
'''

# compress related single pairs into one line (using enum pos), or no?
compressSinglePairs = True
# Switch to control if single pairs shall be written plainly, or in a more
# space-saving notation (using enum pos).


def sortGlyphs(glyphlist):
Expand Down Expand Up @@ -124,9 +122,9 @@ def makeKernFeature(fontPath):
exploding_class_class = []

# Compress the single pairs to a more space-saving notation.
# First, dictionaries for each left glyph are created.
# First, create dictionaries for each left glyph.
# If the kerning value to any right glyph happens to be equal,
# those right glyphs are merged into a 'class'.
# merge those right glyphs into a 'class'.

for (left, right), value in singlePairsList:
leftGlyph = left
Expand Down Expand Up @@ -155,7 +153,7 @@ def makeKernFeature(fontPath):
left = sortGlyphs(left)
compressedBoth.append((left, right.split(), value))

# Splitting the compressed single-pair kerning into four different
# Split the compressed single-pair kerning into four different
# lists; organized by type:

for left, right, value in compressedBoth:
Expand All @@ -176,7 +174,7 @@ def makeKernFeature(fontPath):
else:
print(f'ERROR with ({" ".join(left, right, value)})')

# Making sure all the pairs made it through the process:
# Make sure all the pairs made it through the process:
if len(compressedBoth) != (
len(class_glyph) + len(glyph_class) +
len(glyph_glyph) + len(exploding_class_class)
Expand Down
4 changes: 4 additions & 0 deletions dumpkerning.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python3
'''
Wrapper script for all the getKerningPairsFromXXX scripts.
'''

from getKerningPairsFromFEA import FEAKernReader
from getKerningPairsFromOTF import OTFKernReader
Expand Down
3 changes: 1 addition & 2 deletions getKerningPairsFromFEA.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
'''
Print a list of all kerning pairs to be expected from a kern feature file.
The feature file has to be passed to the script as an argument.
Print all kerning pairs to be expected from a kern feature file.
This script has the ability to use a GlyphOrderAndAliasDB file for translating
"friendly" glyph names to final glyph names (for comparison with OTF).
'''
Expand Down
16 changes: 9 additions & 7 deletions getKerningPairsFromOTF.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env python3
from fontTools import ttLib
from pathlib import Path
import argparse
import sys

__doc__ = '''\
'''
Extract a list of all (flat) GPOS kerning pairs in a font, and report the
absolute number of pairs.
Print all possible kerning pairs within a font.
Supports RTL kerning.
Only GPOS kerning is considered.
Usage:
------
python getKerningPairsFromOTF.py <path to font file>
'''

from fontTools import ttLib
from pathlib import Path
import argparse
import sys


class LeftClass:
def __init__(self):
Expand Down
6 changes: 6 additions & 0 deletions getKerningPairsFromUFO.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env python3
'''
Extract a list of all (flat) kerning pairs in a UFO file’s kern object, and
report the absolute number of pairs.
'''

import argparse
import itertools
from pathlib import Path
Expand Down
6 changes: 6 additions & 0 deletions getKerningPairsFromVFB.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
'''
Extract a list of all (flat) kerning pairs from a VFB’s kern object, and
report the absolute number of pairs. Run as a FontLab script.
'''
import itertools
from FL import fl
f = fl.font
Expand Down Expand Up @@ -197,5 +202,6 @@ def run():

print '\nList of kerning pairs written to\n{}'.format(dumpFileName)


if __name__ == '__main__':
run()

0 comments on commit a83c109

Please sign in to comment.