Skip to content

Commit

Permalink
move all files related to the OpenType profile to a dedicated subdire…
Browse files Browse the repository at this point in the history
…ctory
  • Loading branch information
felipesanches committed Dec 20, 2023
1 parent 97e66f5 commit f8b989e
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
from fontbakery.fonts_profile import profile_factory
from fontbakery.section import Section

from .cff import *
from .cmap import *
from .head import *
from .os2 import *
from .post import *
from .name import *
from .loca import *
from .hhea import *
from .dsig import *
from .gdef import *
from .gpos import *
from .kern import *
from .glyf import *
from .fvar import *
from .stat import *
from .layout import *

profile_imports = (
(
".",
(
"cff",
"cmap",
"head",
"os2",
"post",
"name",
"loca",
"hhea",
"dsig",
"gdef",
"gpos",
"kern",
"glyf",
"fvar",
"stat",
"layout",
"shared_conditions",
),
"..",
("shared_conditions",),
),
)

profile = profile_factory(default_section=Section("OpenType Specification Checks"))

OPENTYPE_PROFILE_CHECKS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from fontbakery.status import FAIL, PASS, WARN
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = ((".", ("shared_conditions",)),)


class CFFAnalysis:
def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from fontbakery.status import FAIL, PASS
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@check(
id="com.google.fonts/check/family/equal_unicode_encodings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from fontbakery.status import WARN, PASS
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@check(
id="com.google.fonts/check/dsig",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
from fontbakery.status import FAIL, PASS, WARN
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = ((".", ("shared_conditions",)),)


@check(
id="com.google.fonts/check/varfont/regular_wght_coord",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from fontbakery.status import PASS, WARN, SKIP
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


def _is_non_spacing_mark_char(charcode):
from fontTools import unicodedata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from fontbakery.callable import check
from fontbakery.status import FAIL, PASS, WARN

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@check(
id="com.google.fonts/check/glyf_unused_data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from fontbakery.status import PASS, WARN
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@condition
def has_kerning_info(ttFont):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from fontbakery.message import Message
from fontbakery.constants import NameID

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@check(
id="com.google.fonts/check/family/equal_font_versions", proposal="legacy:check/014"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from fontbakery.status import FAIL, PASS
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = [(".shared_conditions", ("glyph_metrics_stats", "is_ttf"))]


@check(id="com.google.fonts/check/maxadvancewidth", proposal="legacy:check/073")
def com_google_fonts_check_maxadvancewidth(ttFont):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
from fontbakery.status import FAIL, INFO, PASS, WARN
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611


@check(
id="com.google.fonts/check/kern_table",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from fontbakery.status import PASS, FAIL
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = ((".", ("shared_conditions",)),)


def feature_tags(ttFont):
in_this_font = set()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from fontbakery.status import PASS, FAIL
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = ((".", ("shared_conditions",)),)


@check(
id="com.google.fonts/check/loca/maxp_num_glyphs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
WindowsLanguageID,
)
from fontbakery.utils import markdown_table

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = [(".shared_conditions", ("glyph_metrics_stats", "is_ttf", "is_cff"))]
from fontbakery.profiles.shared_conditions import glyph_metrics_stats, is_ttf, is_cff


@check(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from fontbakery.callable import check
from fontbakery.status import FAIL, PASS, WARN, INFO, SKIP
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = [
(".shared_conditions", ("vmetrics",)),
(".googlefonts_conditions", ("RIBBI_ttFonts",)),
]
from fontbakery.profiles.shared_conditions import vmetrics
from fontbakery.profiles.googlefonts_conditions import RIBBI_ttFonts


@check(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
from fontbakery.status import FAIL, PASS, WARN
from fontbakery.message import Message

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = [(".shared_conditions", ("is_ttf",))]


@check(
id="com.google.fonts/check/family/underline_thickness",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
from fontbakery.status import FAIL, PASS, WARN, SKIP
from fontbakery.utils import bullet_list

# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # noqa:F401 pylint:disable=W0611

profile_imports = ((".", ("shared_conditions",)),)


@check(
id="com.google.fonts/check/varfont/stat_axis_record_for_each_axis",
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontbakery/profiles/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from fontbakery.fonts_profile import profile_factory
from fontbakery.glyphdata import desired_glyph_data
from fontbakery.message import Message
from fontbakery.profiles.layout import feature_tags
from fontbakery.profiles.opentype import OPENTYPE_PROFILE_CHECKS
from fontbakery.profiles.opentype.layout import feature_tags
from fontbakery.section import Section
from fontbakery.status import PASS, FAIL, WARN, INFO, SKIP
from fontbakery.utils import (
Expand Down
10 changes: 6 additions & 4 deletions tests/profiles/cff_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
TEST_FILE,
)
from fontbakery.status import DEBUG, INFO, WARN, ERROR, SKIP, PASS, FAIL
from fontbakery.profiles import cff as cff_profile
from fontbakery.profiles import opentype as opentype_profile

check_statuses = (ERROR, FAIL, SKIP, PASS, WARN, INFO, DEBUG)


def test_check_cff_call_depth():
check = CheckTester(cff_profile, "com.adobe.fonts/check/cff_call_depth")
check = CheckTester(opentype_profile, "com.adobe.fonts/check/cff_call_depth")

# this font's CFF subr call depths should all be <= 10:
font = TEST_FILE("source-sans-pro/OTF/SourceSansPro-Regular.otf")
Expand Down Expand Up @@ -44,7 +44,7 @@ def test_check_cff_call_depth():


def test_check_cff2_call_depth():
check = CheckTester(cff_profile, "com.adobe.fonts/check/cff2_call_depth")
check = CheckTester(opentype_profile, "com.adobe.fonts/check/cff2_call_depth")

# this font's CFF subr call depths should all be <= 10:
font = TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Roman.otf")
Expand Down Expand Up @@ -77,7 +77,9 @@ def test_check_cff2_call_depth():


def test_check_cff_deprecated_operators():
check = CheckTester(cff_profile, "com.adobe.fonts/check/cff_deprecated_operators")
check = CheckTester(
opentype_profile, "com.adobe.fonts/check/cff_deprecated_operators"
)

# this font uses the deprecated 'dotsection' operator
font = TEST_FILE("deprecated_operators/cff1_dotsection.otf")
Expand Down
4 changes: 3 additions & 1 deletion tests/profiles/external_profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def test_external_profile():
assert len(profile.sections) > 1


def test_profile_imports():
## FIXME: Some opentype profile examples here are not valid anymore. Should we update
## the examples, or should we simply deprecate the feature of sub-profiles?
def DISABLE_test_profile_imports():
"""
When a names array in profile_imports contained sub module names, the import
would fail.
Expand Down
2 changes: 1 addition & 1 deletion tests/profiles/head_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_check_unitsperem():

def test_parse_version_string():
"""Checking font version fields."""
from fontbakery.profiles.head import parse_version_string
from fontbakery.profiles.opentype.head import parse_version_string
import fractions

version_tests_good = {
Expand Down
8 changes: 4 additions & 4 deletions tests/profiles/layout_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
CheckTester,
TEST_FILE,
)
from fontbakery.profiles import layout as layout_profile
from fontbakery.profiles import opentype as opentype_profile


def test_check_layout_valid_feature_tags():
"""Does the font have any invalid feature tags?"""
check = CheckTester(
layout_profile, "com.google.fonts/check/layout_valid_feature_tags"
opentype_profile, "com.google.fonts/check/layout_valid_feature_tags"
)

font = TEST_FILE("nunito/Nunito-Regular.ttf")
Expand All @@ -24,7 +24,7 @@ def test_check_layout_valid_feature_tags():
def test_check_layout_valid_script_tags():
"""Does the font have any invalid script tags?"""
check = CheckTester(
layout_profile, "com.google.fonts/check/layout_valid_script_tags"
opentype_profile, "com.google.fonts/check/layout_valid_script_tags"
)

font = TEST_FILE("nunito/Nunito-Regular.ttf")
Expand All @@ -37,7 +37,7 @@ def test_check_layout_valid_script_tags():
def test_check_layout_valid_language_tags():
"""Does the font have any invalid language tags?"""
check = CheckTester(
layout_profile, "com.google.fonts/check/layout_valid_language_tags"
opentype_profile, "com.google.fonts/check/layout_valid_language_tags"
)

font = TEST_FILE("nunito/Nunito-Regular.ttf")
Expand Down

0 comments on commit f8b989e

Please sign in to comment.