Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b5cd9c7
WIP ccmp and locl feature
benkiel Feb 19, 2021
7cb331e
Add WIP IJ implmentation for Dutch to locl & ccmp feature
arrowtype Feb 19, 2021
811d51c
Merge commit '59b61c05ccb03f0b1ad9c7ebf0dd2d2a87f60446' into ccmp_loc…
benkiel Feb 20, 2021
e47e612
Merge commit '7cb331eea6273b3effb323e4db59010d7ae5f266' into ccmp_loc…
benkiel Feb 20, 2021
e86d287
locl feature done. update ufo for correct feature order.
benkiel Feb 20, 2021
918fc39
ccmp feature, catch getting features correct in Mono masters
benkiel Feb 21, 2021
6eaabb0
Tweak locl feature, shouldn't be swapping those glyphs for vietnamese
benkiel Feb 21, 2021
e0d197c
Revert "Tweak locl feature, shouldn't be swapping those glyphs for vi…
benkiel Feb 21, 2021
5180724
Function to write out mark, mkmk, and gdef
benkiel Feb 25, 2021
7c072bb
Wire in the new mark/mkmk/gdef feature writer to the static fonts. St…
benkiel Feb 25, 2021
dd46ab0
Style cleanup.
benkiel Feb 25, 2021
6de3f96
Wire in adding the mark/mkmk/gdef to the variable font sources
benkiel Feb 25, 2021
a0dc95b
Fix syntax
benkiel Feb 25, 2021
248437c
Make the indentation of the GDEF table look prettier
benkiel Feb 26, 2021
39b13ba
Fixup for changes in the ufo2ft writeKerning method
benkiel Feb 26, 2021
67cff52
Missing by's in ccmp
benkiel Feb 26, 2021
975e9fe
Fix for locl feature
benkiel Feb 26, 2021
cbe2d08
Remove mark/mkmk/gdef feature writing from the Var font build. fontma…
benkiel Feb 26, 2021
04bd610
Cleanup
benkiel Feb 26, 2021
a64a737
Built fonts
benkiel Feb 26, 2021
948937a
Re-work feature writing code to use ufo2ft makrFeatureWriter instead …
benkiel Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: uni01CA: Please remove zero length element at 444 700 so can add flex.
25,176 changes: 25,176 additions & 0 deletions fonts/ArrowType-Recursive-1.075-Beta.075/Static_OTF/makeotf_output.txt

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
26,200 changes: 26,200 additions & 0 deletions fonts/ArrowType-Recursive-1.075-Beta.075/Static_TTF/makeotf_output.txt

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion mastering/build_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
from fontTools.designspaceLib import DesignSpaceDocument
from prep_fonts import prep, copyFiles
from build_variable import makeSTAT, buildFeatures
from build_variable import buildFeatures
from build_static import (buildFolders,
buildNameMap,
buildFontMenuDB,
Expand Down
28 changes: 14 additions & 14 deletions mastering/build_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from ttfautohint.options import USER_OPTIONS as ttfautohint_options
from fontTools.ttLib import TTFont
from fontTools import ttLib
from utils import getFiles, printProgressBar, splitall, batchCheckOutlines
from utils import (getFiles, printProgressBar, splitall, batchCheckOutlines,
make_mark_mkmk_gdef_feature)
from contextlib import redirect_stdout, redirect_stderr

# Family specific data
Expand Down Expand Up @@ -207,7 +208,7 @@ def writeKerning(font, path):

feaFile = ast.FeatureFile()
w = KernFeatureWriter()
w.write(font, feaFile)
w.write(font.naked(), feaFile)
with open(path, "w") as f:
f.write(str(feaFile))

Expand Down Expand Up @@ -281,8 +282,8 @@ def writeFeature(font):
includes = ("include (../../features.family);\n"
"include (../../features_roman.fea);\n"
"include (kern.fea);\n")

out = hhea + os2 + includes
mark_mkmk_gdef = make_mark_mkmk_gdef_feature(font)
out = hhea + os2 + includes + mark_mkmk_gdef
with open(path, "w") as f:
f.write(out)

Expand All @@ -302,8 +303,8 @@ def buildFamilyFeatures(root, features, version):
fea_root = os.path.split(features)[0]
regex = re.compile(r'/.+/(.+\.fea)')
feature_roman = []
feature_mono_italic = [] # includes ss07
feature_sans_italic = [] # includes ss07, liga
feature_mono_italic = [] # includes ss07
feature_sans_italic = [] # includes ss07, liga
with open(features, 'r') as f:
for l in f:
if l.startswith("languagesystem"):
Expand Down Expand Up @@ -336,18 +337,17 @@ def buildFamilyFeatures(root, features, version):
# swap italic diagonals in ss07
for i, line in enumerate(feature_sans_italic):
if "sub @curvyDiagonals by @romanDiagonals;" in line:
feature_sans_italic[i] = " sub @romanDiagonals by @curvyDiagonals;"
feature_sans_italic[i] = " sub @romanDiagonals by @curvyDiagonals;"

# swap italic diagonals in ss07
for i, line in enumerate(feature_mono_italic):
if "sub @curvyDiagonals by @romanDiagonals;" in line:
feature_mono_italic[i] = " sub @romanDiagonals by @curvyDiagonals;"
feature_mono_italic[i] = " sub @romanDiagonals by @curvyDiagonals;"

path_roman = os.path.join(root, "features_roman.fea")
path_mono_italic = os.path.join(root, "features_mono_italic.fea")
path_sans_italic = os.path.join(root, "features_sans_italic.fea")


with open(path_roman, 'w') as f:
f.write("".join(feature_roman))
with open(path_mono_italic, 'w') as f:
Expand Down Expand Up @@ -510,13 +510,13 @@ def buildInstances(designspacePath, root, name_map):
# Write out the `fontinfo` file
buildFontInfo(font.info.styleName, font_dir)

# Write out the font feature file
writeFeature(font)

# Write out the kerning feature file
path = os.path.join(font_dir, "kern.fea")
writeKerning(font, path)

# Write out the font feature file
writeFeature(font)

printProgressBar(i + 1, length, prefix=' ',
suffix='Complete', length=50)

Expand Down Expand Up @@ -716,15 +716,15 @@ def makeSFNT(root, outputPath, kind="otf"):

printProgressBar(0, len(files), prefix=' ', suffix='Complete', length=50)
for i, file in enumerate(files):
if kind is "otf":
if kind == "otf":
args = ["psautohint", file]
run = subprocess.run(args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
with open(outputFile, "a") as f:
f.write(run.stdout)
elif kind is "ttf":
elif kind == "ttf":
ttfautohint_options.update(
in_file=file,
out_file=file,
Expand Down
20 changes: 17 additions & 3 deletions mastering/build_variable.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import fontTools.ttLib
import shutil
from plistlib import dump as plDump
from fontmake.font_project import FontProject
from fontTools.designspaceLib import DesignSpaceDocument
from fontTools.otlLib.builder import buildStatTable
from utils import getFiles
from fontParts.fontshell import RFont as Font
from utils import getFiles, make_mark_mkmk_gdef_feature


def buildFeatures(src):
Expand All @@ -21,11 +21,25 @@ def buildFeatures(src):
shutil.copy(feature, ufo)
print("🏗 Moved features into UFOs")

for ufo in ufos:
font = Font(ufo)
# Turn off writing out gdef table glyph classes as this
# causes fontmake to choke on the variable font build.
# Ben Kiel thinks this is because the classes push the
# table size to create another lookup in the Sans fonts,
# causing a mis-match between the number of lookups in Sans
# vs Mono. Instead, only write out the ligature carets, and
# let fontmake/ufo2ft fill in the classes. Testing found that
# fontmake/ufo2ft will not write ligature classes, just mark
# and base, FYI.
make_mark_mkmk_gdef_feature(font, GDEF_Classes=False)
print("🏗 Added mark, mkmk, and GDEF to features")


def makeSTAT(font, designspace):
"""
Uses fontTools.otlLib.builder.buildStatTable to build the STAT table.

*font* is a `fontTools` font object.
*designspace* is a `DesignSpaceDocument` object
"""
Expand Down
14 changes: 5 additions & 9 deletions mastering/prep_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ def decomposeScaledNested(fonts):
"""
Decompose anything that is scaled or built from nested components.
This replaces the fix from Recursive Issue #297, as it will catch
issues occurring in #412 and #427.
issues occurring in #412 and #427.
"""

local_report = report.get("Decomposed scaled, flipped, and nested components", [])
for font in fonts:

changed_glyphs = []

for glyph in font:
if len(glyph.components) != 0:
changed = False
for c in glyph.components:
if c.scale != (1,1):
if c.scale != (1, 1):
try:
c.decompose()
changed = True
Expand All @@ -289,7 +289,6 @@ def decomposeScaledNested(fonts):
report["Decomposed scaled, flipped, and nested components"] = local_report



def sortGlyphOrder(fonts):
"""
Sorts all fonts in the list of *fonts* to have a common sort order.
Expand Down Expand Up @@ -403,7 +402,7 @@ def setProductionNames(fonts):
'slashcomb': 'uni0337',
'tildecomb': 'uni0303',
'mu.math': 'uni00B5',
# the following abbreviations are to keep code ligature glyph names under 31 characters,
# the following abbreviations are to keep code ligature glyph names under 31 characters,
# per FontBakery check: com.google.fonts/check/valid_glyphnames
# (generated with src/01-shell-scripts-for-sources/font-info/shorten-long-glyph-names.py)
'numbersign_numbersign_numbersign.code': 'num_num_num.code',
Expand Down Expand Up @@ -515,8 +514,6 @@ def makeCompatible(fonts):

if nonCompatible != []:
local_report.append(nonCompatible)

print(nonCompatible) # debugging

report["Removed non-compatible glyphs"] = local_report

Expand Down Expand Up @@ -575,7 +572,6 @@ def prep(designspacePath, version):
if version:
setVersion(fonts, version)


print("🏗 Closing and saving sources")
for font in fonts:
font.close(save=True)
Expand Down
88 changes: 87 additions & 1 deletion mastering/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def splitall(path):
if parts[0] == path: # sentinel for absolute paths
allparts.insert(0, parts[0])
break
elif parts[1] == path: # sentinel for relative paths
elif parts[1] == path: # sentinel for relative paths
allparts.insert(0, parts[1])
break
else:
Expand Down Expand Up @@ -135,6 +135,92 @@ def batchCheckOutlines(root):
f.write("".join(log))


def make_mark_mkmk_gdef_feature(font, GDEF_Classes=True):
from collections import defaultdict
from ufo2ft.featureWriters.markFeatureWriter import MarkFeatureWriter, ast

"""
Takes in a font and builds the mark, mkmk,
and gdef table in Adobe Feature File syntax.

*font* is a Defcon like font object.
*GDEF_Classes* will write out the Base, Mark, and Ligature classes in the
gdef table.
"""

# Use ufo2ft to write mark/mkmk feature
feaFile = ast.FeatureFile()
w = MarkFeatureWriter()
w.write(font.naked(), feaFile)

# Gather the ligCaret data
ligCarets = defaultdict(list)
marks = []
bases = []

for glyph in font:

# note, we're rounding (by int()) the anchor positions

if len(glyph.anchors) > 0:
# there can be more than one ligCaret in a ligature
# so need to store them before writing them out
carets = []

for a in glyph.anchors:
# Lig caret marks are named starting
# caret, so we look for those. Only
# need the x position for the feature
if a.name.startswith('caret'):
carets.append(int(a.x))
# if a anchor name starts with a
# underscore, it's a mark
elif a.name.startswith("_"):
if glyph.name not in marks:
marks.append(glyph.name)
# otherwise it is a base
else:
if glyph.name not in bases:
bases.append(glyph.name)

# make a dict of all the same caret positions
# with the glyph names as values. Streamines
# the GDEF table
if carets != []:
ligCarets[tuple(carets)].append(glyph.name)

# Clean out any mark glyphs that are in bases:
for m in marks:
if m in bases:
bases.remove(m)

bases.sort()
marks.sort()

# Get a list of all the ligs in the font for GDEF
ligatures = []
for names in ligCarets.values():
ligatures += names
ligatures.sort()

if GDEF_Classes:
gdef = f"table GDEF {{\n GlyphClassDef [{' '.join(bases)}], [{' '.join(ligatures)}], [{' '.join(marks)}],;\n"
else:
gdef = "table GDEF {\n"

for k, v in ligCarets.items():
if len(v) > 1:
gdef += f" LigatureCaretByPos [{' '.join(v)}] {' '.join(str(i) for i in k)};\n"
else:
gdef += f" LigatureCaretByPos {' '.join(v)} {' '.join(str(i) for i in k)};\n"
gdef += "} GDEF;"

font.features.text += f'{str(feaFile)}\n{gdef}'
font.save(font.path)

return f'{str(feaFile)}\n{gdef}'


if __name__ == "__main__":

import argparse
Expand Down
7 changes: 7 additions & 0 deletions src/features/features.fea
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
languagesystem DFLT dflt;
languagesystem latn dflt;
languagesystem latn CAT;
languagesystem latn MOL;
languagesystem latn NLD;
languagesystem latn ROM;
languagesystem latn VIT;

# include paths written relative to UFOs in varfontprep folders
# `features` dir will be copied to varfontprep folder, and these includes will link to that
include(./features/common.fea);
include(./features/ccmp.fea);
include(./features/locl.fea);
include(./features/afrc.fea);
include(./features/frac.fea);
include(./features/numr_dnom_supr_infr.fea);
Expand Down
Loading