function find_char_class(c,m)
-- c: character code, m:
if not m then return 0 end
--- print("**")
--- for i,v in pairs(m) do print(i,v) end
return m.chars[c] or
luatexbase.call_callback("luatexja.find_char_class", 0, m, c)
end
zw = sz.zw, zh = sz.zh,
chars = sz.chars, char_type = sz.char_type,
kanjiskip = sz.kanjiskip, xkanjiskip = sz.xkanjiskip,
- mono_flag = not string.match((fonts.ids[fn].name or ''), "+[(pwid)(palt)]"),
}
+ fmtable.mono_flag = fonts.ids[fn].cidinfo
+ and (not string.match((fonts.ids[fn].name or ''), "+[(pwid)(palt)]"))
+
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
font_metric_table[fn]=fmtable
tex.sprint(cat_lp, luatexja.is_global .. '\\protected\\expandafter\\def\\csname '
end
-- replace fonts.define.read()
-local ljft_dr_orig = fonts.define.read
-function fonts.define.read(name, size, id)
+function font_callback(name, size, id, fallback)
extract_metric(name)
-- In the present imple., we don't remove "jfm=..." from name.
- return ljft_dr_orig(name, size, id)
+ return fallback(name, size, id)
end
------------------------------------------------------------------------
function cid(key)
local curjfnt = fonts.ids[tex.attribute[attr_curjfnt]]
- if curjfnt.cidinfo.ordering ~= "Japan1" and
- curjfnt.cidinfo.ordering ~= "GB1" and
- curjfnt.cidinfo.ordering ~= "CNS1" and
- curjfnt.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))
+ 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
+ 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.unicodes[curjfnt.cidinfo.ordering..'.'..tostring(key)]
+ local char = curjfnt.resources.unicodes[curjfnt.cidinfo.ordering..'.'..tostring(key)]
if not char then
ltjb.package_warning('luatexja-otf',
'Current Japanese font (or other CJK font) "'
for i, v in pairs(fmtable.chars) do
local j = string.match(i, "^AJ1%-([0-9]*)")
if j then
- j = tonumber(fi.unicodes['Japan1.'..tostring(j)])
+ j = tonumber(fi.resources.unicodes['Japan1.'..tostring(j)])
if j then
fmtable.cid_char_type[j] = v
end
p.subtype = floor(p.subtype*0.5)*2
set_attr(p, attr_orig_char, p.char)
if ltjf_font_metric_table[pf] and ltjf_font_metric_table[pf].mono_flag then
- local pco = fonts_ids[pf].cidinfo.ordering
+ local pfd = fonts_ids[pf]
+ local pco = pfd.cidinfo.ordering
for i,v in pairs(fwglyph) do
- if pco == i then
- local fwc = fonts_ids[pf].unicodes[pco .. '.'.. tostring(v[p.char])]
+ if pco == i and pfd.shared.resources then
+ -- print(pf, pfd.fullname, pfd)
+ -- for j,w in pairs(pfd.resources) do
+ -- print('["' .. j .. '"] = ' .. tostring(w))
+ -- if type(w) == 'table' and j~='characters' then
+ -- for k,x in pairs(w) do
+ -- print(' ["' .. k .. '"] = ' .. tostring(x))
+ -- end
+ -- end
+ -- end
+ local fwc = pfd.shared.resources.unicodes[pco .. '.'.. tostring(v[p.char])]
if fwc then p.char = fwc end
break
end
luatexja.pretreat = {
set_box_stack_level = set_box_stack_level,
-}
\ No newline at end of file
+}
--
--- luatexja/ltj-rmlgbm.lua
+-- luatexja/rmlgbm.lua
--
+luatexbase.provides_module({
+ name = 'luatexja.rmlgbm',
+ date = '2013/03/17',
+ version = '0.4',
+ description = 'Definitions of non-embedded Japanese (or other CJK) fonts',
+})
+module('luatexja.rmlgbm', package.seeall)
+local err, warn, info, log = luatexbase.errwarinf(_NAME)
luatexja.load_module('base'); local ltjb = luatexja.base
-local cidfont_data = {}
+cidfont_data = {}
+local cidfont_data = cidfont_data
local cache_chars = {}
local path = {
localdir = file.join(kpse.expand_var("$TEXMFVAR"), aux_dir),
local cid_reg, cid_order, cid_supp, cid_name
local taux_dir = 'luatex-cache/luatexja'
local cid_replace = {
- ["Adobe-Japan1"] = {"UniJIS-UTF32", 23057,
+ ["Adobe-Japan1"] = {"UniJIS2004-UTF32", 23057,
function (i)
if (231<=i and i<=632) or (8718<=i and i<=8719)
or (12063<=i and i<=12087) then
elseif 9738<=i and i<=9757 then
return 163840 -- 655360/4
end
- end,
- "UniJIS2004-UTF32"},
- -- 基本的には JIS X 0208:1990 に沿ったマッピングだが
- -- JIS X 0213:2004 のみにある字も使えるようにする
+ end},
+ -- 基本的には JIS X 0213:2004 に沿ったマッピング
["Adobe-Korea1"] = {"UniKS-UTF32", 18351,
function (i)
if 8094<=i and i<=8100 then
end
local function increment(a) return a+1 end
- local function entry(a) return {index = a} end
+ local function entry(a)
+ return {index = a}
+ end
function make_cid_font()
local k = {
cidinfo = { ordering=cid_order, registry=cid_reg, supplement=cid_supp },
local kx = cid_replace[cid_name]
cidfont_data[cid_name] = k
- -- CID => Unicode 負号空間
+ -- CID => Unicode 符号空間
-- TODO: vertical fonts?
tt, cidm = {}, {}
for i = 0,kx[2] do cidm[i] = -1 end
open_cmap_file(kx[1] .. "-H", increment, tonumber, entry)
- if kx[4] then
- open_cmap_file(kx[4] .. "-H", increment, tonumber, entry)
- end
k.characters = tt
-- Unicode にマップされなかった文字の処理
local ttu, pricode = {}, 0xF0000
for i,v in ipairs(cidm) do
if v==-1 then
- tt[pricode], cidm[i], pricode= { index = i }, pricode, pricode+1;
+ tt[pricode], cidm[i], pricode
+ = { index = i }, pricode, pricode+1;
end
ttu[cid_order .. '.' .. i] = cidm[i]
end
- k.unicodes = ttu
+ -- shared
+ k.shared = {
+ otfdata = {
+ cidinfo= k.cidinfo, verbose = false,
+ shared = { featuredata = {}, },
+ luatex = { features = {},
+ defaultwidth=1000,
+ sequences = { }, },
+ },
+ dynamics = {}, features = {}, processes = {},
+ }
+ k.resources = { unicodes = ttu, }
+ k.descriptions = {}
cache_chars[cid_name] = { [655360] = k.characters }
-- tounicode エントリ
end
end
- -- shared
- k.shared = {
- otfdata = {
- cidinfo= k.cidinfo, verbose = false,
- shared = { featuredata = {}, },
- luatex = { features = {}, defaultwidth=1000, sequences = { }, },
- },
- dynamics = {}, features = {}, processes = {},
- }
- k.descriptions = {}
-
-- Save
local savepath = path.localdir .. '/luatexja/'
if not lfs.isdir(savepath) then
-- High-level
local function mk_rml(name, size, id)
- local specification = fonts.define.analyze(name,size)
- specification = fonts.define.specify[':'](specification)
+ local specification = fonts.definers.analyze(name,size)
+ specification = fonts.definers.resolve(specification)
local features = specification.features.normal
local fontdata = {}
end
fontdata.characters = nil
cachedata.characters = nil
- fontdata.unicodes = nil
fontdata.shared = nil
cachedata.shared = nil
if s.shared then
for k, v in pairs(s.shared) do
shared[k] = v
end
-
- shared.set_dynamics = fonts.otf.set_dynamics
- shared.processes, shared.features = fonts.otf.set_features(cachedata,fonts.define.check(features,fonts.otf.features.default))
end
-- characters & scaling
fontdata.hfactor = fontdata.hfactor * scale; cachedata.hfactor = fontdata.hfactor
fontdata.vfactor = fontdata.vfactor * scale; cachedata.vfactor = fontdata.vfactor
fontdata.size = size; cachedata.size = size
-
+ fontdata.resources = s.resources
+ cachedata.resources = s.resources
+
-- no embedding
local var = ''
- if features.slant then
- fontdata.slant = features.slant*1000; cachedata.slant = fontdata.slant
- var = var .. 's' .. tostring(features.slant)
- end
- if features.extend then
- fontdata.extend = features.extend*1000; cachedata.extend = fontdata.extend
- var = var .. 'x' .. tostring(features.extend)
- end
+ -- if features.slant then
+ -- fontdata.slant = features.slant*1000; cachedata.slant = fontdata.slant
+ -- var = var .. 's' .. tostring(features.slant)
+ -- end
+ -- if features.extend then
+ -- fontdata.extend = features.extend*1000; cachedata.extend = fontdata.extend
+ -- var = var .. 'x' .. tostring(features.extend)
+ -- 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
return fontdata
end
-local dr_orig = fonts.define.read
-function fonts.define.read(name, size, id)
+function font_callback(name, size, id, fallback)
local p = utf.find(name, ":") or utf.len(name)+1
if utf.sub(name, 1, p-1) == 'psft' then
local s = "Adobe-Japan1-6"
end
return mk_rml(basename, size, id)
else
- return dr_orig(name, size, id)
+ return fallback(name, size, id)
end
end
-cid_reg, cid_order, cid_name = 'Adobe', 'Japan1', 'Adobe-Japan1'
+cid_reg, cid_order, cid_name, cid_supp = 'Adobe', 'Japan1', 'Adobe-Japan1'
read_cid_font()
-
-luatexja.rmlgbm = {
- cidfont_data = cidfont_data,
-}
\ No newline at end of file
-local floor = math.floor
-
-require('lualibs')
+require('lualibs-table')
------------------------------------------------------------------------
-- naming:
-- int_... : called from other Lua codes, but not from \directlua{}
-- (other) : only called from this file
function luatexja.load_module(name)
- if not package.loaded['luatexja.' .. name] then
- local fn = 'ltj-' .. name .. '.lua'
- local found = kpse.find_file(fn, 'tex')
- if not found then
- tex.error("LuaTeX-ja error: File `" .. fn .. "' not found",
- {'This file ' .. fn .. ' is required for LuaTeX-ja.',
- 'Please check your installation.'})
- else
- texio.write_nl('(' .. found .. ')')
- require(found) -- 2度読み防止; これでいいのか?
- end
- end
+ require('ltj-' .. name.. '.lua')
end
function luatexja.load_lua(fn)
local found = kpse.find_file(fn, 'tex')
load_module('math'); local ltjm = luatexja.math
load_module('tangle'); local ltjb = luatexja.base
-
-local node_type = node.type
-local node_new = node.new
-local node_prev = node.prev
-local node_next = node.next
-local has_attr = node.has_attribute
-local node_insert_before = node.insert_before
-local node_insert_after = node.insert_after
-local node_hpack = node.hpack
-
-local id_penalty = node.id('penalty')
-local id_glyph = node.id('glyph')
-local id_glue_spec = node.id('glue_spec')
-local id_glue = node.id('glue')
-local id_kern = node.id('kern')
-local id_hlist = node.id('hlist')
-local id_vlist = node.id('vlist')
-local id_rule = node.id('rule')
-local id_math = node.id('math')
-local id_whatsit = node.id('whatsit')
-local sid_user = node.subtype('user_defined')
-
local attr_jchar_class = luatexbase.attributes['ltj@charclass']
local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
local attr_yablshift = luatexbase.attributes['ltj@yablshift']
local attr_uniqid = luatexbase.attributes['ltj@uniqid']
local cat_lp = luatexbase.catcodetables['latex-package']
+
+---- table: charprop_stack_table [stack_level].{pre|post|xsp}[chr_code]
+
+
-- Three aux. functions, bollowed from tex.web
+
local unity=65536
+local floor = math.floor
+
local function print_scaled(s)
local out=''
local delta=10
return out
end
-function print_spec(p)
+local function print_spec(p)
local out=print_scaled(p.width)..'pt'
if p.stretch~=0 then
out=out..' plus '..print_glue(p.stretch,p.stretch_order)
end
----- table: charprop_stack_table [stack_level].{pre|post|xsp}[chr_code]
-
------------------------------------------------------------------------
-- CODE FOR GETTING/SETTING PARAMETERS
------------------------------------------------------------------------
return main_process(head, true, tex.textdir)
end,'ltj.pre_linebreak_filter',
luatexbase.priority_in_callback('pre_linebreak_filter',
- 'luaotfload.pre_linebreak_filter') + 1)
+ 'luaotfload.node_processor') + 1)
luatexbase.add_to_callback('hpack_filter',
function (head,groupcode,size,packtype, dir)
return main_process(head, false, dir)
end,'ltj.hpack_filter',
luatexbase.priority_in_callback('hpack_filter',
- 'luaotfload.hpack_filter') + 1)
+ 'luaotfload.node_processor') + 1)
+
+-- define_font
+
+local otfl_fdr = fonts.definers.read
+function luatexja.font_callback(name, size, id)
+ return ltjf.font_callback(
+ name, size, id,
+ function (name, size, id) return ltjr.font_callback(name, size, id, otfl_fdr) end
+ )
+end
+--luatexbase.remove_from_callback('define_font',"luaotfload.define_font")
+luatexbase.add_to_callback('define_font',luatexja.font_callback,"luatexja.font_callback", 1)
+
+
+
+
-- debug
+
+do
+
+local id_penalty = node.id('penalty')
+local id_glyph = node.id('glyph')
+local id_glue_spec = node.id('glue_spec')
+local id_glue = node.id('glue')
+local id_kern = node.id('kern')
+local id_hlist = node.id('hlist')
+local id_vlist = node.id('vlist')
+local id_rule = node.id('rule')
+local id_math = node.id('math')
+local id_whatsit = node.id('whatsit')
+local sid_user = node.subtype('user_defined')
+
local function get_attr_icflag(p)
return (has_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
end
else
print_fn(debug_depth .. ' (null list)')
end
-end
\ No newline at end of file
+end
+
+end