summaryrefslogtreecommitdiffstats
path: root/examples/fbttfchecks.py
blob: 2f3777595c3da814c31d72a88fa43e62c41bdf28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
'''Example for making project-specific changes to the standard pysilfont set of Font Bakery ttf checks.
It will start with all the checks normally run by pysilfont's ttfchecks profile then modify as described below'''
__url__ = 'https://github.com/silnrsi/pysilfont'
__copyright__ = 'Copyright (c) 2020 SIL International (https://www.sil.org)'
__license__ = 'Released under the MIT License (https://opensource.org/licenses/MIT)'
__author__ = 'David Raymond'

from silfont.fbtests.ttfchecks import psfcheck_list, make_profile, check, PASS, FAIL

#
# General settings
#
psfvariable_font = False  # Set to True for variable fonts, so different checks will be run

#
# psfcheck_list is a dictionary of all standard Fontbakery checks with a dictionary for each check indicating
# pysilfont's standard processing of that check
#
# Specifically:
# - If the dictionary has "exclude" set to True, that check will be excluded from the profile
# - If change_status is set, the status values reported by psfrunfbchecks will be changed based on its values
# - If a change in status is temporary - eg just until something is fixed, use temp_change_status instead
#
# Projects can edit this dictionary to change behaviour from Pysilfont defaults.  See examples below

# To reinstate the copyright check (which is normally excluded):
psfcheck_list["com.google.fonts/check/metadata/copyright"]["exclude"] = False

# To prevent the hinting_impact check from running:
psfcheck_list["com.google.fonts/check/hinting_impact"]["exclude"] = True

# To change a FAIL status for com.google.fonts/check/whitespace_glyphnames to WARN:
psfcheck_list["com.google.fonts/check/whitespace_glyphnames"]["temp_change_status"] = {
    "FAIL": "WARN", "reason": "This font currently uses non-standard names"}

#
#  Create the fontbakery profile
#
profile = make_profile(psfcheck_list, variable_font = psfvariable_font)

# Add any project-specific tests (This dummy test should normally be commented out!)

@profile.register_check
@check(
  id = 'org.sil/dummy',
  rationale = """
    There is no reason for this test!
    """
)
def org_sil_dummy():
  """Dummy test that always fails"""
  if True: yield FAIL, "Oops!"

'''
Run this using

  $ psfrunfbchecks --profile fbttfchecks.py <ttf file(s) to check> ...

It can also be used with fontbakery directly if you want to use options that psfrunfbchecks does not support, however
status changes will not be actioned.

  $ fontbakery check-profile fbttfchecks.py <ttf file(s) to check> ...    
  
'''