-
Notifications
You must be signed in to change notification settings - Fork 3
/
luametalatex-pdf-font-t1.lua
57 lines (56 loc) · 2.36 KB
/
luametalatex-pdf-font-t1.lua
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
local readfile = require'luametalatex-readfile'
-- Some helpers:
local serialize_cff = require'luametalatex-font-cff'
local serializet2 = require'luametalatex-font-t2'
local parseT1 = require'luametalatex-font-t1'
local t1tot2 = require'luametalatex-font-t1tot2'
return function(filename, reencode)
local file <close> = readfile('type1', filename)
local parsed_t1 = parseT1(file())
return function(f, usedcids)
f.bbox = parsed_t1.FontBBox
local fonttable = {
version = parsed_t1.FontInfo.version,
Notice = parsed_t1.FontInfo.Notice,
FullName = parsed_t1.FontInfo.FullName,
FamilyName = parsed_t1.FontInfo.FamilyName,
Weight = parsed_t1.FontInfo.Weight,
ItalicAngle = parsed_t1.FontInfo.ItalicAngle,
isFixedPitch = parsed_t1.FontInfo.isFixedPitch,
UnderlinePosition = parsed_t1.FontInfo.UnderlinePosition,
UnderlineThickness = parsed_t1.FontInfo.UnderlineThickness,
FontName = parsed_t1.FontName,
FontMatrix = parsed_t1.FontMatrix,
FontBBox = parsed_t1.FontBBox,
-- UniqueID = parsed_t1.UniqueID,
-- ? = parsed_t1.Metrics,
---- PRIVATE ----
BlueValues = parsed_t1.Private.BlueValues,
OtherBlues = parsed_t1.Private.OtherBlues,
-- FamilyBlues?
BlueScale = parsed_t1.Private.BlueScale,
BlueShift = parsed_t1.Private.BlueShift,
BlueFuzz = parsed_t1.Private.BlueFuzz,
StdHW = (parsed_t1.Private.StdHW or {})[1], -- Why are these arrays in T1?
StdVW = (parsed_t1.Private.StdVW or {})[1], -- They are also undocumented in the spec...
StemSnapH = parsed_t1.Private.StemSnapH,
StemSnapV = parsed_t1.Private.StemSnapV,
ForceBold = parsed_t1.Private.ForceBold,
-- LanguageGroup = parsed_t1.Private.LanguageGroup,
}
if not reencode and parsed_t1.Encoding == "StandardEncoding" then
reencode = '8a'
end
if reencode then
parsed_t1.Encoding = require'luametalatex-font-enc'(reencode)
end
-- parsed_t1.Encoding[0] = ".notdef"
local glyphs = {}
fonttable.glyphs = glyphs
for i=1,#usedcids do
local name = parsed_t1.Encoding[usedcids[i][1]] -- TODO: Reencoding and StandardEncoding
glyphs[#glyphs + 1] = {index = usedcids[i][1], name = name, cs = serializet2(t1tot2(parsed_t1.CharStrings[name], parsed_t1.Private.Subrs))} -- TODO: Missing glyphs
end
return serialize_cff(fonttable)
end
end