luatexja.load_module('jfont'); local ltjf = luatexja.jfont
luatexja.load_module('jfmglue'); local ltjj = luatexja.jfmglue
+luatexja.load_module('stack'); local ltjs = luatexja.stack
local Dnode = node.direct or node
end
local res = {}
-
--- local new_ks, new_xs
+local is_skip_normal = {}
local function get_total_stretched(p)
local go, gf, gs
= getfield(p, 'glue_order'), getfield(p, 'glue_set'), getfield(p, 'glue_sign')
if type(res[ic]) == 'number' then
-- kanjiskip, xkanjiskip は段落内で spec を共有しているが,
-- それはここでは望ましくないので,各 glue ごとに異なる spec を使う.
+ -- (この仮定でメモリリークを起こしている!)
-- JFM グルーはそれぞれ異なる glue_spec を用いているので,問題ない.
res[ic] = res[ic] + a
- if ic == KANJI_SKIP or ic == XKANJI_SKIP then
+ if (ic == KANJI_SKIP or ic == XKANJI_SKIP) and getsubtype(q)==0 then
local qs = getfield(q, 'spec')
- if qs ~= spec_zero_glue then
+ if is_skip_normal[ic] and qs ~= spec_zero_glue then
setfield(q, 'spec', node_copy(qs))
end
end
function adjust_width(head)
if not head then return head end
+ is_skip_normal[KANJI_SKIP] = (ltjs.fast_get_skip_table('kanjiskip').width ~= 1073741823)
+ is_skip_normal[XKANJI_SKIP] = (ltjs.fast_get_skip_table('xkanjiskip').width ~= 1073741823)
for p in node_traverse_id(id_hlist, to_direct(head)) do
local res = get_total_stretched(p)
if res then
local getchar = (Dnode ~= node) and Dnode.getchar or function(n) return n.char end
local has_attr = Dnode.has_attribute
local has_attr_node = node.has_attribute
+local tex_getattr = tex.getattribute
ATTR_RANGE = 7
local floor = math.floor
local pow = math.pow
local kcat_attr_table = {}
local pow_table = {}
+local fn_table = {} -- used in is_ucs_in_japanese_char_direct
for i = 0, 31*ATTR_RANGE-1 do
kcat_attr_table[i] = luatexbase.attributes['ltj@kcat'..floor(i/31)]
pow_table[i] = pow(2, i%31)
+ fn_table[i] = function(p)
+ return floor(has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk
+ end
end
pow_table[31*ATTR_RANGE] = pow(2, 31)
end
function get_range_setting(i) -- i: internal range number
- return floor(tex.getattribute(kcat_attr_table[i])/pow_table[i])%2
+ return floor(tex_getattr(kcat_attr_table[i])/pow_table[i])%2
end
-- glyph_node p は和文文字か?
-
function is_ucs_in_japanese_char_node(p)
local c = p.char
if c<0x80 then
if c<0x80 then
return false
else
- local i=jcr_table_main[c]
- return (floor(
- has_attr(p, kcat_attr_table[i])/pow_table[i])%2 ~= jcr_noncjk)
+ return fn_table[jcr_table_main[c]]
end
end
+function is_japanese_char_curlist(c) -- assume that c>=0x80
+ local i=jcr_table_main[c]
+ return get_range_setting(i)~= jcr_noncjk
+end
+
-- EXT
function toggle_char_range(g, i) -- i: external range number
if type(i)~='number' then
if i>0 then kc=0 else kc=1; i=-i end
if i>=7*ATTR_RANGE then i=0 end
local attr = kcat_attr_table[i]
- local a = tex.getattribute(attr)
+ local a = tex_getattr(attr)
tex.setattribute(g,attr,(floor(a/pow_table[i+1])*2+kc)*pow_table[i]+a%pow_table[i])
end
end
local node_free = node.free
local id_glyph = node.id('glyph')
local getcatcode = tex.getcatcode
-local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
+local ltjc_is_japanese_char_curlist = ltjc.is_japanese_char_curlist
local FFFFF = string.char(0xF3,0xBF,0xBF,0xBF)
--- the following function is modified from jafontspec.lua (by K. Maeda).
-- Is the catcode of endline character is 5 (end-of-line)?
-- Is the catcode of U+FFFFF (new comment char) is 14 (comment)?
if ((ct==11) or (ct==12)) and ctl then
- local p = node_new(id_glyph)
- p.char = c
- if ltjc_is_ucs_in_japanese_char(p) then
+ if ltjc_is_japanese_char_curlist(c) then
buffer = buffer .. FFFFF -- U+FFFFF
end
- node_free(p)
end
end
end
[id_whatsit] = function(lp)
local lps = getsubtype(lp)
if lps==sid_user then
- if getsubtype(lp, 'user_id')==luatexja.userid_table.IHB then
+ if getfield(lp, 'user_id')==luatexja.userid_table.IHB then
local lq = node_next(lp);
head = node_remove(head, lp); node_free(lp); ihb_flag = true
return false, lq;
\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-core}[2014/01/13 Core of LuaTeX-ja]
+ \ProvidesPackage{luatexja-core}[2014/01/24 Core of LuaTeX-ja]
\fi %</LaTeX>
%% Load prerequisite packages.
{Package loading is aborted now.\MessageBreak}
\expandafter\endinput\fi\relax
- \@PackageInfo{luatexja-core}
- {This LuaTeX-ja uses\space%
+ \@PackageInfoNoLine{luatexja-core}
+ {using\space%
\directlua{if node.direct==node then tex.write('traditional node')
- else tex:write('DIRECT') end} access model for accessing nodes.}
+ else tex.write('DIRECT') end} node access model}
%! なお、luatexbase-compat の説明に従うと、LuaTeX 拡張プリミティブは
%! plain/LaTeX の両方で \luatex 付の名前(\directlua はそのまま)