-
Notifications
You must be signed in to change notification settings - Fork 2
/
svg2otf.lua
60 lines (51 loc) · 1.96 KB
/
svg2otf.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
58
59
60
require("fflua")
local function CHR(a,b,c,d)
-- CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
local a = tostring(a) or ''
local b = tostring(b) or ''
local c = tostring(c) or ''
local d = tostring(d) or ''
local len = string.len
local byte= string.byte
assert(len(a)==1,"Error on input data:first char must 1 byte")
assert(len(b)==1,"Error on input data:second char must 1 byte")
assert(len(c)==1,"Error on input data:third char must 1 byte")
assert(len(d)==1,"Error on input data:fourth char must 1 byte")
return byte(a)*2^24+byte(b)*2^16+byte(c)*2^8+byte(d)*8^0
end
if fflua.CHR ~= nil then fflua.CHR = CHR end
local fontfile = "ConcreteOT.svg"
local openflags = 0
local sf = fflua.LoadSplineFont(fontfile,openflags)
--print(sf)
--print(sf.map.enc.enc_name)
lk = fflua.SFFindLookup(sf,sf.gsub_lookups.lookup_name)
--print(lk.lookup_name)
--print(lk.lookup_type)
--print(swig_type(lk.features.featuretag),lk.features.featuretag)
--print(swig_type(lk.features.scripts),lk.features.scripts)
--print(swig_type(lk.features.scripts.script),lk.features.scripts.script)
script_tag = CHR('l','a','t','n')
lang_tag = fflua.DEFAULT_LANG
fflua.FListAppendScriptLang(lk.features,script_tag,lang_tag)
encmap = sf.map
fflua.SFDWrite("ConcreteOT.sfd",sf,encmap,encmap,0)
-- extern int GenerateScript(SplineFont *sf,char *filename,char *bitmaptype,
-- int fmflags,int res, char *subfontdirectory,struct sflist *sfs,
-- EncMap *map,NameList *rename_to,int layer);
--
filename = "ConcreteOT.otf"
bitmaptype = ""
fmflags = -1
res = -1
subfontdirectory = ""
sfs = nil
map = sf.map
rename_to = fflua.DefaultNameListForNewFonts()
layer = 1
fflua.GenerateScript(sf,filename,bitmaptype,
fmflags,res,subfontdirectory,sfs,
map,rename_to,layer);
--[===[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Code inside here is commented.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]===]--