summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua135
1 files changed, 102 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua
index cda9d1d33e0..62b0e329c3a 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua
+++ b/Master/texmf-dist/tex/luatex/luatexja/ltj-jfont.lua
@@ -50,7 +50,7 @@ luatexbase.create_callback("luatexja.load_jfm", "data", function (ft, jn) return
local jfm_file_name, jfm_var
local defjfm_res
-local jfm_dir, is_def_jfont
+local jfm_dir, is_def_jfont, is_vert_enabled
function define_jfm(t)
local real_char -- Does current character class have the 'real' character?
@@ -280,6 +280,7 @@ do
chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
chars_cbcache = {},
+ vert_activated = is_vert_enabled,
}
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
@@ -350,9 +351,12 @@ do
end
end
if jfm_dir == 'tate' then
+ is_vert_enabled = (not name:match('-vert')) and (not name:match('-vrt2'))
if not name:match('vert') and not name:match('vrt2') then
name = name .. ';vert;vrt2'
end
+ else
+ is_vert_enabled = nil
end
return name
end
@@ -377,7 +381,8 @@ end
------------------------------------------------------------------------
do
-- these function are called from ltj-latex.sty
- local kyenc_list, ktenc_list = {}, {}
+ local fenc_list, kyenc_list, ktenc_list = {}, {}, {}
+ function add_fenc_list(enc) fenc_list[enc] = 'true ' end
function add_kyenc_list(enc) kyenc_list[enc] = 'true ' end
function add_ktenc_list(enc) ktenc_list[enc] = 'true ' end
function is_kyenc(enc)
@@ -392,36 +397,57 @@ do
end
local kfam_list, Nkfam_list = {}, {}
- function add_kfam_list(enc, fam)
- if not kfam_list[enc] then kfam_list[enc] = {} end
- kfam_list[enc][fam] = 'true '
- end
- function add_Nkfam_list(enc, fam)
- if not Nkfam_list[enc] then Nkfam_list[enc] = {} end
- Nkfam_list[enc][fam] = 'true '
+ function add_kfam(fam)
+ kfam_list[fam]=true
+ end
+ function search_kfam(fam, use_fd)
+ if kfam_list[fam] then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
+ elseif Nkfam_list[fam] then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
+ elseif use_fd then
+ for i,_ in pairs(kyenc_list) do
+ if kpse.find_file(string.lower(i)..fam..'.fd') then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
+ end
+ end
+ for i,_ in pairs(ktenc_list) do
+ if kpse.find_file(string.lower(i)..fam..'.fd') then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
+ end
+ end
+ Nkfam_list[fam]=true; tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
+ else
+ tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
+ end
end
- function is_kfam(enc, fam)
- tex.sprint(cat_lp, '\\let\\ifin@\\if'
- .. (kfam_list[enc] and kfam_list[enc][fam] or 'false ')) end
- function is_Nkfam(enc, fam)
- tex.sprint(cat_lp, '\\let\\ifin@\\if'
- .. (Nkfam_list[enc] and Nkfam_list[enc][fam] or 'false ')) end
-
local ffam_list, Nffam_list = {}, {}
- function add_ffam_list(enc, fam)
- if not ffam_list[enc] then ffam_list[enc] = {} end
- ffam_list[enc][fam] = 'true '
- end
- function add_Nffam_list(enc, fam)
- if not Nffam_list[enc] then Nffam_list[enc] = {} end
- Nffam_list[enc][fam] = 'true '
+ function is_ffam(fam)
+ tex.sprint(cat_lp, '\\let\\ifin@\\if' .. (ffam_list[fam] or 'false '))
+ end
+ function add_ffam(fam)
+ ffam_list[fam]='true '
+ end
+ function search_ffam_declared()
+ local s = ''
+ for i,_ in pairs(fenc_list) do
+ s = s .. '\\cdp@elt{' .. i .. '}'
+ end
+ tex.sprint(cat_lp, s)
+ end
+ function search_ffam_fd(fam)
+ if Nffam_list[fam] then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
+ else
+ for i,_ in pairs(fenc_list) do
+ if kpse.find_file(string.lower(i)..fam..'.fd') then
+ tex.sprint(cat_lp, '\\let\\ifin@\\iftrue '); return
+ end
+ end
+ Nffam_list[fam]=true; tex.sprint(cat_lp, '\\let\\ifin@\\iffalse '); return
+ end
end
- function is_ffam(enc, fam)
- tex.sprint(cat_lp, '\\let\\ifin@\\if'
- .. (ffam_list[enc] and ffam_list[enc][fam] or 'false ')) end
- function is_Nffam(enc, fam)
- tex.sprint(cat_lp, '\\let\\ifin@\\if'
- .. (Nffam_list[enc] and Nffam_list[enc][fam] or 'false ')) end
+
end
------------------------------------------------------------------------
-- ALTERNATE FONTS
@@ -651,8 +677,9 @@ do
end
local sort = table.sort
- local function add_fl_table(dest, tg, unitable, glyphmax, asc_des, units)
- for i = 0, glyphmax-1 do
+ local function add_fl_table(dest, glyphs, unitable, asc_des, units)
+ local tg, glyphmin, glyphmax = glyphs.glyphs, glyphs.glyphmin or 0, glyphs.glyphmax
+ for i = glyphmin, glyphmax-1 do
local gv = tg[i]
if gv then
if gv.altuni then
@@ -711,12 +738,12 @@ do
local fl = fontloader.open(id.filename)
local unicodes = id.resources.unicodes
if fl.glyphs then
- dest = add_fl_table(dest, fl.glyphs, id.resources.unicodes, fl.glyphmax,
+ dest = add_fl_table(dest, fl, unicodes,
fl.ascent + fl.descent, fl.units_per_em)
end
if fl.subfonts then
for _,v in pairs(fl.subfonts) do
- dest = add_fl_table(dest, v.glyphs, id.resources.unicodes, v.glyphmax,
+ dest = add_fl_table(dest, v, unicodes,
fl.ascent + fl.descent, fl.units_per_em)
end
end
@@ -862,6 +889,34 @@ luatexbase.add_to_callback(
end, 1, 'ltj.v_advance'
)
end
+
+------------------------------------------------------------------------
+-- supply tounicode entries
+------------------------------------------------------------------------
+do
+ local ltjr_prepare_cid_font = ltjr.prepare_cid_font
+ luatexbase.add_to_callback(
+ 'luaotfload.patch_font',
+ function (tfmdata)
+ if tfmdata.cidinfo then
+ local rd = ltjr_prepare_cid_font(tfmdata.cidinfo.registry, tfmdata.cidinfo.ordering)
+ if rd then
+ local ru, rc = rd.resources.unicodes, rd.characters
+ for i,v in pairs(tfmdata.characters) do
+ local w = ru["Japan1." .. tostring(v.index)]
+ if w then
+ v.tounicode = v.tounicode or rc[w]. tounicode
+ end
+ end
+ end
+ end
+
+ return tfmdata
+ end,
+ 'ltj.supply_tounicode', 1)
+end
+
+
------------------------------------------------------------------------
-- MISC
------------------------------------------------------------------------
@@ -901,3 +956,17 @@ do
node_free(TEMP)
end
end
+
+------------------------------------------------------------------------
+-- VERT VARIANT TABLE
+------------------------------------------------------------------------
+vert_form_table = {
+ [0x2013]=0xFE32, [0x2014]=0xFE31, [0x2025]=0xFE30,
+ [0xFF08]=0xFE35, [0xFF09]=0xFE36, [0xFF5B]=0xFE37, [0xFF5D]=0xFE38,
+ [0x3014]=0xFE39, [0x3015]=0xFE3A, [0x3010]=0xFE3B, [0x3011]=0xFE3C,
+ [0x300A]=0xFE3D, [0x300B]=0xFE3E, [0x3008]=0xFE3F, [0x3009]=0xFE40,
+ [0x300C]=0xFE41, [0x300D]=0xFE42, [0x300E]=0xFE43, [0x300F]=0xFE44,
+ [0xFF3B]=0xFE47, [0xFF3D]=0xFE48, [0xFF3F]=0xFE33,
+}
+setmetatable(vert_form_table, {__index=function(t,k) return k end});
+