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)
| 62 | |
| 63 | |
| 64 | def 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 | |
| 100 | def fillInPanoseValues(font, weight): |