summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-04 21:10:21 +0000
committerKarl Berry <karl@freefriends.org>2019-05-04 21:10:21 +0000
commit74728e861a713442320663646123dff99487108f (patch)
tree1087307121ffd1b2b2799b4e244e934a0495a625 /Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua
parent4c7e9e5ca9cf88c9a2a11e287c02649ef2f4dd21 (diff)
luatexja (4may19)
git-svn-id: svn://tug.org/texlive/trunk@50978 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua85
1 files changed, 72 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua
index d083026abbb..3b4d57e00c1 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-otf.lua
@@ -82,19 +82,49 @@ local function get_ucs_from_rmlgbm(c)
elseif v<0xF0000 then -- 素直に Unicode にマップ可能
return v
else -- privete use area
- local w = ltjr_cidfont_data["Adobe-Japan1"].characters[v]. tounicode
- -- must be non-nil!
- local i = string.len(w)
- if i==4 then -- UCS2
- return tonumber(w,16)
- elseif i==8 then
- i,w = tonumber(string.sub(w,1,4),16), tonumber(string.sub(w,-4),16)
- if (w>=0xD800) and (w<=0xDB7F) and (i>=0xDC00) and (i<=0xDFFF) then -- Surrogate pair
- return (w-0xD800)*0x400 + (i-0xDC00)
- else
- return 0
+ local r, aj = nil, ltjr_cidfont_data["Adobe-Japan1"]
+ -- 先に ltj_vert_table を見る
+ for i,w in pairs(aj.shared.ltj_vert_table) do
+ if w==v then r=i; break end
+ end
+ if not r then
+ -- なければ ToUnicode から引く
+ local w = aj.characters[v].tounicode -- must be non-nil!
+ local i = string.len(w)
+ if i==4 then -- UCS2
+ r = tonumber(w,16)
+ elseif i==8 then
+ i,w = tonumber(string.sub(w,1,4),16), tonumber(string.sub(w,-4),16)
+ if (w>=0xD800) and (w<=0xDB7F) and (i>=0xDC00) and (i<=0xDFFF) then -- Surrogate pair
+ r = (w-0xD800)*0x400 + (i-0xDC00)
+ else
+ r = 0
+ end
+ end
+ end
+ if aj.shared.ltj_vert_table[r] then
+ -- CID が縦組用字形だった場合
+ local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
+ and attr_curtfnt or attr_curjfnt)
+ local t = identifiers[curjfnt_num]
+ if t.resources.sequences then
+ for _,i in pairs(t.resources.sequences) do
+ if (i.order[1]=='vert' or i.order[1]=='vrt2')
+ and i.type == 'gsub_single' and i.steps then
+ for _,j in pairs(i.steps) do
+ if type(j)=='table' then
+ if type(j.coverage)=='table' then
+ for i,k in pairs(j.coverage) do
+ if i==r then return k end
+ end
+ end
+ end
+ end
+ end
+ end
end
end
+ return r
end
end
@@ -108,10 +138,39 @@ local function append_jglyph(char)
node_write(p)
end
+local utf
+do
+ utf = function (ucs)
+ local char = ucs
+ if ltjd_get_dir_count()==dir_tate then
+ local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
+ and attr_curtfnt or attr_curjfnt)
+ local t = identifiers[curjfnt_num]
+ if t.resources.sequences then
+ for _,i in pairs(t.resources.sequences) do
+ if (i.order[1]=='vert' or i.order[1]=='vrt2')
+ and i.type == 'gsub_single' and i.steps then
+ for _,j in pairs(i.steps) do
+ if type(j)=='table' then
+ if type(j.coverage)=='table' then
+ for i,k in pairs(j.coverage) do
+ if i==char then return append_jglyph(k) end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ return append_jglyph(char)
+ end
+end
+
local cid
do
cid = function (key)
- if key==0 then return append_jglyph(char) end
+ if key==0 then return append_jglyph(0) end
local curjfnt_num = tex_get_attr((ltjd_get_dir_count()==dir_tate)
and attr_curtfnt or attr_curjfnt)
local curjfnt = identifiers[curjfnt_num]
@@ -235,7 +294,7 @@ luatexja.otf = {
append_jglyph = append_jglyph,
enable_ivs = enable_ivs, -- 隠し機能: IVS
disable_ivs = disable_ivs, -- 隠し機能: IVS
- cid = cid,
+ cid = cid, utf = utf,
}