-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathtest_checks_base_has_width.py
48 lines (37 loc) · 1.12 KB
/
test_checks_base_has_width.py
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
from io import BytesIO
from fontTools.ttLib import TTFont
from conftest import check_id
from fontbakery.status import FAIL
from fontbakery.codetesting import (
assert_PASS,
assert_results_contain,
TEST_FILE,
)
def get_test_font():
import defcon
import ufo2ft
test_ufo = defcon.Font(TEST_FILE("test.ufo"))
# Add a PUA character that has no width
glyph = test_ufo.newGlyph("uniF176")
glyph.unicode = 0xF176
test_ttf = ufo2ft.compileTTF(test_ufo)
# Make the CheckTester class happy... :-P
stream = BytesIO()
test_ttf.save(stream)
stream.seek(0)
test_ttf = TTFont(stream)
test_ttf.reader.file.name = "in-memory-data.ttf"
return test_ttf
@check_id("base_has_width")
def test_check_base_has_width(check):
"""Do some base characters have zero width?"""
ttfont = get_test_font()
assert_PASS(check(ttfont), "if acute has width...")
ttfont["hmtx"].metrics["A"] = (0, 0)
message = assert_results_contain(
check(ttfont),
FAIL,
"zero-width-bases",
"following glyphs had zero advance width",
)
assert "U+0041" in message