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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
alt_styles = {
Reg = { 400, 100 }, -- Regular
Cond = { 400, 75 },
SmCond = { 400, 87.5 },
SmExp = { 400, 112.5 },
Exp = { 400, 125 },
Light = { 300, 100 }, -- Light
CondLight = { 300, 75 },
SmCondLight = { 300, 87.5 },
SmExpLight = { 300, 112.5 },
ExpLight = { 300, 125 },
Medium = { 500, 100 }, -- Medium
CondMedium = { 500, 75 },
SmCondMedium = { 500, 87.5 },
SmExpMedium = { 500, 112.5 },
ExpMedium = { 500, 125 },
Smbold = { 600, 100 }, -- Semibold
CondSmbold = { 600, 75 },
SmCondSmbold = { 600, 87.5 },
SmExpSmbold = { 600, 112.5 },
ExpSmbold = { 600, 125 },
Bold = { 700, 100 }, -- Bold
CondBold = { 700, 75 },
SmCondBold = { 700, 87.5 },
SmExpBold = { 700, 112.5 },
ExpBold = { 700, 125 }
}
-- 1: Regular, 2: Light, 3: Medium
regular_weights = {
junicodevf_at_RwghtOne = { 490, 390, 590 },
junicodevf_at_RwghtTwo = { 440, 340, 540 },
junicodevf_at_RwghtThree = { 390, 290, 490 },
junicodevf_at_RwghtFour = { 370, 270, 470 },
junicodevf_at_RwghtFive = { 350, 250, 450 },
junicodevf_at_IwghtOne = { 525, 425, 625 },
junicodevf_at_IwghtTwo = { 475, 375, 575 },
junicodevf_at_IwghtThree = { 425, 325, 525 },
junicodevf_at_IwghtFour = { 370, 270, 470 },
junicodevf_at_IwghtFive = { 350, 250, 450 }
}
-- 1: Bold, 2: Semibold
bold_weights = {
junicodevf_at_BwghtOne = { 790, 690 },
junicodevf_at_BwghtTwo = { 740, 640 },
junicodevf_at_BwghtThree = { 690, 590 },
junicodevf_at_BwghtFour = { 650, 550 },
junicodevf_at_BwghtFive = { 600, 500 },
junicodevf_at_BIwghtOne = { 800, 700 },
junicodevf_at_BIwghtTwo = { 775, 675 },
junicodevf_at_BIwghtThree = { 725, 625 },
junicodevf_at_BIwghtFour = { 675, 575 },
junicodevf_at_BIwghtFive = { 625, 525 }
}
-- 1: regular, 2: condensed, 3: semicondensed, 4: semiexpanded, 5: expanded
all_widths = {
junicodevf_at_RwdthOne = { 115, 95, 100, 125, 150 },
junicodevf_at_RwdthTwo = { 107.5, 85, 95, 120, 137.5 },
junicodevf_at_RwdthThree = { 100, 82.5, 90, 112.5, 125 },
junicodevf_at_RwdthFour = { 95, 75, 87.5, 107.5, 120 },
junicodevf_at_RwdthFive = { 90, 70, 77.5, 102.5, 115 },
junicodevf_at_IwdthOne = { 115, 95, 100, 125, 150 },
junicodevf_at_IwdthTwo = { 107.5, 85, 95, 120, 137.5 },
junicodevf_at_IwdthThree = { 100, 82.5, 90, 112.5, 125 },
junicodevf_at_IwdthFour = { 95, 75, 87.5, 107.5, 120 },
junicodevf_at_IwdthFive = { 90, 70, 77.5, 102.5, 115 },
junicodevf_at_BwdthOne = { 115, 95, 100, 125, 150 },
junicodevf_at_BwdthTwo = { 107.5, 85, 95, 120, 137.5 },
junicodevf_at_BwdthThree = { 100, 82.5, 90, 112.5, 125 },
junicodevf_at_BwdthFour = { 95, 75, 87.5, 107.5, 120 },
junicodevf_at_BwdthFive = { 90, 70, 77.5, 102.5, 115 },
junicodevf_at_BIwdthOne = { 115, 95, 100, 125, 150 },
junicodevf_at_BIwdthTwo = { 107.5, 85, 95, 120, 137.5 },
junicodevf_at_BIwdthThree = { 100, 82.5, 90, 112.5, 125 },
junicodevf_at_BIwdthFour = { 95, 75, 87.5, 107.5, 120 },
junicodevf_at_BIwdthFive = { 90, 70, 77.5, 102.5, 115 }
}
function adjustweight(weight, adjustment)
adjusted = weight + adjustment
if adjusted > 800 then adjusted = 800 end
if adjusted < 200 then adjusted = 200 end
return adjusted
end
function adjustwidth(width, adjustment)
adjusted = width + adjustment
if adjusted > 125 then adjusted = 125 end
if adjusted < 75 then adjusted = 75 end
return adjusted
end
function mkaltcommands()
for k, v in pairs(alt_styles) do
romdef = k .. "Def"
romsizedef = k .. "SizeDef"
italsizedef = k .. "ItalicSizeDef"
romfeat = k .. "Features"
romsizefeat = k .. "SizeFeatures"
italsizefeat = k .. "ItalicSizeFeatures"
if k == "Reg" then
romdef = "RegDef"
italsizedef = "ItalicSizeDef"
romfeat = "RegularFeatures"
romsizefeat = "RegularSizeFeatures"
italsizefeat = "ItalicSizeFeatures"
end
tex.print("\\newcommand{\\" .. romdef .. "}{}")
tex.print("\\newcommand{\\" .. romsizedef .. "}{SizeFeatures={{Size={5-}, RawFeature={axis={wght=" ..
v[1] .. ",wdth=" .. v[2] .. "}}}}}")
tex.print("\\DeclareOptionX{" .. romfeat .. "}{\\renewcommand*{\\" .. romdef .. "}{#1,}}")
tex.print("\\DeclareOptionX{" .. romsizefeat .. "}{\\renewcommand*{\\" .. romsizedef .. "}{\\directlua{mksizecommand({#1})}}}")
tex.print("\\DeclareOptionX{" .. italsizefeat .. "}{\\renewcommand*{\\" .. romsizedef .. "}{\\directlua{mksizecommand({#1})}}}")
end
end
function mkregweightcommands(wtidx,adjustment)
for k, wt in pairs(regular_weights) do
cmd, n = string.gsub(k, "_at_", "@")
tex.print("\\newcommand*{\\" .. cmd .. "}{" .. adjustweight(wt[wtidx],adjustment) .. "}")
end
end
function mkboldweightcommands(wtidx,adjustment)
for k, wt in pairs(bold_weights) do
cmd, n = string.gsub(k, "_at_", "@")
tex.print("\\newcommand*{\\" .. cmd .. "}{" .. adjustweight(wt[wtidx],adjustment) .. "}")
end
end
function mkwidthcommands(wdidx, adjustment)
for k, wd in pairs(all_widths) do
cmd, n = string.gsub(k, "_at_", "@")
tex.print("\\newcommand*{\\" .. cmd .. "}{" .. adjustwidth(wd[wdidx],adjustment) .. "}")
end
end
function mkfontcommands()
for k, v in pairs(alt_styles) do
defcmd = k .. "Def"
defsizecmd = k .. "SizeDef"
romfontcmd = "j" .. k
italfontcmd = "j" .. k .. "Italic"
if k == "Reg" then
romfontcmd = "jRegular"
italfontcmd = "jItalic"
end
tex.print("\\junicodevf@newfont{\\" .. romfontcmd .. "}{JunicodeVF}{\\" .. defcmd .. "}{\\" .. defsizecmd .. "}")
tex.print("\\junicodevf@newfont{\\" .. italfontcmd .. "}{JunicodeVF-Italic}{\\" .. defcmd .. "}{\\" .. defsizecmd .. "}")
end
end
function mksizecommand(sizetable)
result = "Nothing yet"
if #sizetable > 0 then
result = "SizeFeatures={"
lastsize = 0
for i, v in ipairs(sizetable) do
if v["size"] then
axiscount = 0
sizeitem = "{Size={"
currentsize = v["size"]
csnum = v["size"]
if i == #sizetable then
currentsize = currentsize .. "-"
elseif lastsize == 0 then
currentsize = "-" .. currentsize
else
currentsize = lastsize .. "-" .. currentsize
end
lastsize = csnum
sizeitem = sizeitem .. currentsize .. "},RawFeature={axis={"
if v["wght"] then
sizeitem = sizeitem .. "wght=" .. v["wght"]
axiscount = axiscount + 1
end
if v["wdth"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "wdth=" .. v["wdth"]
axiscount = axiscount + 1
end
if v["ENLA"] then
if axiscount >= 1 then sizeitem = sizeitem .. "," end
sizeitem = sizeitem .. "ENLA=" .. v["ENLA"]
end
sizeitem = sizeitem .. "}}},"
result = result .. sizeitem
end
end
result = result .. "}"
tex.print(result)
end
end
|