Skip to content

Commit 43bcbb5

Browse files
authored
Merge pull request #257 from dalthviz/fix_236
PR: Add version to fonts assets, some error handling for Windows font installation logic and keep up to date update scripts/commands
2 parents 15a3e6a + 87837af commit 43bcbb5

25 files changed

Lines changed: 127 additions & 80 deletions

UPDATE.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
To update _FontAwesome_ icons, one must:
66

77
- check what is the latest released version here: https://github.com/FortAwesome/Font-Awesome/releases/
8+
- update font version in \_\_init__.py
9+
- remove outdated files in the fonts dir
810
- run: `python setup.py update_fa5 --fa-version X.X.X`
911
- update FA version number, icon counts and URLs inside:
1012
- README.md
@@ -55,18 +57,29 @@ import json
5557
import urllib.request
5658
import hashlib
5759

60+
61+
VERSION = '6.9.96' # Update version as required
5862
TTF_URL = 'https://raw.githubusercontent.com/Templarian/MaterialDesign-Webfont/master/fonts/materialdesignicons-webfont.ttf'
5963
CSS_URL = 'https://raw.githubusercontent.com/Templarian/MaterialDesign-Webfont/master/css/materialdesignicons.css'
64+
FONT_FILENAME = "materialdesignicons6-webfont-{version}.ttf".format(
65+
version=VERSION
66+
)
67+
FONT_CHARMAP_FILENAME = (
68+
"materialdesignicons6-webfont-charmap-{version}.json".format(
69+
version=VERSION
70+
)
71+
)
72+
6073

61-
with open('materialdesignicons6-webfont.ttf', 'wb') as fp:
74+
with open(FONT_FILENAME, 'wb') as fp:
6275
req = urllib.request.urlopen(TTF_URL)
6376
if req.status != 200:
6477
raise Exception('Failed to download TTF')
6578
fp.write(req.read())
6679
req.close()
6780

6881
hasher = hashlib.md5()
69-
with open('materialdesignicons6-webfont.ttf', 'rb') as f:
82+
with open(FONT_FILENAME, 'rb') as f:
7083
content = f.read()
7184
hasher.update(content)
7285

@@ -89,7 +102,7 @@ for name, key in data:
89102
name = name.lower()
90103
charmap[name] = key
91104

92-
with open('materialdesignicons6-webfont-charmap.json', 'w') as fp:
105+
with open(FONT_CHARMAP_FILENAME, 'w') as fp:
93106
json.dump(charmap, fp, indent=4, sort_keys=True)
94107

95108
```
@@ -112,18 +125,23 @@ import json
112125
import urllib.request
113126
import hashlib
114127

128+
VERSION = '1.3.0' # Update version as required
115129
TTF_URL = 'https://raw.githubusercontent.com/phosphor-icons/phosphor-icons/master/src/font/phosphor.ttf'
116130
CSS_URL = 'https://raw.githubusercontent.com/phosphor-icons/phosphor-icons/master/src/css/phosphor.css'
131+
FONT_FILENAME = 'phosphor-{version}.ttf'.format(version=VERSION)
132+
FONT_CHARMAP_FILENAME = "phosphor-charmap-{version}.json".format(
133+
version=VERSION
134+
)
117135

118-
with open('phosphor.ttf', 'wb') as fp:
136+
with open(FONT_FILENAME, 'wb') as fp:
119137
req = urllib.request.urlopen(TTF_URL)
120138
if req.status != 200:
121139
raise Exception('Failed to download TTF')
122140
fp.write(req.read())
123141
req.close()
124142

125143
hasher = hashlib.md5()
126-
with open('phosphor.ttf', 'rb') as f:
144+
with open(FONT_FILENAME, 'rb') as f:
127145
content = f.read()
128146
hasher.update(content)
129147

@@ -145,7 +163,7 @@ for name, key in data:
145163
name = name.lower()
146164
charmap[name] = key
147165

148-
with open('phosphor-charmap.json', 'w') as fp:
166+
with open(FONT_CHARMAP_FILENAME, 'w') as fp:
149167
json.dump(charmap, fp, indent=4, sort_keys=True)
150168

151169
```
@@ -168,18 +186,23 @@ import json
168186
import urllib.request
169187
import hashlib
170188

189+
VERSION = '2.5.0' # Update version as required
171190
TTF_URL = 'https://raw.githubusercontent.com/Remix-Design/RemixIcon/master/fonts/remixicon.ttf'
172191
CSS_URL = 'https://raw.githubusercontent.com/Remix-Design/RemixIcon/master/fonts/remixicon.css'
192+
FONT_FILENAME = 'remixicon-{version}.ttf'.format(version=VERSION)
193+
FONT_CHARMAP_FILENAME = "remixicon-charmap-{version}.json".format(
194+
version=VERSION
195+
)
173196

174-
with open('remixicon.ttf', 'wb') as fp:
197+
with open(FONT_FILENAME, 'wb') as fp:
175198
req = urllib.request.urlopen(TTF_URL)
176199
if req.status != 200:
177200
raise Exception('Failed to download TTF')
178201
fp.write(req.read())
179202
req.close()
180203

181204
hasher = hashlib.md5()
182-
with open('remixicon.ttf', 'rb') as f:
205+
with open(FONT_FILENAME, 'rb') as f:
183206
content = f.read()
184207
hasher.update(content)
185208

@@ -201,7 +224,7 @@ for name, key in data:
201224
name = name.lower()
202225
charmap[name] = key
203226

204-
with open('remixicon-charmap.json', 'w') as fp:
227+
with open(FONT_CHARMAP_FILENAME, 'w') as fp:
205228
json.dump(charmap, fp, indent=4, sort_keys=True)
206229

