-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-my-metadata.py
67 lines (55 loc) · 1.63 KB
/
set-my-metadata.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
#FLM: Set my metadata
# Set all my personal metadata
import os
font = fl.font
# Base name on filename
fontName = os.path.basename(os.path.splitext(font.file_name)[0]).strip()
nameParts = fontName.split()
styleNames = []
font.font_style = 0
font.weight = "Regular"
font.weight_code = 400
if "Bold" in nameParts:
styleNames.append("Bold")
nameParts.remove("Bold")
font.font_style += 32
font.weight = "Bold"
font.weight_code = 700
if "SemiBold" in nameParts:
styleNames.append("SemiBold")
nameParts.remove("SemiBold")
font.font_style += 32
font.weight = "SemiBold"
font.weight_code = 600
if "Italic" in nameParts:
styleNames.append("Italic")
nameParts.remove("Italic")
font.font_style += 1
familyName = " ".join(nameParts)
appleName = familyName
if styleNames:
styleName = " ".join(styleNames)
appleName += " " + styleName
else:
styleName = "Regular"
fullName = familyName + " " + styleName
# Set all standard names
font.family_name = familyName
font.style_name = styleName
font.font_name = familyName.replace(' ', '') + "-" + styleName.replace(' ', '')
font.full_name = fullName
font.menu_name = familyName
font.apple_name = appleName
# Personalized creator info
font.designer = "Damien Guard"
font.designer_url = "https://damieng.com"
font.year = 2019
font.copyright = "Copyright 2019 Damien Guard."
font.vendor = "ENVY"
font.vendor_url = "https://envytech.com"
# Set OpenType & TrueType data
font.pref_family_name = familyName
font.pref_style_name = styleName
font.mac_compatible = fullName
font.tt_u_id = font.designer.replace(' ','') + ": " + fullName + ": " + str(font.year)
fl.UpdateFont()