Skip to content

Commit cc40a6b

Browse files
committed
Accept axis coordinates dict with default in to_sliced_variable method. #63
1 parent 0f74504 commit cc40a6b

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,11 @@ Converts the variable font to a partial one slicing the variable axes at the giv
641641
If an axis value is not specified, the axis will be left untouched.
642642
If an axis min and max values are equal, the axis will be pinned.
643643
644-
:param coordinates: The coordinates dictionary, each item value must be tuple/list/dict (with min and max keys) for slicing or float/int for pinning, eg.
645-
{"wdth":100, "wght":(100,600), "ital":(30,70)} or
646-
{"wdth":100, "wght":[100,600], "ital":[30,70]} or
647-
{"wdth":100, "wght":{"min":100,"max":600}, "ital":{"min":30,"max":70}}
644+
:param coordinates: The coordinates dictionary, each item value must be tuple/list/dict
645+
(with 'min', 'default' and 'max' keys) for slicing or float/int for pinning, eg.
646+
{'wdth':100, 'wght':(100,600), 'ital':(30,65,70)} or
647+
{'wdth':100, 'wght':[100,600], 'ital':[30,65,70]} or
648+
{'wdth':100, 'wght':{'min':100,'max':600}, 'ital':{'min':30,'default':65,'max':70}}
648649
:type coordinates: dict
649650
:param options: The options for the fontTools.varLib.instancer
650651
:type options: dictionary

fontbro/font.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,11 +1255,11 @@ def to_sliced_variable(self, coordinates, **options):
12551255
If an axis value is not specified, the axis will be left untouched.
12561256
If an axis min and max values are equal, the axis will be pinned.
12571257
1258-
:param coordinates: The coordinates dictionary, each item value must be
1259-
tuple/list/dict (with min and max keys) for slicing or float/int for pinning, eg.
1260-
{'wdth':100, 'wght':(100,600), 'ital':(30,70)} or
1261-
{'wdth':100, 'wght':[100,600], 'ital':[30,70]} or
1262-
{'wdth':100, 'wght':{'min':100,'max':600}, 'ital':{'min':30,'max':70}}
1258+
:param coordinates: The coordinates dictionary, each item value must be tuple/list/dict
1259+
(with 'min', 'default' and 'max' keys) for slicing or float/int for pinning, eg.
1260+
{'wdth':100, 'wght':(100,600), 'ital':(30,65,70)} or
1261+
{'wdth':100, 'wght':[100,600], 'ital':[30,65,70]} or
1262+
{'wdth':100, 'wght':{'min':100,'max':600}, 'ital':{'min':30,'default':65,'max':70}}
12631263
:type coordinates: dict
12641264
:param options: The options for the fontTools.varLib.instancer
12651265
:type options: dictionary
@@ -1283,8 +1283,9 @@ def to_sliced_variable(self, coordinates, **options):
12831283
elif isinstance(axis_value, dict):
12841284
axis = self.get_variable_axis_by_tag(axis_tag)
12851285
axis_min = axis_value.get("min", axis.get("min_value"))
1286+
axis_default = axis_value.get("default", axis.get("default_value"))
12861287
axis_max = axis_value.get("max", axis.get("max_value"))
1287-
axis_value = (axis_min, axis_max)
1288+
axis_value = (axis_min, axis_default, axis_max)
12881289
coordinates[axis_tag] = axis_value
12891290

12901291
# ensure that coordinates axes are defined and that are not all pinned

0 commit comments

Comments
 (0)