Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move all files related to the OpenType profile to a dedicated subdirectory #4391

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 * # noqa:F401,F403
from .cmap import * # noqa:F401,F403
from .head import * # noqa:F401,F403
from .os2 import * # noqa:F401,F403
from .post import * # noqa:F401,F403
from .name import * # noqa:F401,F403
from .loca import * # noqa:F401,F403
from .hhea import * # noqa:F401,F403
from .dsig import * # noqa:F401,F403
from .gdef import * # noqa:F401,F403
from .gpos import * # noqa:F401,F403
from .kern import * # noqa:F401,F403
from .glyf import * # noqa:F401,F403
from .fvar import * # noqa:F401,F403
from .stat import * # noqa:F401,F403
from .layout import * # noqa:F401,F403

profile_imports = (
(
".",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand how profile_imports works (why do we even have our own system for importing things?!) but can't we change just this to .opentype and leave the rest?

* imports are a bad idea (as the linter is telling you) because they make the namespace unpredictable. It's fine for something like this where we're not really doing any code, but in general you don't want adding a utility function to module B to suddenly add a new defined symbol to module A.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is part of the "magic" behaviour of inferring conditions and args to checks.

I have been actually working on a refactor of the profile to not use those profile_import
statements, but by doing so, I think I started to grasp why they're there.

I'm pushing an updated set of commits now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree about the import * being usually a bad idea.

(
"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 @@ -7,12 +7,6 @@
WindowsEncodingID,
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"))]


@check(
Expand Down Expand Up @@ -426,7 +420,7 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont):
def com_adobe_fonts_check_postscript_name(ttFont):
"""PostScript name follows OpenType specification requirements?"""
import re
from fontbakery.utils import get_name_entry_strings
from fontbakery.utils import get_name_entry_strings, markdown_table

bad_entries = []

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
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.googlefonts_conditions import ( # noqa:F401,E501 pylint:disable=W0611
RIBBI_ttFonts,
)


@check(
Expand Down Expand Up @@ -252,7 +247,9 @@ def com_adobe_fonts_check_fsselection_matches_macstyle(ttFont):
""",
proposal="https://github.com/fonttools/fontbakery/pull/2388",
)
def com_adobe_fonts_check_family_bold_italic_unique_for_nameid1(RIBBI_ttFonts):
def com_adobe_fonts_check_family_bold_italic_unique_for_nameid1(
RIBBI_ttFonts, # noqa:F811
):
"""Check that OS/2.fsSelection bold & italic settings are unique
for each NameID1"""
from collections import Counter
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
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"fontbakery",
"fontbakery.reporters",
"fontbakery.profiles",
"fontbakery.profiles.opentype",
"fontbakery.commands",
"fontbakery.sphinx_extensions", # for FontBakery's documentation at ReadTheDocs
],
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