|
1 | 1 | from fontbakery.callable import check |
2 | | -from fontbakery.status import FAIL, PASS, WARN, INFO |
| 2 | +from fontbakery.status import FAIL, PASS, WARN, INFO, SKIP |
3 | 3 | from fontbakery.message import Message |
4 | 4 | # used to inform get_module_profile whether and how to create a profile |
5 | 5 | from fontbakery.fonts_profile import profile_factory # NOQA pylint: disable=unused-import |
@@ -329,3 +329,40 @@ def com_google_fonts_check_code_pages(ttFont): |
329 | 329 | " ulCodePageRange1 and CodePageRange2 fields.") |
330 | 330 | else: |
331 | 331 | yield PASS, "At least one code page is defined." |
| 332 | + |
| 333 | + |
| 334 | +@check( |
| 335 | + id = 'com.thetypefounders/check/vendor_id', |
| 336 | + rationale = """ |
| 337 | + When a font project's Vendor ID is specified explicitely on FontBakery's |
| 338 | + configuration file, all binaries must have a matching vendor identifier |
| 339 | + value in the OS/2 table. |
| 340 | + """, |
| 341 | + proposal = 'https://github.com/googlefonts/fontbakery/pull/3941' |
| 342 | +) |
| 343 | +def com_thetypefounders_check_vendor_id(config, ttFont): |
| 344 | + """Checking OS/2 achVendID against configuration.""" |
| 345 | + |
| 346 | + if "vendor_id" not in config: |
| 347 | + yield SKIP, ("Add the `vendor_id` key to a `fontbakery.yaml` file" |
| 348 | + " on your font project directory to enable this check.\n" |
| 349 | + "You'll also need to use the `--configuration` flag when" |
| 350 | + " invoking fontbakery.") |
| 351 | + return |
| 352 | + |
| 353 | + if "OS/2" not in ttFont: |
| 354 | + yield FAIL,\ |
| 355 | + Message("lacks-OS/2", |
| 356 | + "The required OS/2 table is missing.") |
| 357 | + return |
| 358 | + |
| 359 | + config_vendor_id = config['vendor_id'] |
| 360 | + font_vendor_id = ttFont['OS/2'].achVendID |
| 361 | + |
| 362 | + if config_vendor_id != font_vendor_id: |
| 363 | + yield FAIL,\ |
| 364 | + Message("bad-vendor-id", |
| 365 | + f"OS/2 VendorID is '{font_vendor_id}'," |
| 366 | + f" but should be '{config_vendor_id}'.") |
| 367 | + else: |
| 368 | + yield PASS, f"OS/2 VendorID '{font_vendor_id}' is correct." |
0 commit comments