From 0d0e4748aca67aa2294b3a8cdec575e1e414d918 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Wed, 4 May 2016 08:32:10 +0900 Subject: [PATCH] ltj-otf.lua etc.: update \CID for luaotfload v2.7 --- src/ltj-jfont.lua | 17 +++++++++-------- src/ltj-otf.lua | 26 ++++++++++++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/ltj-jfont.lua b/src/ltj-jfont.lua index 6695eb9..5b9cbe4 100644 --- a/src/ltj-jfont.lua +++ b/src/ltj-jfont.lua @@ -743,15 +743,15 @@ do end prepare_fl_data = function (dest, id) local fl = fontloader.open(id.filename) - local unicodes = {} + local ind_to_uni, unicodes = {}, {} for i,v in pairs(id.characters) do - unicodes[v.index] = i + ind_to_uni[v.index] = i end if fl.glyphs then local tg, glyphmin, glyphmax = fl.glyphs, fl.glyphmin, fl.glyphmax for i = glyphmin, glyphmax do - if tg[i] and tg[i].name then unicodes[tg[i].name] = unicodes[i] end + if tg[i] and tg[i].name then unicodes[tg[i].name] = ind_to_uni[i] end end dest = add_fl_table(dest, fl, unicodes, fl.ascent + fl.descent, fl.units_per_em) @@ -760,16 +760,17 @@ do for _,v in pairs(fl.subfonts) do local tg, glyphmin, glyphmax = v.glyphs, v.glyphmin, v.glyphmax for i = glyphmin, glyphmax do - if tg[i] and tg[i].name then unicodes[tg[i].name] = unicodes[i] end + if tg[i] and tg[i].name then unicodes[tg[i].name] = ind_to_uni[i] end end end for _,v in pairs(fl.subfonts) do dest = add_fl_table(dest, v, unicodes, fl.ascent + fl.descent, fl.units_per_em) end - end - fontloader.close(fl); collectgarbage("collect") - return dest + end + if dest then dest.unicodes = unicodes end + fontloader.close(fl); collectgarbage("collect") + return dest end -- supply vkern table supply_vkern_table = function(id, bname) @@ -790,7 +791,7 @@ end -- do - local cache_ver = 7 + local cache_ver = 9 local checksum = file.checksum local function prepare_extra_data_base(id) diff --git a/src/ltj-otf.lua b/src/ltj-otf.lua index d13cff2..bdaf8ad 100644 --- a/src/ltj-otf.lua +++ b/src/ltj-otf.lua @@ -96,19 +96,24 @@ do local tex_get_attr = tex.getattribute cid = function (key) if key==0 then return append_jglyph(char) end - local curjfnt = identifiers[tex_get_attr((ltjd_get_dir_count()==dir_tate) - and attr_curtfnt or attr_curjfnt)] - if not curjfnt.cidinfo or - curjfnt.cidinfo.ordering ~= "Japan1" and - curjfnt.cidinfo.ordering ~= "GB1" and - curjfnt.cidinfo.ordering ~= "CNS1" and - curjfnt.cidinfo.ordering ~= "Korea1" then + local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate) + and attr_curtfnt or attr_curjfnt) + local curjfnt = identifiers[curjfnt_num] + local cidinfo = curjfnt.resources.cidinfo + if not cidinfo or + cidinfo.ordering ~= "Japan1" and + cidinfo.ordering ~= "GB1" and + cidinfo.ordering ~= "CNS1" and + cidinfo.ordering ~= "Korea1" then -- ltjb.package_warning('luatexja-otf', -- 'Current Japanese font (or other CJK font) "' -- ..curjfnt.psname..'" is not a CID-Keyed font (Adobe-Japan1 etc.)') return append_jglyph(get_ucs_from_rmlgbm(key)) end - local char = curjfnt.resources.unicodes[curjfnt.cidinfo.ordering..'.'..tostring(key)] + local fe, char = ltjf_font_extra_info[curjfnt_num], nil + if fe and fe.unicodes then + char = fe.unicodes[cidinfo.ordering..'.'..tostring(key)] + end if not char then ltjb.package_warning('luatexja-otf', 'Current Japanese font (or other CJK font) "' @@ -167,11 +172,12 @@ ltjb.add_to_callback('pre_linebreak_filter', extract,'ltj.otf', -- 和文フォント読み込み時に,CID -> unicode 対応をとっておく. local function cid_to_char(fmtable, fn) local fi = identifiers[fn] - if fi.cidinfo and fi.cidinfo.ordering == "Japan1" then + local fe = ltjf_font_extra_info[fn] + if fi.cidinfo and fi.cidinfo.ordering == "Japan1" and fe then for i, v in pairs(fmtable.chars) do local j = string.match(i, "^AJ1%-([0-9]*)") if j then - j = tonumber(fi.resources.unicodes['Japan1.'..tostring(j)]) + j = tonumber(fe.unicodes['Japan1.'..tostring(j)]) if j then fmtable.cid_char_type = fmtable.cid_char_type or {} fmtable.cid_char_type[j] = v -- 2.11.0