207230
```
@@ -211,6 +234,8 @@ with open('remixicon-charmap.json', 'w') as fp:
211234
To update _Codicons_ icons, one must:
212235

213236
- check what is the latest released version here: https://github.com/microsoft/vscode-codicons/releases
237+
- update font version in \_\_init__.py
238+
- remove outdated files in the fonts dir
214239
- run: `python setup.py update_msc`
215240
- update Codicons version number, icon counts and URLs inside:
216241
- README.md

qtawesome/__init__.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,50 @@
3434

3535
_BUNDLED_FONTS = (
3636
('fa',
37-
'fontawesome4.7-webfont.ttf',
38-
'fontawesome4.7-webfont-charmap.json'),
37+
'fontawesome4-webfont-4.7.ttf',
38+
'fontawesome4-webfont-charmap-4.7.json'),
3939
('fa5',
40-
'fontawesome5-regular-webfont.ttf',
41-
'fontawesome5-regular-webfont-charmap.json'),
40+
'fontawesome5-regular-webfont-5.15.4.ttf',
41+
'fontawesome5-regular-webfont-charmap-5.15.4.json'),
4242
('fa5s',
43-
'fontawesome5-solid-webfont.ttf',
44-
'fontawesome5-solid-webfont-charmap.json'),
43+
'fontawesome5-solid-webfont-5.15.4.ttf',
44+
'fontawesome5-solid-webfont-charmap-5.15.4.json'),
4545
('fa5b',
46-
'fontawesome5-brands-webfont.ttf',
47-
'fontawesome5-brands-webfont-charmap.json'),
46+
'fontawesome5-brands-webfont-5.15.4.ttf',
47+
'fontawesome5-brands-webfont-charmap-5.15.4.json'),
4848
('ei',
49-
'elusiveicons-webfont.ttf',
50-
'elusiveicons-webfont-charmap.json'),
49+
'elusiveicons-webfont-2.0.ttf',
50+
'elusiveicons-webfont-charmap-2.0.json'),
5151
('mdi',
52-
'materialdesignicons5-webfont.ttf',
53-
'materialdesignicons5-webfont-charmap.json'),
52+
'materialdesignicons5-webfont-5.9.55.ttf',
53+
'materialdesignicons5-webfont-charmap-5.9.55.json'),
5454
('mdi6',
55-
'materialdesignicons6-webfont.ttf',
56-
'materialdesignicons6-webfont-charmap.json'),
55+
'materialdesignicons6-webfont-6.9.96.ttf',
56+
'materialdesignicons6-webfont-charmap-6.9.96.json'),
5757
('ph',
58-
'phosphor.ttf',
59-
'phosphor-charmap.json'),
58+
'phosphor-1.3.0.ttf',
59+
'phosphor-charmap-1.3.0.json'),
6060
('ri',
61-
'remixicon.ttf',
62-
'remixicon-charmap.json'),
61+
'remixicon-2.5.0.ttf',
62+
'remixicon-charmap-2.5.0.json'),
6363
('msc',
64-
'codicon.ttf',
65-
'codicon-charmap.json'),
64+
'codicon-0.0.35.ttf',
65+
'codicon-charmap-0.0.35.json'),
6666
)
6767

6868

6969
# MD5 Hashes for font files bundled with qtawesome:
7070
_MD5_HASHES = {
71-
'fontawesome4.7-webfont.ttf': 'b06871f281fee6b241d60582ae9369b9',
72-
'fontawesome5-regular-webfont.ttf': 'dc47e4089f5bcb25f241bdeb2de0fb58',
73-
'fontawesome5-solid-webfont.ttf': '5de19800fc9ae73438c2e5c61d041b48',
74-
'fontawesome5-brands-webfont.ttf': '513aa607d398efaccc559916c3431403',
75-
'elusiveicons-webfont.ttf': '207966b04c032d5b873fd595a211582e',
76-
'materialdesignicons5-webfont.ttf': 'b7d40e7ef80c1d4af6d94902af66e524',
77-
'materialdesignicons6-webfont.ttf': 'ecaabfbb23fdac4ddbaf897b97257a92',
78-
'phosphor.ttf': '5b8dc57388b2d86243566b996cc3a789',
79-
'remixicon.ttf': '888e61f04316f10bddfff7bee10c6dd0',
80-
'codicon.ttf': '2b89de3354b7768e193c0ec14571422b',
71+
'fontawesome4-webfont-4.7.ttf': 'b06871f281fee6b241d60582ae9369b9',
72+
'fontawesome5-regular-webfont-5.15.4.ttf': 'dc47e4089f5bcb25f241bdeb2de0fb58',
73+
'fontawesome5-solid-webfont-5.15.4.ttf': '5de19800fc9ae73438c2e5c61d041b48',
74+
'fontawesome5-brands-webfont-5.15.4.ttf': '513aa607d398efaccc559916c3431403',
75+
'elusiveicons-webfont-2.0.ttf': '207966b04c032d5b873fd595a211582e',
76+
'materialdesignicons5-webfont-5.9.55.ttf': 'b7d40e7ef80c1d4af6d94902af66e524',
77+
'materialdesignicons6-webfont-6.9.96.ttf': 'ecaabfbb23fdac4ddbaf897b97257a92',
78+
'phosphor-1.3.0.ttf': '5b8dc57388b2d86243566b996cc3a789',
79+
'remixicon-2.5.0.ttf': '888e61f04316f10bddfff7bee10c6dd0',
80+
'codicon-0.0.35.ttf': '2b89de3354b7768e193c0ec14571422b',
8181
}
8282

8383

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

qtawesome/fonts/fontawesome5-brands-webfont-charmap.json renamed to qtawesome/fonts/fontawesome5-brands-webfont-charmap-5.15.4.json

File renamed without changes.

0 commit comments

Comments
 (0)