Write the font specific features file *font* is a font object (Defcon or FontParts)
(font)
| 241 | |
| 242 | |
| 243 | def writeFeature(font): |
| 244 | """ |
| 245 | Write the font specific features file |
| 246 | |
| 247 | *font* is a font object (Defcon or FontParts) |
| 248 | """ |
| 249 | |
| 250 | path = os.path.join(os.path.split(font.path)[0], "features") |
| 251 | hhea = (f"table hhea {{\n" |
| 252 | f" Ascender {font.info.openTypeHheaAscender};\n" |
| 253 | f" Descender {font.info.openTypeHheaDescender};\n" |
| 254 | f" LineGap {font.info.openTypeHheaLineGap};\n" |
| 255 | f"}} hhea;\n\n") |
| 256 | os2 = (f"table OS/2 {{\n" |
| 257 | f" FSType 0;\n" |
| 258 | f" Panose {' '.join(str(x) for x in font.info.openTypeOS2Panose)};\n" |
| 259 | f" TypoAscender {font.info.openTypeOS2TypoAscender};\n" |
| 260 | f" TypoDescender {font.info.openTypeOS2TypoDescender};\n" |
| 261 | f" TypoLineGap {font.info.openTypeOS2TypoLineGap};\n" |
| 262 | f" winAscent {font.info.openTypeOS2WinAscent};\n" |
| 263 | f" winDescent {font.info.openTypeOS2WinDescent};\n" |
| 264 | f" XHeight {font.info.xHeight};\n" |
| 265 | f" CapHeight {font.info.capHeight};\n" |
| 266 | f" WeightClass {font.info.openTypeOS2WeightClass};\n" |
| 267 | f" WidthClass {font.info.openTypeOS2WidthClass};\n" |
| 268 | f' Vendor "{font.info.openTypeOS2VendorID}";\n' |
| 269 | f"}} OS/2;\n\n") |
| 270 | |
| 271 | split = font.info.postscriptFullName.split() |
| 272 | |
| 273 | if "Italic" in split and "Mn" in split: |
| 274 | includes = ("include (../../features.family);\n" |
| 275 | "include (../../features_mono_italic.fea);\n" |
| 276 | "include (kern.fea);\n") |
| 277 | elif "Italic" in split and "Sn" in split: |
| 278 | includes = ("include (../../features.family);\n" |
| 279 | "include (../../features_sans_italic.fea);\n" |
| 280 | "include (kern.fea);\n") |
| 281 | else: |
| 282 | includes = ("include (../../features.family);\n" |
| 283 | "include (../../features_roman.fea);\n" |
| 284 | "include (kern.fea);\n") |
| 285 | mark_mkmk_gdef = make_mark_mkmk_gdef_feature(font) |
| 286 | out = hhea + os2 + includes + mark_mkmk_gdef |
| 287 | with open(path, "w") as f: |
| 288 | f.write(out) |
| 289 | |
| 290 | |
| 291 | def buildFamilyFeatures(root, features, version): |
no test coverage detected