forked from adobe-type-tools/afdko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproofpdf_test.py
173 lines (151 loc) · 5.78 KB
/
proofpdf_test.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import pytest
from runner import main as runner
from differ import main as differ
from test_utils import get_input_path, get_expected_path, get_temp_file_path
def _get_filename_label(file_name):
sep_index = file_name.find('_')
if sep_index == -1:
return ''
return file_name.split('.')[0][sep_index:]
# -----
# Tests
# -----
@pytest.mark.parametrize('font_filename', [
'cidfont.otf',
'font.otf',
'font.ttf',
])
@pytest.mark.parametrize('tool_name', [
'charplot',
'digiplot',
'fontplot',
'fontplot2',
'hintplot',
'waterfallplot',
])
def test_glyphs_2_7(tool_name, font_filename):
if 'cid' in font_filename:
font_format = 'cid'
elif 'ttf' in font_filename:
font_format = 'ttf'
else:
font_format = 'otf'
pdf_filename = f'{tool_name}_{font_format}_glyphs_2-7.pdf'
font_path = get_input_path(font_filename)
save_path = get_temp_file_path()
runner(['-t', tool_name, '-o', 'o', f'_{save_path}', 'g', '_2-7',
'dno', '=pageIncludeTitle', '_0', '-f', font_path, '-a'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
@pytest.mark.parametrize('font_filename', [
'cidfont_noHints.otf',
'cidfont_noStems.otf',
'cidfont_noZones.otf',
'font_noHints.otf',
'font_noStems.otf',
'font_noZones.otf',
])
@pytest.mark.parametrize('tool_name', [
'hintplot',
'waterfallplot',
])
def test_hinting_data(tool_name, font_filename):
label = _get_filename_label(font_filename)
if 'cid' in font_filename:
font_format = 'cid'
elif 'ttf' in font_filename:
font_format = 'ttf'
else:
font_format = 'otf'
pdf_filename = f'{tool_name}_{font_format}{label}.pdf'
font_path = get_input_path(font_filename)
save_path = get_temp_file_path()
runner(['-t', tool_name, '-o', 'o', f'_{save_path}', 'g', '_2-7',
'dno', '=pageIncludeTitle', '_0', '-f', font_path, '-a'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
@pytest.mark.parametrize('font_filename, glyphs', [
('cidfont.otf', '_0-5,98-101'),
('font.otf', '_0-2,4,5'),
])
def test_fontplot2_lf_option(font_filename, glyphs):
tool_name = 'fontplot2'
if 'cid' in font_filename:
font_format = 'cid'
else:
font_format = 'otf'
layout_path = get_input_path('CID_layout')
font_path = get_input_path(font_filename)
pdf_filename = f'{tool_name}_{font_format}_lf_option.pdf'
save_path = get_temp_file_path()
runner(['-t', tool_name, '-o', 'o', f'_{save_path}', 'dno',
'g', glyphs, 'lf', f'_{layout_path}',
'=pageIncludeTitle', '_0', '-f', font_path, '-a'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
def test_fontsetplot():
f1 = 'SourceSansPro-Black.otf'
f2 = 'SourceSansPro-BlackIt.otf'
pdf_filename = "fontsetplot_otf_glyphs_2-7.pdf"
fp1 = get_input_path(f1)
fp2 = get_input_path(f2)
save_path = get_temp_file_path()
runner(['-t', 'fontsetplot', '-o', 'o', f'_{save_path}', 'dno',
'g', '_2-7', '=pageIncludeTitle', '_0', f'_{fp1}', f'_{fp2}'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
@pytest.mark.parametrize('filename', ['SourceSansPro-Black',
'SourceSansPro-BlackIt'])
def test_waterfallplot(filename):
font_filename = f'{filename}.otf'
pdf_filename = f'{filename}.pdf'
font_path = get_input_path(font_filename)
save_path = get_temp_file_path()
expected_path = get_expected_path(pdf_filename)
runner(['-t', 'waterfallplot',
'-o', 'o', f'_{save_path}', 'dno', '-f', font_path, '-a'])
assert differ([expected_path, save_path,
'-s', '/CreationDate',
'-r', r'^BT 1 0 0 1 \d{3}\.\d+ 742\.0000 Tm', # timestamp
'-e', 'macroman'])
@pytest.mark.parametrize('tool_name', [
'charplot',
'digiplot',
'fontplot',
'fontplot2',
'hintplot',
'waterfallplot',
])
def test_seac_in_charstring_bug125(tool_name):
pdf_filename = f'bug125_{tool_name}.pdf'
font_path = get_input_path('seac.otf')
save_path = get_temp_file_path()
runner(['-t', tool_name, '-o', 'o', f'_{save_path}', 'dno',
'=pageIncludeTitle', '_0', '-f', font_path, '-a'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
@pytest.mark.parametrize('font_format', ['otf', 'ttf'])
def test_round_glyph_bounds_values_bug128(font_format):
bug_numb = 'bug128'
pdf_filename = f'{bug_numb}_{font_format}.pdf'
font_path = get_input_path(f'{bug_numb}/font.{font_format}')
save_path = get_temp_file_path()
runner(['-t', 'charplot', '-o', 'o', f'_{save_path}', 'g', '_o',
'dno', '=pageIncludeTitle', '_0', '-f', font_path, '-a'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])
def test_fontsetplot_ttf_with_components_bug1125():
pdf_filename = "bug1125.pdf"
font_path = get_input_path('bug1125.ttf')
save_path = get_temp_file_path()
runner(['-t', 'fontsetplot', '-o', 'o', f'_{save_path}', 'dno',
'=pageIncludeTitle', '_0', f'_{font_path}'])
expected_path = get_expected_path(pdf_filename)
assert differ([expected_path, save_path,
'-s', '/CreationDate', '-e', 'macroman'])