--- /dev/null
+%#! lualatex -shell-escape
+\input docstrip.tex
+\askforoverwritefalse
+\generate{\file{luatexja-ja.tex}{\from{luatexja.dtx}{ja}}
+ \file{luatexja-en.tex}{\from{luatexja.dtx}{en}}}
+\immediate\write18{lualatex luatexja-ja}
+\immediate\write18{lualatex luatexja-en}
+\endbatchfile
+++ /dev/null
-%#! lualatex -shell-escape
-\input docstrip.tex
-\askforoverwritefalse
-\generate{\file{man-ja.tex}{\from{manual.dtx}{ja}}
- \file{man-en.tex}{\from{manual.dtx}{en}}}
-\immediate\write18{lualatex man-ja}
-\immediate\write18{lualatex man-en}
-\endbatchfile
\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-otf}[2011/09/09 v0.1]
+ \ProvidesPackage{luatexja-otf}[2012/4/20 v0.2]
\fi %</LaTeX>
% Load core module if not yet.
\ifx\luatexjacoreLoaded\@undefined
\ifltj@in@latex %<*LaTeX>
- \RequirePackage{luatexja-core}[2011/04/01]
+ \RequirePackage{luatexja-core}[2012/04/20]
\else %<*!LaTeX>
\input luatexja-core.sty %
\fi %</LaTeX>
%%------------------
%! Main part of luatexja-otf
-\RequireLuaModule{luatexja.otf}
+\directlua{luatexja.load_module('otf')}
\newcount\ltj@tempcnta
for j,v in ipairs(metrics) do
if v.name==jfm_file_name then return j end
end
- ltj.loadlua('jfm-' .. jfm_file_name .. '.lua')
+ luatexja.load_lua('jfm-' .. jfm_file_name .. '.lua')
if defjfm_res then
defjfm_res.name = jfm_file_name
table.insert(metrics, defjfm_res)
function jfontdefX(g)
local t = token.get_next()
cstemp=token.csname_name(t)
- if g then ltj.is_global = '\\global' else ltj.is_global = '' end
+ if g then luatexja.is_global = '\\global' else luatexja.is_global = '' end
tex.sprint(cat_lp, '\\expandafter\\font\\csname ' .. cstemp .. '\\endcsname')
end
"bad JFM `" .. jfm_file_name .. "'",
'The JFM file you specified is not valid JFM file.\n'..
'So defining Japanese font is cancelled.')
- tex.sprint(cat_lp, ltj.is_global .. '\\expandafter\\let\\csname ' ..cstemp
+ tex.sprint(cat_lp, luatexja.is_global .. '\\expandafter\\let\\csname ' ..cstemp
.. '\\endcsname=\\relax')
return
end
local fmtable = { jfm = j, size = f.size, var = jfm_var }
fmtable = luatexbase.call_callback("luatexja.define_jfont", fmtable, fn)
font_metric_table[fn]=fmtable
- tex.sprint(cat_lp, ltj.is_global .. '\\protected\\expandafter\\def\\csname '
+ tex.sprint(cat_lp, luatexja.is_global .. '\\protected\\expandafter\\def\\csname '
.. cstemp .. '\\endcsname{\\ltj@curjfnt=' .. fn .. '\\relax}')
end
localdir = file.join(kpse.expand_var("$TEXMFVAR"), aux_dir),
systemdir = file.join(kpse.expand_var("$TEXMFSYSVAR"), aux_dir),
}
-local cid_replace = {
- ["Adobe-Japan1"] = "UniJISX0213-UTF32",
- ["Adobe-Korea1"] = "UniKS-UTF32",
- ["Adobe-GB1"] = "UniGB-UTF32",
- ["Adobe-CNS1"] = "UniCNS-UTF32",
-}
-
--- reading CID maps
-local line, fh, tt
-
-local function load_bf_char()
- local cid, ucs, ucsa
- line = fh:read("*l")
- while line do
- if line == "endcidchar" then
- line = fh:read("*l"); return
- else -- WMA l is in the form "<%x+>%s%d+"
- ucs, cid = string.match(line, "<(%x+)>%s+(%d+)")
- cid = tonumber(cid, 10); ucs = tonumber(ucs, 16);
- if not tt[ucs] then
- tt[ucs] = { index = cid, width = 655360 }
- end
- end
- line = fh:read("*l")
- end
-end
-
-local function load_bf_range()
- local bucs, eucs, cid
- line = fh:read("*l")
- while line do
- if line == "endcidrange" then
- line = fh:read("*l"); return
- else -- WMA l is in the form "<%x+>%s+<%x+>"
- bucs, eucs, cid = string.match(line, "<(%x+)>%s+<(%x+)>%s+(%d+)")
- cid = tonumber(cid, 10); bucs = tonumber(bucs, 16); eucs = tonumber(eucs, 16);
- for ucs = bucs, eucs do
- if not tt[ucs] then
- tt[ucs] = { index = cid, width = 655360 }
- end
- cid = cid+1
- end
- end
- line = fh:read("*l")
- end
-end
-
-local function make_cid_font()
- cidfont_data[cid_name] = {
- cidinfo = { ordering=cid_order, registry=cid_reg, supplement=cid_supp },
- encodingbytes = 2, extend=1000, format = 'opentype',
- direction = 0, characters = {}, parameters = {}, embedding = "no", cache = "yes",
- ascender = 0, descender = 0, factor = 0, hfactor = 0, vfactor = 0,
- }
- tt = {}
-
- -- Open
- -- TODO: vertical fonts?
- fh = io.open(kpse.find_file(cid_replace[cid_name] .. "-H", 'cmap files'), "r")
- line = fh:read("*l")
- while line do
- if string.find(line, "%x+%s+begincidchar") then
- load_bf_char()
- elseif string.find(line, "%x+%s+begincidrange") then
- load_bf_range()
- else
- line = fh:read("*l")
- end
- end
- fh:close(); cidfont_data[cid_name].characters = tt
- cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
-
- -- Save
- local savepath = path.localdir
- if not lfs.isdir(savepath) then
- dir.mkdirs(savepath)
- end
- savepath = file.join(savepath, "luatexja-cid-auto-"
- .. string.lower(cid_name) .. ".lua")
- if file.iswritable(savepath) then
- table.tofile(savepath, cidfont_data[cid_name],'return', false, true, false )
- else
- ltjb.package_warning('luatexja',
- 'failed to save informations of non-embedded 2-byte fonts', '')
- end
-end
--
local function read_cid_font()
- local names = {
- "luatexja-cid-std-" .. string.lower(cid_name) .. ".lua",
- "luatexja-cid-auto-" .. string.lower(cid_name) .. ".lua",
- }
- local s
- for i,v in ipairs(names) do
- local localpath = file.join(path.localdir, v)
- local systempath = file.join(path.systemdir, v)
- local kpsefound = kpse.find_file(v)
- if kpsefound and file.isreadable(kpsefound) then
- cidfont_data[cid_name] = require(kpsefound)
- cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
- return
- elseif file.isreadable(localpath) then
- cidfont_data[cid_name] = require(localpath)
- cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
- return
- elseif file.isreadable(systempath) then
- cidfont_data[cid_name] = require(systempath)
- cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
- return
- end
+ local v = "ltj-cid-" .. string.lower(cid_name) .. ".lua"
+ local localpath = file.join(path.localdir, v)
+ local systempath = file.join(path.systemdir, v)
+ local kpsefound = kpse.find_file(v)
+ if kpsefound and file.isreadable(kpsefound) then
+ cidfont_data[cid_name] = require(kpsefound)
+ cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
+ return
+ elseif file.isreadable(localpath) then
+ cidfont_data[cid_name] = require(localpath)
+ cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
+ return
+ elseif file.isreadable(systempath) then
+ cidfont_data[cid_name] = require(systempath)
+ cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters }
+ return
end
- -- Now we must create the virtual metrics from CMap.
- ltjb.package_info('luatexja',
- 'I try to generate informations of non-embedded 2-byte fonts...', '')
- make_cid_font()
+ --
end
-- High-level
\ifltj@in@latex %<*LaTeX>
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-base}[2011/04/01 v0.1]
+ \ProvidesPackage{luatexja-base}[2011/04/20 v0.2]
\fi %</LaTeX>
-
-%%------------------ Lua module loading
-
-%% Quark tokens needed in Lua modules.
-\protected\def\ltj@@q@escape{\ltj@@q@escape@}
-\protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
-
-%%
-\countdef\ltj@@count@zero=0 %
-\luatexattributedef\ltj@@attr@zero=0 %
-\dimendef\ltj@@dimen@zero=0 %
-\skipdef\ltj@@skip@zero=0 %
-
-%% Load Lua modules.
-\RequireLuaModule{luatexja.base}
-\RequireLuaModule{luatexja.tangle}
%%------------------ Tiny helpers
%% Registers
\newcount\ltj@tempcnta
\newcount\ltj@tempcntb
+\newcount\ltj@tempcntc
\newdimen\ltj@tempdima
+\newskip\ltj@tempskipa
+\newtoks\ltj@temptoks
+
+\countdef\ltj@@count@zero=0 %
+\luatexattributedef\ltj@@attr@zero=0 %
+\dimendef\ltj@@dimen@zero=0 %
+\skipdef\ltj@@skip@zero=0 %
%% Quarks
%! ただ expl3 の quark とは異なり展開されるとエラーになる.
% Load core module if not yet.
\ifx\luatexjacoreLoaded\@undefined
\ifltj@in@latex %<*LaTeX>
- \RequirePackage{luatexja-core}[2011/04/01]
+ \RequirePackage{luatexja-core}[2012/04/20]
\else %<*!LaTeX>
\input luatexja-core.sty %
\fi %</LaTeX>
% not yet implemented.
%%------------------
-%! これ以降に LuaTeX 用の compat の内容を入れる.
-\RequireLuaModule{luatexja.jisx0208} %% JIS X 0208 => unicode のテーブル
-\RequireLuaModule{luatexja.compat}
+
+\directlua{
+ luatexja.load_module('jisx0208');
+ luatexja.load_module('compat');
+}
\def\euc{\ltj@code@conv{euc}}
\def\kuten{\ltj@code@conv{kuten}}
\def\ucs{\ltj@code@conv{ucs}}
\def\ltj@code@conv#1{%
- \directlua{ luatexja._cc_next = luatexja.compat.from_#1 }%
+ \directlua{luatexja._cc_next = luatexja.compat.from_#1 }%
\ltj@code@convA
}
\def\ltj@code@convA{%
\ltj@code@convB\ltj@grab@num
}
\def\ltj@code@convB#1{%
- \directlua{ luatexja._cc_next(\ltj@safe@num{#1}) }%
+ \directlua{luatexja._cc_next(\ltj@safe@num{#1}) }%
}
\def\kansuji{%
+\tracingall
\expandafter\expandafter\expandafter
\ltj@kansujiA\ltj@grab@num
}
\def\ltj@kansujiA#1{%
- \directlua{ luatexja.compat.to_kansuji(\ltj@safe@num{#1}) }%
+ \directlua{luatexja.compat.to_kansuji(\ltj@safe@num{#1}) }%
}
\define@key[ltj]{japaram}{kansujichar}{%
\expandafter\ltj@@set@stack#1:{ksj}{0}{0x7FFFFFFF}}
\expandafter\let\csname ifltj@in@latex\expandafter\endcsname
\csname iftrue\endcsname
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{luatexja-core}[2011/04/01 v0.1]
+ \ProvidesPackage{luatexja-core}[2012/04/20 v0.2]
\fi %</LaTeX>
%% Load prerequisite packages.
\let\LuaTeXjaAvailable=t %
%%------------------
-
-%% Load all sub-packages.
-\ifltj@in@latex %<*LaTeX>
- \RequirePackage{luatexja-cctbreg}[2011/04/01]
- \RequirePackage{luatexja-base}[2011/04/01]
-\else %<*!LaTeX>
- \input luatexja-cctbreg.sty %
- \input luatexja-base.sty %
-\fi %</LaTeX>
-
-%%------------------
\endlinechar=13
%! この中に master の luatexja-core.sty の内容を挿入する
%! ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
\def\ltj@loaded{hoge}
-\newcount\ltj@tempcnta
-\newcount\ltj@tempcntb
-\newcount\ltj@tempcntc
-\newdimen\ltj@tempdima
-\newskip\ltj@tempskipa
-\newtoks\ltj@temptoks
-
\newdimen\ltj@zw
\newdimen\ltj@zh
\newdimen\jQ \jQ=0.25mm
\def\ltj@defnum{0}
\def\ltj@defdimen{0}
-
%%%%%%%% Attributes for Japanese typesetting.
\newluatexattribute\ltj@curjfnt % index for ``current Japanese font''
\newluatexattribute\jfam % index for current jfam
\newluatexattribute\ltj@autoxspc % attribute for autoxspacing
\newluatexattribute\ltj@icflag % attribute for italic correction
-%%%%%%%% Loading lua files
+%%%%%%%% Loading luatexja.lua
+%% Quark tokens needed in ltj-base
+\protected\def\ltj@@q@escape{\ltj@@q@escape@}
+\protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
+
\directlua{%
- utf = unicode.utf8
- ltj = {}
- function ltj.loadlua(file)
- local path = assert(kpse.find_file(file, 'tex'),
- "File '"..file.."' not found")
- texio.write_nl("("..path..")")
- dofile(path)
+ luatexja = {}
+ function luatexja.error(s,t)
+ tex.error('LuaTeX-ja error: ' .. s ,t)
+ end
+ function luatexja.load_module(name)
+ local fn = 'ltj-' .. name .. '.lua'
+ local found = kpse.find_file(fn, 'tex')
+ if not found then
+ luatexja.error("File `" .. fn .. "' not found",
+ {'This file ' .. fn .. ' is required for LuaTeX-ja.', 'Please check your installation.'})
+ else
+ texio.write('(' .. found .. ')')
+ require(found)
+ end
end
- ltj.loadlua('luatexja-core.lua')
+ local path = assert(kpse.find_file('luatexja.lua', 'tex'),
+ "File `luatexja.lua' not found")
+ dofile(path)
}
+%%%%%%%% Load all sub-packages.
+\ifltj@in@latex %<*LaTeX>
+ \RequirePackage{luatexja-cctbreg}[2011/04/01]
+ \RequirePackage{luatexja-base}[2011/04/20]
+\else %<*!LaTeX>
+ \input luatexja-cctbreg.sty %
+ \input luatexja-base.sty %
+\fi %</LaTeX>
+
%%%%%%%% Attributes for character ranges
\ltj@tempcnta=0
\advance\ltj@tempcnta by1
\repeat
-
%%%%%%%% \asluastring
\def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
%%%%%%%% \inhibitglue
\protected\def\ltj@reset@globaldefs{%
- \directlua{ltj.global_temp = tex.globaldefs; tex.globaldefs = 0}}
-\protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = ltj.global_temp}}
+ \directlua{luatexja.global_temp = tex.globaldefs; tex.globaldefs = 0}}
+\protected\def\ltj@restore@globaldefs{\directlua{tex.globaldefs = luatexja.global_temp}}
\let\new@everypar=\everypar
\protected\def\inhibitglue{\relax%
\ifvmode
\define@key[ltj]{japaram}{postbreakpenalty}{%
\expandafter\ltj@@set@stack#1:{post}{-10000}{10000}}
\def\ltj@@set@stack#1,#2:#3#4#5{%
- \directlua{luatexja.stack.set_stack_table(ltj.isglobal, \asluastring{#3},
+ \directlua{luatexja.stack.set_stack_table(luatexja.isglobal, \asluastring{#3},
\ltj@safe@num@or\ltj@defnum{#1},\ltj@safe@num@or\ltj@defnum{#2},#4,#5)}}
% jatextfont = {<char_code>, <font_cs>}
{\string#2 is not a control sequence that represents \MessageBreak
a Japanese font}{}%
\else
- \directlua{luatexja.stack.set_stack_font(ltj.isglobal, \asluastring{#3},
+ \directlua{luatexja.stack.set_stack_font(luatexja.isglobal, \asluastring{#3},
\ltj@safe@num@or\ltj@defnum{#1}, \the\ltj@curjfnt)}%
\fi
\ltj@curjfnt=\ltj@tempcnta
% yalbaselineshift = <dimen>
% yjabaselineshift = <dimen>
\define@key[ltj]{japaram}{yalbaselineshift}{%
- \directlua{tex.setattribute(ltj.isglobal,
+ \directlua{tex.setattribute(luatexja.isglobal,
luatexbase.attributes['ltj@yablshift'],
\ltj@safe@dimen@or\ltj@defdimen{#1})}}
\define@key[ltj]{japaram}{yjabaselineshift}{%
- \directlua{tex.setattribute(ltj.isglobal,
+ \directlua{tex.setattribute(luatexja.isglobal,
luatexbase.attributes['ltj@ykblshift'],
\ltj@safe@dimen@or\ltj@defdimen{#1})}}
\def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
\def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
\def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
- \directlua{luatexja.stack.set_stack_table(ltj.isglobal, 'xsp',
+ \directlua{luatexja.stack.set_stack_table(luatexja.isglobal, 'xsp',
\ltj@safe@num@or\ltj@defnum{#1},
\ltj@safe@num@or\ltj@defnum{\ltj@temp},0,3)}}
\def\ltj@tempa{preonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{1}\fi
\def\ltj@tempa{postonly}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{2}\fi
\def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
- \directlua{luatexja.stack.set_stack_table(ltj.isglobal, 'xsp',
+ \directlua{luatexja.stack.set_stack_table(luatexja.isglobal, 'xsp',
\ltj@safe@num@or\ltj@defnum{#1},
\ltj@safe@num@or\ltj@defnum{\ltj@temp},0,3)}}
% autospacing = <bool> (default: true)
\define@boolkey[ltj]{japaram}{autospacing}[true]{%
\ifltj@japaram@autospacing
- \directlua{ltj.ext_print_global()}\ltj@autospc=1
+ \directlua{luatexja.ext_print_global()}\ltj@autospc=1
\else
- \directlua{ltj.ext_print_global()}\ltj@autospc=0
+ \directlua{luatexja.ext_print_global()}\ltj@autospc=0
\fi}
% autoxspacing = <bool> (default: true)
\define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
\ifltj@japaram@autoxspacing
- \directlua{ltj.ext_print_global()}\ltj@autoxspc=1
+ \directlua{luatexja.ext_print_global()}\ltj@autoxspc=1
\else
- \directlua{ltj.ext_print_global()}\ltj@autoxspc=0
+ \directlua{luatexja.ext_print_global()}\ltj@autoxspc=0
\fi}
% [x]]kanjiskip = <dimen>
\define@key[ltj]{japaram}{kanjiskip}{% % SKIP
- \directlua{luatexja.stack.set_stack_skip(ltj.isglobal, 'kanjiskip', \ltj@safe@glue{#1})}}
+ \directlua{luatexja.stack.set_stack_skip(luatexja.isglobal, 'kanjiskip', \ltj@safe@glue{#1})}}
\define@key[ltj]{japaram}{xkanjiskip}{% % SKIP
- \directlua{luatexja.stack.set_stack_skip(ltj.isglobal, 'xkanjiskip', \ltj@safe@glue{#1})}}
+ \directlua{luatexja.stack.set_stack_skip(luatexja.isglobal, 'xkanjiskip', \ltj@safe@glue{#1})}}
% jcharwidowpenalty = <count>
\define@key[ltj]{japaram}{jcharwidowpenalty}{% %COUNT
\edef\ltj@temp{#1}%
\ifx\ltj@temp\empty\let\next=\relax\else\let\next=\ltj@@scrange
\directlua{luatexja.charrange.toggle_char_range(%
- ltj.is_global,\ltj@safe@num@or\ltj@defnum{#1})}%
+ luatexja.is_global,\ltj@safe@num@or\ltj@defnum{#1})}%
\fi\next
}
\protected\def\ltjsetparameter#1{%
- \ifnum\globaldefs>0\directlua{ltj.isglobal='global'}\else\directlua{ltj.isglobal=''}\fi
+ \ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}\else\directlua{luatexja.isglobal=''}\fi
\setkeys[ltj]{japaram}{#1}\ignorespaces}
\protected\def\ltjglobalsetparameter#1{%
- \ifnum\globaldefs<0\directlua{ltj.isglobal=''}\else\directlua{ltj.isglobal='global'}\fi
+ \ifnum\globaldefs<0\directlua{luatexja.isglobal=''}\else\directlua{luatexja.isglobal='global'}\fi
\setkeys[ltj]{japaram}{#1}\ignorespaces}
%%%%%%%% \ltjgetparameter
{\ltj@@getparam@one{#1}}%
}
\def\ltj@@getparam@one#1{%
- \directlua{ltj.ext_get_parameter_unary('#1')}}%
+ \directlua{luatexja.ext_get_parameter_unary('#1')}}%
\def\ltj@@getparam@two#1#2{%
- \directlua{ltj.ext_get_parameter_binary('#1', \ltj@safe@num{#2})}%
+ \directlua{luatexja.ext_get_parameter_binary('#1', \ltj@safe@num{#2})}%
}
%%%%%%%% \ltjalchar<number>, \ltjjachar<number>
+
+local floor = math.floor
+
require('lualibs')
-require('luatexja.rmlgbm'); local ltjr = luatexja.rmlgbm -- must be 1st
-require('luatexja.base'); local ltjb = luatexja.base
-require('luatexja.charrange'); local ltjc = luatexja.charrange
-require('luatexja.jfont'); local ltjf = luatexja.jfont
-require('luatexja.inputbuf'); local ltji = luatexja.inputbuf
-require('luatexja.jfmglue'); local ltjj = luatexja.jfmglue
-require('luatexja.math'); local ltjm = luatexja.math
-require('luatexja.pretreat'); local ltjp = luatexja.pretreat
-require('luatexja.stack'); local ltjs = luatexja.stack
-require('luatexja.setwidth'); local ltjw = luatexja.setwidth
+
+------------------------------------------------------------------------
+-- naming:
+-- ext_... : called from \directlua{}
+-- int_... : called from other Lua codes, but not from \directlua{}
+-- (other) : only called from this file
+
+function luatexja.load_lua(fn)
+ local found = kpse.find_file(fn, 'tex')
+ if not found then
+ error("File `" .. fn .. "' not found")
+ else
+ texio.write('(' .. found .. ')')
+ require(found)
+ end
+end
+
+local load_module = luatexja.load_module
+load_module('base'); local ltjb = luatexja.base
+load_module('rmlgbm'); local ltjr = luatexja.rmlgbm -- must be 1st
+load_module('charrange'); local ltjc = luatexja.charrange
+load_module('jfont'); local ltjf = luatexja.jfont
+load_module('inputbuf'); local ltji = luatexja.inputbuf
+load_module('stack'); local ltjs = luatexja.stack
+load_module('pretreat'); local ltjp = luatexja.pretreat
+load_module('jfmglue'); local ltjj = luatexja.jfmglue
+load_module('setwidth'); local ltjw = luatexja.setwidth
+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 IC_PROCESSED = 9
local BOXBDD = 15
-------------------------------------------------------------------------
--- naming:
--- ltj.ext_... : called from \directlua{}
--- ltj.int_... : called from other Lua codes, but not from \directlua{}
--- (other) : only called from this file
-
--- error messages
-function ltj.error(s,t)
- tex.error('LuaTeX-ja error: ' .. s ,t)
-end
-- Three aux. functions, bollowed from tex.web
local unity=65536
-function print_scaled(s)
+local function print_scaled(s)
local out=''
local delta=10
if s<0 then
out=out..'-'; s=-s
end
- out=out..tostring(math.floor(s/unity)) .. '.'
+ out=out..tostring(floor(s/unity)) .. '.'
s=10*(s%unity)+5
repeat
if delta>unity then s=s+32768-50000 end
- out=out .. tostring(math.floor(s/unity))
+ out=out .. tostring(floor(s/unity))
s=10*(s%unity)
delta=delta*10
until s<=delta
------------------------------------------------------------------------
-- EXT: print parameters that don't need arguments
-function ltj.ext_get_parameter_unary(k)
+function luatexja.ext_get_parameter_unary(k)
if k == 'yalbaselineshift' then
tex.write(print_scaled(tex.getattribute('ltj@yablshift'))..'pt')
elseif k == 'yjabaselineshift' then
end
end
+
-- EXT: print parameters that need arguments
-function ltj.ext_get_parameter_binary(k,c)
+function luatexja.ext_get_parameter_binary(k,c)
if k == 'jacharrange' then
if c<0 or c>216 then
ltjb.package_error('luatexja',
end
-- EXT: print \global if necessary
-function ltj.ext_print_global()
- if ltj.isglobal=='global' then tex.sprint(cat_lp, '\\global') end
+function luatexja.ext_print_global()
+ if isglobal=='global' then tex.sprint(cat_lp, '\\global') end
end
-- main process
return p
end
+-- callbacks
+
+luatexbase.add_to_callback('pre_linebreak_filter',
+ function (head,groupcode)
+ return main_process(head, true, tex.textdir)
+ end,'ltj.pre_linebreak_filter',
+ luatexbase.priority_in_callback('pre_linebreak_filter',
+ 'luaotfload.pre_linebreak_filter') + 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)
-- debug
local debug_depth
-function ltj.ext_show_node_list(head,depth,print_fn)
- debug_depth = depth
- if head then
- while head do
- debug_show_node_X(head, print_fn); head = node_next(head)
- end
- else
- print_fn(debug_depth .. ' (null list)')
- end
-end
-function ltj.ext_show_node(head,depth,print_fn)
- debug_depth = depth
- if head then
- debug_show_node_X(head, print_fn)
- else
- print_fn(debug_depth .. ' (null list)')
- end
-end
-function debug_show_node_X(p,print_fn)
+
+local function debug_show_node_X(p,print_fn)
local k = debug_depth
local s
local pt=node_type(p.id)
if p.glue_sign >= 1 then
s = s .. ' glue set '
if p.glue_sign == 2 then s = s .. '-' end
- s = s .. tostring(math.floor(p.glue_set*10000)/10000)
+ s = s .. tostring(floor(p.glue_set*10000)/10000)
if p.glue_order == 0 then
s = s .. 'pt'
else
end
p=node_next(p)
end
-
-
--- callbacks
-
-luatexbase.add_to_callback('pre_linebreak_filter',
- function (head,groupcode)
- return main_process(head, true, tex.textdir)
- end,'ltj.pre_linebreak_filter',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'luaotfload.pre_linebreak_filter') + 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)
+function luatexja.ext_show_node_list(head,depth,print_fn)
+ debug_depth = depth
+ if head then
+ while head do
+ debug_show_node_X(head, print_fn); head = node_next(head)
+ end
+ else
+ print_fn(debug_depth .. ' (null list)')
+ end
+end
+function luatexja.ext_show_node(head,depth,print_fn)
+ debug_depth = depth
+ if head then
+ debug_show_node_X(head, print_fn)
+ else
+ print_fn(debug_depth .. ' (null list)')
+ end
+end
\ No newline at end of file
%#! lualatex
\documentclass{ltjsarticle}
-\nonstopmode
+%\nonstopmode
\makeatletter
\newpage{\obeylines\tt
\setbox0=\hbox{\gt\textsl{あいう■\textup{■え■}■おかき}}
-\directlua{ltj.ext_show_node_list(tex.box[0].head, '', tex.print)}\par}
+\directlua{luatexja.ext_show_node_list(tex.box[0].head, '', tex.print)}\par}
\bigskip
\char\jis{"346E}
\char\kuten{"253C}
\char\euc{"B0A5}
-\char\sjis"8A79
+\char\sjis{"8A79}
%\char\sjis{"B4}
%\char\euc"8EBE
\def\dumplist#1{\par\noindent\leavevmode
\hbox to 0.2\hsize{\copy#1\hss}%
\vbox{\hsize=0.6\hsize\sixtt\baselineskip=7.2pt\sixgt\let\\=\relax
-\directlua{ltj.ext_show_node_list(tex.getbox(#1).head, '\\par ', tex.print)}\hrule}}
+\directlua{luatexja.ext_show_node_list(tex.getbox(#1).head, '\\par ', tex.print)}\hrule}}
%\tracingonline=1\tracingoutput=1\showboxdepth=3\showboxbreadth=100
\def\dumplist#1{\par\noindent\leavevmode
\hbox to 0.2\hsize{\copy#1\hss}%
\vbox{\hsize=0.6\hsize\sixtt\baselineskip=7.2pt\sixgt\let\\=\relax
-\directlua{ltj.ext_show_node_list(tex.getbox(#1).head, '\\par ', tex.print)}\hrule}}
+\directlua{luatexja.ext_show_node_list(tex.getbox(#1).head, '\\par ', tex.print)}\hrule}}
\ltjsetparameter{yalbaselineshift=0pt,yjabaselineshift=0pt}
\setbox0=\hbox{\d Hy}\dumplist0