X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-rmlgbm.lua;h=35c32995c0e1041bc7ab6c7120804201124cb934;hb=2cd99a5cbcb182fa6d8d9c303efd76d18f50a31a;hp=2430ef3f7c13bf639670b6c3519b19aaee5a859c;hpb=9af4f04e3123548ad4a1f4bada4177e09abeb285;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-rmlgbm.lua b/src/ltj-rmlgbm.lua index 2430ef3..35c3299 100644 --- a/src/ltj-rmlgbm.lua +++ b/src/ltj-rmlgbm.lua @@ -5,12 +5,12 @@ luatexja.load_module('base'); local ltjb = luatexja.base local cidfont_data = {} local cache_chars = {} -local cache_ver = 5 +local cache_ver = 8 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 @@ -35,12 +35,22 @@ local cid_replace = { 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 @@ -106,6 +116,13 @@ do 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 @@ -118,6 +135,7 @@ do }, embedding = "no", cache = "yes", factor = 0, hfactor = 0, vfactor = 0, tounicode = 1, + properties = { language = "dflt", script = "dflt" }, } cidfont_data[cid_name] = k @@ -145,11 +163,17 @@ do 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 } -- 縦書用字形 @@ -195,16 +219,21 @@ end -- 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 cidf_vert_processor = { function (head, fnum) local fontdata = identifiers[fnum] - if fontdata.is_ltj_vert then - local vt = fontdata.shared.ltj_vert_table + if head and luatexja.jfont.font_metric_table[fnum].vert_activated then + local vt = fontdata.shared.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 @@ -230,17 +259,30 @@ local function read_cid_font() if not v.width then v.width = 655360 end v.height, v.depth = 576716.8, 78643.2 -- optimized for jfm-ujis.lua end + return cidfont_data[cid_name] + else + return nil end end -- High-level +local function prepare_cid_font(reg, ord) + cid_reg, cid_order, cid_name, cid_supp = reg, ord, reg .. '-' .. ord + return cidfont_data[cid_name] or read_cid_font() +end + local definers = fonts.definers local function mk_rml(name, size, id) 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] @@ -308,9 +350,6 @@ local function mk_rml(name, size, id) e = e * 1000 var, fontdata.extend = var .. 'x' .. tostring(e), e end - if string.match(specification.detail, '(%+?vert)') then - cachedata.is_ltj_vert = true - end fontdata.name = specification.name .. size .. var; cachedata.name = fontdata.name fontdata.fullname = specification.name .. var; cachedata.fullname = fontdata.fullname fontdata.psname = specification.name; cachedata.psname = fontdata.psname @@ -320,7 +359,8 @@ local function mk_rml(name, size, id) end local function font_callback(name, size, id, fallback) - local p = name:find(":") or name:len()+1 + 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 basename = name:sub(p+1) @@ -345,17 +385,13 @@ local function font_callback(name, size, id, fallback) if not cid_reg then cid_reg, cid_order = string.match(s, "^(.-)%-(.-)$") end - cid_name = cid_reg .. '-' .. cid_order - if not cidfont_data[cid_name] then - read_cid_font() - if not cidfont_data[cid_name] then - ltjb.package_error('luatexja', - "bad cid key `" .. s .. "'", - "I couldn't find any non-embedded font information for the CID\n" .. - '`' .. s .. "'. For now, I'll use `Adobe-Japan1-6'.\n".. - 'Please contact the LuaTeX-ja project team.') - cid_name = "Adobe-Japan1" - end + if not prepare_cid_font(cid_reg, cid_order) then + ltjb.package_error('luatexja', + "bad cid key `" .. s .. "'", + "I couldn't find any non-embedded font information for the CID\n" .. + '`' .. s .. "'. For now, I'll use `Adobe-Japan1-6'.\n".. + 'Please contact the LuaTeX-ja project team.') + cid_name = "Adobe-Japan1" end return mk_rml(basename, size, id) else @@ -368,10 +404,10 @@ local function font_callback(name, size, id, fallback) end luatexja.rmlgbm = { + prepare_cid_font = prepare_cid_font, cidfont_data = cidfont_data, font_callback = font_callback, vert_addfunc = function () end, -- dummy, set in ltj-direction.lua } -cid_reg, cid_order, cid_name, cid_supp = 'Adobe', 'Japan1', 'Adobe-Japan1' -read_cid_font() +prepare_cid_font('Adobe', 'Japan1')