local cidfont_data = {}
local cache_chars = {}
-local cache_ver = 6
+local cache_ver = 9
local identifiers = fonts.hashes.identifiers
local cid_reg, cid_order, cid_supp, cid_name
local cid_replace = {
- ["Adobe-Japan1"] = {"UniJIS2004-UTF32", 23057, 6,
+ ["Adobe-Japan1"] = {"UniJIS2004-UTF32", 23059, 7,
function (i)
if (231<=i and i<=632) or (8718<=i and i<=8719)
or (12063<=i and i<=12087) then
return 327680 -- 655360/2
end
end},
- ["Adobe-CNS1"] = {"UniCNS-UTF32", 19155, 6,
+ ["Adobe-CNS1"] = {"UniCNS-UTF32", 19178, 7,
function (i)
if (13648<=i and i<=13742) or (i==17603) then
return 327680 -- 655360/2
end
end},
+ ["Adobe-KR"] = {"UniAKR-UTF32", 22896, 9,
+ function (i)
+ if i==3057 then
+ return 655360*2
+ elseif i==3058 then
+ return 655360*3
+ elseif i==12235 or i==12236 then
+ return 163840 -- 655360/4
+ end
+ end},
}
-- reading CID maps
end
local function open_cmap_file(name, inc, cid_dec, mke)
- fh = io.open(kpse.find_file(name, 'cmap files'), "r")
- line = fh:read("*l")
- while line do
- if string.find(line, "%x+%s+begin...?char") then
- load_cid_char(cid_dec, mke)
- elseif string.find(line, "%x+%s+begin...?range") then
- load_cid_range(inc, cid_dec, mke)
- else
- line = fh:read("*l")
+ local fn = kpse.find_file(name, 'cmap files')
+ if fn then
+ fh = io.open(fn, "r")
+ line = fh:read("*l")
+ while line do
+ if string.find(line, "%x+%s+begin...?char") then
+ load_cid_char(cid_dec, mke)
+ elseif string.find(line, "%x+%s+begin...?range") then
+ load_cid_range(inc, cid_dec, mke)
+ else
+ line = fh:read("*l")
+ end
end
+ fh:close();
end
- fh:close();
end
local function increment(a) return a+1 end
local function entry(a)
return {index = a}
end
+ local feat_dummy_vert = { gsub={vert={dflt={dflt=true}}} }
+ local seq_dummy_vert={{
+ features={vert={dflt={dflt=true}}},
+ --flags={false,false,false,false},
+ --index=1, name="s_s_0", skiphash=false, steps={coverage={},index=1},
+ ["type"]="gsub_single", order='vert',
+ }}
make_cid_font = function ()
local kx = cid_replace[cid_name]
if not kx then return end
cidinfo= k.cidinfo, verbose = false,
shared = { featuredata = {}, },
},
- dynamics = {}, features = {}, processes = {},
- --rawdata = { descriptions = {} },
- }
- k.resources = { unicodes = ttu, }
+ dynamics = {}, processes = {},
+ rawdata = {}, features={},
+ }
+ k.resources = {
+ unicodes = ttu,
+ features = feat_dummy_vert,
+ 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 }
-- 縦書用字形
tt, cidm = {}, {}
- local ttv = {}; k.shared.ltj_vert_table = ttv
+ local ttv = {}; k.ltj_vert_table = ttv
for i = 0,kx[2] do cidm[i] = -1 end
open_cmap_file(kx[1] .. "-V", increment, tonumber, entry)
for i,v in pairs(tt) do
- ttv[i] = cidmo[v.index]
+ ttv[i] = cidmo[v.index] -- "unicode" of vertical variant
end
-- tounicode エントリ
--
local cidf_vert_processor
do
- local traverse_id = node.traverse_id
+ local traverse_id, is_node = node.direct.traverse_id, node.is_node
+ local to_direct = node.direct.todirect
local id_glyph = node.id('glyph')
+ local getfont = node.direct.getfont
+ local getchar = node.direct.getchar
+ local setchar = node.direct.setchar
+ local font_getfont = font.getfont
cidf_vert_processor = {
function (head, fnum)
- local fontdata = identifiers[fnum]
- if luatexja.jfont.font_metric_table[fnum].vert_activated then
- local vt = fontdata.shared.ltj_vert_table
+ local fontdata = font_getfont(fnum)
+ if head and luatexja.jfont.font_metric_table[fnum].vert_activated then
+ local vt = fontdata.ltj_vert_table
+ local nh = is_node(head) and to_direct(head) or head
for n in traverse_id(id_glyph, head) do
- if n.font==fnum then
- n.char = vt[n.char] or n.char
+ if getfont(n)==fnum then
+ local c = getchar(n); setchar(n, vt[c] or c)
end
end
return head, false
local specification = definers.analyze(name,size)
--specification = definers.resolve(specification) (not needed)
specification.detail = specification.detail or ''
-
+ do
+ local n = specification.name
+ if n:sub(1,1)=="{" then n=n:sub(2) end
+ if n:sub(-1)=="}" then n=n:sub(1,-2) end
+ specification.name=n
+ end
local fontdata = {}
local cachedata = {}
local s = cidfont_data[cid_name]
if name:sub(1,1)=="{" and name:sub(-1)=="}" then name = name:sub(2,-2) end
local p = name:find(":") or 0
if name:sub(1, p-1) == 'psft' then
- local s = "Adobe-Japan1-6"
+ local s = "Adobe-Japan1-7"
local basename = name:sub(p+1)
local p = basename:find(":")
local q = basename:find("/[BI][BI]?")
return mk_rml(basename, size, id)
else
local tfmdata=fallback(name, size, id)
- if type (tfmdata) == "table" and tfmdata.shared then
+ if type (tfmdata) == "table" and tfmdata.encodingbytes == 2 then
luatexbase.call_callback("luaotfload.patch_font", tfmdata, name)
end
return tfmdata