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

No open corners check #4809

Merged
merged 2 commits into from
Aug 8, 2024
Merged
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
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ A more detailed list of changes is available in the corresponding milestones for

## Upcoming release: 0.12.10 (2024-Jul-??)
### Changes to existing checks
#### On the UFO profile
- **EXPERIMENTAL - [com.daltonmaag/check/consistent_curve_type]:**: remove usage of `ufoLib2` APIs
- **EXPERIMENTAL - [com.daltonmaag/check/consistent_curve_type]:**: remove usage of `ufoLib2` APIs. (PR #4802)

### New checks
#### Added to the UFO profile
- **EXPERIMENTAL - [com.daltonmaag/check/consistent_curve_type]:**: checks that a consistent curve type is used across the font sources as well as within glyphs. (PR #4795)
- **EXPERIMENTAL - [com.daltonmaag/check/no_open_corners]:** checks that sources don't contain open corners, intended for use in font projects with a roundness axis. (PR #4808)


## 0.12.9 (2024-Jul-17)
### New checks
#### Added to the Universal profile
- **EXPERIMENTAL - [com.arrowtype.fonts/check/typoascender_exceeds_Agrave]:** Check that the typoAscender exceeds the yMax of the /Agrave (issue #3170)

#### Added to the UFO profile
- **EXPERIMENTAL - [com.daltonmaag/check/consistent_curve_type]:**: checks that a consistent curve type is used across the font sources as well as within glyphs. (PR #4795)

### Changes to existing checks
#### On the Universal profile
- **[com.google.fonts/check/gsub/smallcaps_before_ligatures]:** Skip check if font lacks GSUB table or font is missing either liga or smcp features. (PR #4787)
Expand Down
40 changes: 40 additions & 0 deletions Lib/fontbakery/checks/ufo.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,43 @@ def check_consistent_curve_type(config, ufo: Ufo):
PASS,
"All curves of all glyphs use a consistent curve type",
)


@check(
id="com.daltonmaag/check/no_open_corners",
rationale="""
This may be a requirement when creating a font that supports a roundness
axis.
""",
conditions=["ufo_font"],
proposal="https://github.com/fonttools/fontbakery/pull/4808",
)
def check_no_open_corners(config, ufo):
"""Check the sources have no corners"""
from glyphsLib.filters.eraseOpenCorners import EraseOpenCornersPen
from fontTools.pens.basePen import NullPen

font = ufo.ufo_font
for layer in font.layers:
offending_glyphs = []
for glyph in layer:
erase_open_corners = EraseOpenCornersPen(NullPen())
for contour in glyph:
contour.draw(erase_open_corners)
if erase_open_corners.affected:
offending_glyphs.append(glyph.name)

if offending_glyphs:
location_str = (
"Default layer"
if layer.name == font.layers.defaultLayer.name
else layer.name
)
yield (
FAIL,
Message(
"open-corners-found",
f"{location_str} contains glyphs with open corners:\n\n"
f"{utils.bullet_list(config, offending_glyphs)}\n",
),
)
11 changes: 7 additions & 4 deletions Lib/fontbakery/profiles/ufo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
"name": "UFO Sources",
"sections": {
"UFO Sources": [
"com.daltonmaag/check/ufolint",
"com.daltonmaag/check/ufo_required_fields",
"com.daltonmaag/check/ufo_recommended_fields",
"com.daltonmaag/check/ufo_unnecessary_fields",
# FIXME (orphan check): "com.daltonmaag/check/consistent_curve_type",
# https://github.com/fonttools/fontbakery/pull/4809
"com.google.fonts/check/designspace_has_sources",
"com.google.fonts/check/designspace_has_default_master",
"com.google.fonts/check/designspace_has_consistent_glyphset",
"com.google.fonts/check/designspace_has_consistent_codepoints",
"com.thetypefounders/check/features_default_languagesystem",
# FIXME (orphan check): "com.daltonmaag/check/no_open_corners",
"com.daltonmaag/check/ufolint",
"com.daltonmaag/check/ufo_required_fields",
"com.daltonmaag/check/ufo_recommended_fields",
"com.daltonmaag/check/ufo_unnecessary_fields",
]
},
}
2 changes: 2 additions & 0 deletions data/test/test.ufo/glyphs/contents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<string>B_.glif</string>
<key>C</key>
<string>C_.glif</string>
<key>square</key>
<string>square.glif</string>
</dict>
</plist>
17 changes: 17 additions & 0 deletions data/test/test.ufo/glyphs/square.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="square" format="2">
<advance width="600"/>
<outline>
<contour>
<!-- Intentional open corners for test_check_no_open_corners -->
<point x="547" y="128" type="line"/>
<point x="495" y="100" type="line"/>
<point x="482" y="454" type="line"/>
<point x="530" y="423" type="line"/>
<point x="110" y="417" type="line"/>
<point x="156" y="460" type="line"/>
<point x="163" y="100" type="line"/>
<point x="111" y="119" type="line"/>
</contour>
</outline>
</glyph>
1 change: 1 addition & 0 deletions data/test/test.ufo/lib.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string>A</string>
<string>B</string>
<string>C</string>
<string>square</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions tests/checks/ufo_sources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,17 @@ def test_check_consistent_curve_type_check(empty_ufo_font) -> None:
# Cubics & quadratics, all in one glyph
ufo.insertGlyph(mixed_glyph, "mixed")
assert_results_contain(check(ufo), WARN, "mixed-glyphs")


def test_check_no_open_corners() -> None:
"""Ensure the check identifies open corners correctly"""
check = CheckTester("com.daltonmaag/check/no_open_corners")

ufo = defcon.Font(TEST_FILE("test.ufo"))

assert_results_contain(check(ufo), FAIL, "open-corners-found")

# Remove glyph with open corners
del ufo["square"]

assert_PASS(check(ufo))
Loading