-
Notifications
You must be signed in to change notification settings - Fork 20
/
conftest.py
145 lines (100 loc) · 3.31 KB
/
conftest.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
import os
from fontTools.ttLib import TTFont
import pytest
import requests
import uharfbuzz as hb
REPO = 'https://github.com/adobe-fonts/adobe-variable-font-prototype/'
OTF_NAME = 'AdobeVFPrototype.otf'
TTF_NAME = 'AdobeVFPrototype.ttf'
@pytest.fixture(scope="session")
def latest_otf_path():
"""Retrieve and save the GitHub "latest" OTF"""
p = os.path.join("RomanMasters", OTF_NAME.replace(".otf", "_latest.otf"))
if not os.path.isfile(p):
# download it if we don't have it
url = REPO + 'releases/latest/download/' + OTF_NAME
response = requests.get(url)
if response.status_code != 200:
raise Exception(f"Error retrieving latest {OTF_NAME} from GitHub.")
with open(p, 'wb') as f:
f.write(response.content)
return p
@pytest.fixture(scope="session")
def latest_otf(latest_otf_path):
"""HB Font from latest OTF"""
with open(latest_otf_path, 'rb') as font_file:
font_data = font_file.read()
face = hb.Face(font_data)
font = hb.Font(face)
upem = face.upem
font.scale = (upem, upem)
hb.ot_font_set_funcs(font)
return font
@pytest.fixture(scope="session")
def latest_otf_ft(latest_otf_path):
"""FontTools Font for latest OTF"""
font = TTFont(latest_otf_path)
return font
@pytest.fixture(scope="session")
def latest_ttf_path():
"""Retrieve and save the GitHub "latest" TTF"""
p = os.path.join("RomanMasters", TTF_NAME.replace(".ttf", "_latest.ttf"))
if not os.path.isfile(p):
# download it if we don't have it
url = REPO + 'releases/latest/download/' + TTF_NAME
response = requests.get(url)
if response.status_code != 200:
raise Exception(f"Error retrieving latest {TTF_NAME} from GitHub.")
with open(p, 'wb') as f:
f.write(response.content)
return p
@pytest.fixture(scope="session")
def latest_ttf(latest_ttf_path):
"""HB Font from latest TTF"""
with open(latest_ttf_path, 'rb') as font_file:
font_data = font_file.read()
face = hb.Face(font_data)
font = hb.Font(face)
upem = face.upem
font.scale = (upem, upem)
hb.ot_font_set_funcs(font)
return font
@pytest.fixture(scope="session")
def latest_ttf_ft(latest_ttf_path):
"""FontTools Font for latest TTF"""
font = TTFont(latest_ttf_path)
return font
@pytest.fixture(scope="session")
def otf_path():
return os.path.join('RomanMasters', OTF_NAME)
@pytest.fixture(scope="session")
def otf_font(otf_path):
with open(otf_path, 'rb') as font_file:
font_data = font_file.read()
face = hb.Face(font_data)
font = hb.Font(face)
upem = face.upem
font.scale = (upem, upem)
hb.ot_font_set_funcs(font)
return font
@pytest.fixture(scope="session")
def otf_ft_font(otf_path):
font = TTFont(otf_path)
return font
@pytest.fixture(scope="session")
def ttf_path():
return os.path.join('RomanMasters', TTF_NAME)
@pytest.fixture(scope="session")
def ttf_font(ttf_path):
with open(ttf_path, 'rb') as font_file:
font_data = font_file.read()
face = hb.Face(font_data)
font = hb.Font(face)
upem = face.upem
font.scale = (upem, upem)
hb.ot_font_set_funcs(font)
return font
@pytest.fixture(scope="session")
def ttf_ft_font(ttf_path):
font = TTFont(ttf_path)
return font