Skip to content

Commit

Permalink
Add makeinstancesufo support for strict flag passed to ufoProcessor/f…
Browse files Browse the repository at this point in the history
…ontMath
  • Loading branch information
punchcutter committed Sep 4, 2024
1 parent ed6287d commit c3a3b6b
Show file tree
Hide file tree
Showing 111 changed files with 1,555 additions and 181 deletions.
28 changes: 20 additions & 8 deletions python/afdko/makeinstancesufo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright 2015 Adobe. All rights reserved.

"""
Generates UFO font instances from a set of master UFO fonts.
It uses the mutatorMath library. The paths to the masters and
instances fonts are specified in the .designspace file.
Generates UFO font instances from a set of source UFO fonts
using either MutatorMath or the fontTools varLib library.
The paths to the source and instance fonts are specified in
the .designspace file.
"""

import argparse
Expand All @@ -22,7 +23,7 @@
from defcon import Font
from .otfautohint.__main__ import main as otfautohint
from ufonormalizer import normalizeUFO
from ufoProcessor import build as ufoProcessorBuild
from ufoProcessor.ufoOperator import UFOOperator

from afdko.checkoutlinesufo import run as checkoutlinesUFO
from afdko.fdkutils import (
Expand Down Expand Up @@ -336,10 +337,15 @@ def run(options):
tool_str = "fontTools.varlib" if options.useVarlib else "MutatorMath"
info_str = f"Building {newInstancesCount} {icnt_str} with {tool_str} ..."
logger.info(info_str)
ufoProcessorBuild(documentPath=dsPath,
outputUFOFormatVersion=options.ufo_version,
roundGeometry=(not options.no_round),
logger=logger, useVarlib=options.useVarlib)
ufoOperator = UFOOperator(pathOrObject=dsPath,
ufoVersion=options.ufo_version,
useVarlib=options.useVarlib,
extrapolate=True,
strict=options.strict,
debug=options.verbose > 2)
ufoOperator.roundGeometry = (not options.no_round)
ufoOperator.loadFonts()
ufoOperator.generateUFOs()

# Remove temporary designspace file
if (dsPath != options.dsPath) and os.path.exists(dsPath):
Expand Down Expand Up @@ -470,6 +476,12 @@ def get_options(args):
action='store_true',
help='do NOT round coordinates to integer'
)
parser.add_argument(
'-s',
'--strict',
action='store_true',
help='Pass the strict flag to ufoProcessor'
)
parser.add_argument(
'-i',
metavar='INDEX(ES)',
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fontMath==0.9.3
fontTools[unicode,woff,lxml,ufo]==4.43.0
tqdm==4.66.1
ufonormalizer==0.6.1
ufoProcessor==1.9.0
ufoProcessor==1.13.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<integer>750</integer>
<key>capHeight</key>
<integer>750</integer>
<key>copyright</key>
<string>Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>descender</key>
<integer>-250</integer>
<key>familyName</key>
Expand All @@ -15,6 +17,11 @@
</array>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeNameLicense</key>
<string>This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is available with a FAQ at: http://scripts.sil.org/OFL. This Font Software is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.</string>
<key>openTypeNameLicenseURL</key>
<string>http://scripts.sil.org/OFL</string>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
<key>postscriptBlueScale</key>
Expand Down Expand Up @@ -60,6 +67,8 @@
</array>
<key>postscriptFontName</key>
<string>Dummy-ExtraMinus</string>
<key>postscriptForceBold</key>
<false/>
<key>postscriptOtherBlues</key>
<array>
<integer>-243</integer>
Expand All @@ -81,8 +90,14 @@
<integer>50</integer>
<key>styleName</key>
<string>Extra Minus</string>
<key>trademark</key>
<string>Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>versionMajor</key>
<integer>2</integer>
<key>versionMinor</key>
<integer>0</integer>
<key>xHeight</key>
<integer>500</integer>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<integer>750</integer>
<key>capHeight</key>
<integer>750</integer>
<key>copyright</key>
<string>Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>descender</key>
<integer>-250</integer>
<key>familyName</key>
Expand All @@ -15,6 +17,11 @@
</array>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeNameLicense</key>
<string>This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is available with a FAQ at: http://scripts.sil.org/OFL. This Font Software is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.</string>
<key>openTypeNameLicenseURL</key>
<string>http://scripts.sil.org/OFL</string>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
<key>postscriptBlueScale</key>
Expand Down Expand Up @@ -60,6 +67,8 @@
</array>
<key>postscriptFontName</key>
<string>Dummy-ExtraPlus</string>
<key>postscriptForceBold</key>
<false/>
<key>postscriptOtherBlues</key>
<array>
<integer>-165</integer>
Expand All @@ -81,8 +90,14 @@
<integer>50</integer>
<key>styleName</key>
<string>Extra Plus</string>
<key>trademark</key>
<string>Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>versionMajor</key>
<integer>2</integer>
<key>versionMinor</key>
<integer>0</integer>
<key>xHeight</key>
<integer>500</integer>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>@MMK_L_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_L_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_L_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_L_LAT_v</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>@MMK_R_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_R_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_R_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_R_LAT_y</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>Not a kerning group</key>
<array>
<string>a</string>
Expand Down
14 changes: 14 additions & 0 deletions tests/makeinstancesufo_data/expected_output/bend1.ufo/features.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@lat_UC_left = [ A B C D E F G H J K L M N O P R S T U V W X Y Z ];

@lat_lcnew_right = [ a o l lslash b ];

@punct_left = [ hyphen parenleft quotedblbase guillemotleft quotedblleft guillemotright quotedblright asterisk quotesingle comma period slash colon semicolon question backslash bullet ];

@punct_right = [ hyphen parenright guillemotleft quotedblleft guillemotright quotedblright exclam quotedbl asterisk comma period slash colon semicolon question backslash bullet ];

@lat_lc_right = [ a n e c f g i j lslash o p d h s t u v w x y z ];

@lat_lcnew_left = [ d dcaron e c l lslash o eth s germandbls ];

@lat_lc_left = [ c dcaron eth e f longs germandbls g j k lslash o b r d n a s t v w x y z ];

14 changes: 14 additions & 0 deletions tests/makeinstancesufo_data/expected_output/bend2.ufo/features.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@lat_UC_left = [ A B C D E F G H J K L M N O P R S T U V W X Y Z ];

@lat_lcnew_right = [ a o l lslash b ];

@punct_left = [ hyphen parenleft quotedblbase guillemotleft quotedblleft guillemotright quotedblright asterisk quotesingle comma period slash colon semicolon question backslash bullet ];

@punct_right = [ hyphen parenright guillemotleft quotedblleft guillemotright quotedblright exclam quotedbl asterisk comma period slash colon semicolon question backslash bullet ];

@lat_lc_right = [ a n e c f g i j lslash o p d h s t u v w x y z ];

@lat_lcnew_left = [ d dcaron e c l lslash o eth s germandbls ];

@lat_lc_left = [ c dcaron eth e f longs germandbls g j k lslash o b r d n a s t v w x y z ];

14 changes: 14 additions & 0 deletions tests/makeinstancesufo_data/expected_output/bend3.ufo/features.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@lat_UC_left = [ A B C D E F G H J K L M N O P R S T U V W X Y Z ];

@lat_lcnew_right = [ a o l lslash b ];

@punct_left = [ hyphen parenleft quotedblbase guillemotleft quotedblleft guillemotright quotedblright asterisk quotesingle comma period slash colon semicolon question backslash bullet ];

@punct_right = [ hyphen parenright guillemotleft quotedblleft guillemotright quotedblright exclam quotedbl asterisk comma period slash colon semicolon question backslash bullet ];

@lat_lc_right = [ a n e c f g i j lslash o p d h s t u v w x y z ];

@lat_lcnew_left = [ d dcaron e c l lslash o eth s germandbls ];

@lat_lc_left = [ c dcaron eth e f longs germandbls g j k lslash o b r d n a s t v w x y z ];

56 changes: 56 additions & 0 deletions tests/makeinstancesufo_data/expected_output/black.ufo/groups.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>@MMK_L_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_L_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_L_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_L_LAT_v</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>@MMK_R_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_R_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_R_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_R_LAT_y</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>Not a kerning group</key>
<array>
<string>a</string>
Expand Down
56 changes: 56 additions & 0 deletions tests/makeinstancesufo_data/expected_output/bold.ufo/groups.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>@MMK_L_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_L_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_L_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_L_LAT_v</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>@MMK_R_LAT_A</key>
<array>
<string>A</string>
<string>Aacute</string>
<string>Adieresis</string>
<string>Atilde</string>
</array>
<key>@MMK_R_LAT_Y</key>
<array>
<string>Y</string>
<string>Yacute</string>
<string>Ydieresis</string>
<string>Ytilde</string>
</array>
<key>@MMK_R_LAT_a</key>
<array>
<string>a</string>
<string>aacute</string>
<string>adieresis</string>
<string>atilde</string>
</array>
<key>@MMK_R_LAT_y</key>
<array>
<string>y</string>
<string>yacute</string>
<string>ydieresis</string>
<string>ytilde</string>
</array>
<key>Not a kerning group</key>
<array>
<string>a</string>
Expand Down
Loading

0 comments on commit c3a3b6b

Please sign in to comment.