require('lualibs-lpeg') -- string.split
require('lualibs-os') -- os.type
+require('lualibs-gzip') -- gzip.*
do
local kpse_var_value = kpse.var_value
end
local function save_cache(filename, t)
- local fullpath = savepath .. '/' .. filename .. '.lua'
+ local fullpath = savepath .. '/' .. filename .. '.lua.gz'
local s = serialize(t, 'return', false, serial_spec)
if s then
- local f = io.open(fullpath, 'wb')
- if f then
- f:write(s)
- texio.write('(save cache: ' .. fullpath .. ')')
- f:close()
- end
- save_cache_luc(filename, t, s)
+ gzip.save(fullpath, s, 1)
+ texio.write('(save cache: ' .. fullpath .. ')')
+ save_cache_luc(filename, t, s)
end
end
- local function load_cache_a(filename, outdate)
+ local function load_cache_a(filename, outdate, compressed)
local result
for _,v in pairs(path) do
local fn = join(v, cache_dir, filename)
if isreadable(fn) then
texio.write('(load cache: ' .. fn .. ')')
- result = loadfile(fn)
+ if compressed then
+ result = loadstring(gzip.load(fn))
+ else
+ result = loadfile(fn)
+ end
result = result and result()
break
end
end
local function load_cache(filename, outdate)
- local r = load_cache_a(filename .. luc_suffix, outdate)
+ local r = load_cache_a(filename .. luc_suffix, outdate, false)
if r then
return r
else
- local r = load_cache_a(filename .. '.lua', outdate)
+ local r = load_cache_a(filename .. '.lua.gz', outdate, true)
if r then save_cache_luc(filename, r) end -- update the precompiled cache
return r
end
local function remove_cache (filename)
local fullpath_wo_ext = savepath .. '/' .. filename .. '.lu'
remove_file_if_exist(fullpath_wo_ext .. 'a')
+ remove_file_if_exist(fullpath_wo_ext .. 'a.gz')
remove_file_if_exist(fullpath_wo_ext .. 'b')
remove_file_if_exist(fullpath_wo_ext .. 'c')
end
local cidfont_data = {}
local cache_chars = {}
-local cache_ver = 9
+local cache_ver = 10
local identifiers = fonts.hashes.identifiers
local cid_reg, cid_order, cid_supp, cid_name
sequences = seq_dummy_vert,
}
k.descriptions = {}
- k.shared.rawdata.resources=k.resources
- k.shared.rawdata.descriptions=k.descriptions
cache_chars[cid_name] = { [655360] = k.characters }
-- 縦書用字形
version = cache_ver,
k,
})
+ k.shared.rawdata.resources=k.resources
+ k.shared.rawdata.descriptions=k.descriptions
end
end
local dat = ltjb.load_cache("ltj-cid-auto-" .. string.lower(cid_name),
cid_cache_outdated )
if dat then
+ dat[1].shared.rawdata.resources=dat[1].resources
+ dat[1].shared.rawdata.descriptions=dat[1].descriptions
cidfont_data[cid_name] = dat[1]
cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
else