Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 17 additions & 3 deletions Lib/fontmake/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,19 @@ def main(args=None):
"--no-auto-use-my-metrics",
dest="auto_use_my_metrics",
action="store_false",
help="Don't automatically set USE_MY_METRICS glyf component flags (0x0200).",
default=None,
)
contourGroup.add_argument(
"--auto-use-my-metrics",
dest="auto_use_my_metrics",
action="store_true",
default=None,
help=(
"Automatically set (or not) USE_MY_METRICS glyf component flags (0x0200). "
"By default, fontmake only enables this for static fonts, though it can "
"also be enabled for variable fonts. This is not needed unless the font "
"is going to have hinted horizontal glyph metrics."
),
)
contourGroup.add_argument(
"--drop-implied-oncurves",
Expand Down Expand Up @@ -605,8 +617,7 @@ def main(args=None):
"--production-names",
dest="use_production_names",
action="store_true",
help="Rename glyphs with production names if available otherwise use "
"uninames.",
help="Rename glyphs with production names if available otherwise use uninames.",
)
glyphnamesGroup.add_argument(
"--no-production-names", dest="use_production_names", action="store_false"
Expand Down Expand Up @@ -743,6 +754,9 @@ def main(args=None):
)
args.pop("ufo_structure", None) # unused for UFO output
args.pop("indent_json", None)
# keep the old default for statics, where it doesn't harm
if args["auto_use_my_metrics"] is None:
args["auto_use_my_metrics"] = True
project.run_from_ufos(
inputs.ufo_paths, is_instance=args.pop("masters_as_instances"), **args
)
Expand Down
19 changes: 17 additions & 2 deletions Lib/fontmake/font_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def _build_interpolatable_masters(
fea_include_dir=None,
flatten_components=False,
filters=None,
auto_use_my_metrics=True,
auto_use_my_metrics=False,
**kwargs,
):
if ttf:
Expand Down Expand Up @@ -395,7 +395,7 @@ def build_variable_fonts(
fea_include_dir=None,
flatten_components=False,
filters=None,
auto_use_my_metrics=True,
auto_use_my_metrics=False,
drop_implied_oncurves=False,
variable_features=True,
**kwargs,
Expand Down Expand Up @@ -1098,6 +1098,7 @@ def run_from_designspace(
filters=None,
expand_features_to_instances=False,
check_compatibility=None,
auto_use_my_metrics=None,
**kwargs,
):
"""Run toolchain from a DesignSpace document to produce either static
Expand Down Expand Up @@ -1194,6 +1195,9 @@ def run_from_designspace(

try:
if static_outputs:
# keep setting the USE_MY_METRICS flag for the static outputs only
if auto_use_my_metrics is None:
auto_use_my_metrics = True
self._run_from_designspace_static(
designspace,
outputs=static_outputs,
Expand All @@ -1204,16 +1208,27 @@ def run_from_designspace(
feature_writers=feature_writers,
expand_features_to_instances=expand_features_to_instances,
filters=filters,
auto_use_my_metrics=auto_use_my_metrics,
**kwargs,
)
if interp_outputs:
# for interpolatable outputs, prefer not to set the flag automatically
# and let the user decide. For VFs in particular this is either useless
# (if the VF isn't going to be hinted) or wrong (if the composite and
# component metrics are not the same throughout the variation space,
# leading to potential mismatch between the metrics computed from HVAR
# vs glyf+gvar phantom points, depending on whether the flag is honored
# by the renderer).
if auto_use_my_metrics is None:
auto_use_my_metrics = False
self._run_from_designspace_interpolatable(
designspace,
outputs=interp_outputs,
variable_fonts=variable_fonts,
feature_writers=feature_writers,
filters=filters,
variable_features=variable_features,
auto_use_my_metrics=auto_use_my_metrics,
**kwargs,
)
except FontmakeError as e:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ascender</key>
<integer>800</integer>
<key>capHeight</key>
<integer>700</integer>
<key>descender</key>
<integer>-200</integer>
<key>familyName</key>
<string>WghtVar Composite</string>
<key>styleMapFamilyName</key>
<string>WghtVar Composite</string>
<key>styleMapStyleName</key>
<string>bold</string>
<key>styleName</key>
<string>Bold</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>versionMajor</key>
<integer>42</integer>
<key>versionMinor</key>
<integer>42</integer>
<key>xHeight</key>
<integer>500</integer>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>equal</key>
<string>equal.glif</string>
<key>hyphen</key>
<string>hyphen.glif</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="equal" format="2">
<advance width="600"/>
<unicode hex="003D"/>
<outline>
<component base="hyphen" yOffset="70"/>
<component base="hyphen" yOffset="-100"/>
</outline>
</glyph>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="hyphen" format="2">
<advance width="600"/>
<unicode hex="002D"/>
<outline>
<contour>
<point x="92" y="356" type="line"/>
<point x="92" y="224" type="line"/>
<point x="508" y="224" type="line"/>
<point x="508" y="356" type="line"/>
</contour>
</outline>
</glyph>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<array>
<string>public.default</string>
<string>glyphs</string>
</array>
</array>
</plist>
11 changes: 11 additions & 0 deletions tests/data/AutoUseMyMetrics/WghtVarComposite-Bold.ufo/lib.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>public.glyphOrder</key>
<array>
<string>hyphen</string>
<string>equal</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>creator</key>
<string>com.github.fonttools.ufoLib</string>
<key>formatVersion</key>
<integer>3</integer>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ascender</key>
<integer>737</integer>
<key>capHeight</key>
<integer>702</integer>
<key>descender</key>
<integer>-42</integer>
<key>familyName</key>
<string>WghtVar Composite</string>
<key>styleMapFamilyName</key>
<string>WghtVar Composite</string>
<key>styleMapStyleName</key>
<string>regular</string>
<key>styleName</key>
<string>Regular</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>versionMajor</key>
<integer>42</integer>
<key>versionMinor</key>
<integer>42</integer>
<key>xHeight</key>
<integer>501</integer>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>equal</key>
<string>equal.glif</string>
<key>hyphen</key>
<string>hyphen.glif</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="equal" format="2">
<advance width="600"/>
<unicode hex="003D"/>
<outline>
<component base="hyphen" yOffset="50"/>
<component base="hyphen" yOffset="-50"/>
</outline>
</glyph>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="hyphen" format="2">
<advance width="600"/>
<unicode hex="002D"/>
<outline>
<contour>
<point x="131" y="330" type="line"/>
<point x="131" y="250" type="line" name="hr00"/>
<point x="470" y="250" type="line"/>
<point x="470" y="330" type="line"/>
</contour>
</outline>
</glyph>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<array>
<string>public.default</string>
<string>glyphs</string>
</array>
</array>
</plist>
11 changes: 11 additions & 0 deletions tests/data/AutoUseMyMetrics/WghtVarComposite-Regular.ufo/lib.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>public.glyphOrder</key>
<array>
<string>hyphen</string>
<string>equal</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>creator</key>
<string>com.github.fonttools.ufoLib</string>
<key>formatVersion</key>
<integer>3</integer>
</dict>
</plist>
34 changes: 34 additions & 0 deletions tests/data/AutoUseMyMetrics/WghtVarComposite.designspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version='1.0' encoding='UTF-8'?>
<designspace format="5.0">
<axes>
<axis tag="wght" name="Weight" minimum="400" maximum="700" default="400"/>
</axes>
<sources>
<source filename="WghtVarComposite-Regular.ufo" name="WghtVar Composite Regular" familyname="WghtVar Composite" stylename="Regular">
<lib copy="1"/>
<groups copy="1"/>
<features copy="1"/>
<info copy="1"/>
<location>
<dimension name="Weight" xvalue="400"/>
</location>
</source>
<source filename="WghtVarComposite-Bold.ufo" name="WghtVar Composite Bold" familyname="WghtVar Composite" stylename="Bold">
<location>
<dimension name="Weight" xvalue="700"/>
</location>
</source>
</sources>
<instances>
<instance name="WghtVar Composite Regular" familyname="WghtVar Composite" stylename="Regular" filename="../../instance_ufo/WghtVarComposite-Regular.ufo" stylemapfamilyname="WghtVar Composite" stylemapstylename="regular">
<location>
<dimension name="Weight" xvalue="400"/>
</location>
</instance>
<instance name="WghtVar Composite Bold" familyname="WghtVar Composite" stylename="Bold" filename="../../instance_ufo/WghtVarComposite-Bold.ufo" stylemapfamilyname="WghtVar Composite" stylemapstylename="bold">
<location>
<dimension name="Weight" xvalue="700"/>
</location>
</instance>
</instances>
</designspace>
Loading
Loading