MCPcopy Index your code
hub / github.com/arrowtype/recursive / getBlueScale

Function getBlueScale

mastering/build_static.py:64–97  ·  view source on GitHub ↗

Calculates the correct blue scale for the family based on the max blue zone height. Also sets the `font.info.postscriptBlueFuzz` to 0, which should be the default value, but it does this just to be sure that the value is set correctly (some UFO versions have this set to a differ

(fonts)

Source from the content-addressed store, hash-verified

62
63
64def getBlueScale(fonts):
65 """
66 Calculates the correct blue scale for the family based on the max
67 blue zone height. Also sets the `font.info.postscriptBlueFuzz` to
68 0, which should be the default value, but it does this just to be
69 sure that the value is set correctly (some UFO versions have this
70 set to a different value).
71
72 Returns a `float` that is the blueScale value. If no PS zones are
73 set, it falls back to the default value (0.039625)
74
75 *font* is a font object (Defcon or FontParts)
76 """
77
78 maxZoneHeight = 0
79 blueScale = 0.039625
80
81 for font in fonts:
82 font.info.postscriptBlueFuzz = 0
83 blues = font.info.postscriptBlueValues
84 otherBlues = font.info.postscriptOtherBlues
85 if blues:
86 assert len(blues) % 2 == 0
87 for x, y in zip(blues[:-1:2], blues[1::2]):
88 maxZoneHeight = max(maxZoneHeight, abs(y-x))
89 if otherBlues:
90 assert len(otherBlues) % 2 == 0
91 for x, y in zip(otherBlues[:-1:2], otherBlues[1::2]):
92 maxZoneHeight = max(maxZoneHeight, abs(y-x))
93
94 if maxZoneHeight != 0:
95 blueScale = float(3)/float((4*maxZoneHeight))
96
97 return blueScale
98
99
100def fillInPanoseValues(font, weight):

Callers 1

buildInstancesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected