OSDN Git Service

Implemented \jcharwidowpenalty, and fixed the treatment of character ranges.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 23 Apr 2011 03:50:36 +0000 (12:50 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 23 Apr 2011 03:50:36 +0000 (12:50 +0900)
13 files changed:
doc/s1sty.tex
doc/sample1.log
doc/sample1.pdf
doc/sample1.tex
src/luatexja-core.lua
src/luatexja-core.sty
src/luatexja-jfont.lua
src/luatexja-plain.tex
test/test03-after.pdf
test/test03-after.tex
test/test04-jfm.log
test/test04-jfm.pdf
test/test04-jfm.tex

index 313fded..f57cca1 100644 (file)
 
 {\catcode`\_=\active \global\catcode`\<=\active
 \gdef<{\begingroup\catcode`\_=\active\let_=\_\it\@arg}
-\gdef\@arg#1>{$\langle$#1$\rangle$\endgroup}
+\gdef\@arg#1>{$\langle$#1\/$\rangle$\endgroup}
 }
 
+\def\lvert{\delimiter"426A30C }
+\def\rvert{\delimiter"526A30C }
+
 % itemize
 \newcount\enumi\enumi=0
 \def\item{\par\medskip\leftskip=2\zw\noindent\hskip-1\zw\hbox to 1\zw{\hss$\bullet$\hss}}
index fbd3be6..dd95159 100644 (file)
@@ -1,4 +1,4 @@
-This is LuaTeX, Version beta-0.66.0-2011032121 (rev 4093)  (format=luatex 2011.3.21)  20 APR 2011 15:10
+This is LuaTeX, Version beta-0.66.0-2011032121 (rev 4093)  (format=luatex 2011.4.20)  23 APR 2011 12:48
  restricted \write18 enabled.
 **sample1
 (./sample1.tex (./s1sty.tex
@@ -170,10 +170,11 @@ Package: infwarerr 2010/04/08 v1.3 Providing info/warning/message (HO)
 )
 \luatexja@tempcnta=\count281
 \luatexja@tempcntb=\count282
+\luatexja@tempcntc=\count283
 \luatexja@tempdima=\dimen256
-\luatexja@autospc=\count283
-\luatexja@autoxspc=\count284
-\jcharwidowpenalty=\count285
+\luatexja@autospc=\count284
+\luatexja@autoxspc=\count285
+\jcharwidowpenalty=\count286
 \kanjiskip=\skip256
 \xkanjiskip=\skip257
 \zw=\dimen257
@@ -186,11 +187,6 @@ Package: infwarerr 2010/04/08 v1.3 Providing info/warning/message (HO)
 \luatexja@ykblshift=\luatexattribute12
 \luatexja@icflag=\luatexattribute13
 \luatexja@japanese=\language87
-\luatexja@kcat0=\luatexattribute14
-\luatexja@kcat1=\luatexattribute15
-\luatexja@kcat2=\luatexattribute16
-\luatexja@kcat3=\luatexattribute17
-\luatexja@kcat4=\luatexattribute18
 
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-rmlgbm.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-rmlgbm-data.lu
@@ -208,17 +204,23 @@ Module luatexbase-mcb info: inserting 'ltj.hyphenate'
 (luatexbase-mcb)            at position 1 in 'hyphenate'
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-jfont.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-core-aux.lua)
-\ltj@stack@pbp=\count286
-\ltj@group@level@pbp=\count287
+\luatexja@kcat0=\luatexattribute14
+\luatexja@kcat1=\luatexattribute15
+\luatexja@kcat2=\luatexattribute16
+\luatexja@kcat3=\luatexattribute17
+\luatexja@kcat4=\luatexattribute18
+\luatexja@kcat5=\luatexattribute19
+\luatexja@kcat6=\luatexattribute20
+\ltj@stack@pbp=\count287
+\ltj@group@level@pbp=\count288
 
 plain format: loading luatexja-plain.tex
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-plain.tex
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua) (other)
-(iso8859-1)
+(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-kinsoku.tex)))
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-mono.lua)
 \vspbox=\box256
-\enumi=\count288
+\enumi=\count289
 ) BB AA
 特徴 制限 ファイル構成 使用方法 [1{/opt/texlive/p2010/texmf-var/f
 onts/map/pdftex/updmap/pdftex.map
@@ -240,26 +242,9 @@ x.map): fontmap entry for `bchri8r' already exists, duplicates ignored
 LuaTeX warning (file /opt/texlive/p2010/texmf-var/fonts/map/pdftex/updmap/pdfte
 x.map): fontmap entry for `bchro8r' already exists, duplicates ignored
 }] 和文フォントの定義 「和文文字の範囲」の設定 [2]
-組版パラメタの調整 [3] その他の命令 [4] JFMについて
-大まかな処理の流れ [5]
-Overfull \hbox (16.21461pt too wide) in paragraph at lines 336--340
- [][]\tenmin こ の 段 階 の 前 で は[] 和 文 文 字 で あっ て 
-も[] そ れ を 内 部 で 表 し て い る \tentt glyph[]node $\teni p$ 
-\tenmin は[] []\tentt \tenrm \tenjtt あ[]
-
-\hbox(8.45029+2.22223)x412.9118, glue set - 1.0, direction TLT
-.\glue(\leftskip) 19.2052
-.\whatsit
-..\localinterlinepenalty=0
-..\localbrokenpenalty=0
-..\localleftbox=null
-..\localrightbox=null
-.\hbox(0.0+0.0)x9.6026, direction TLT
-.\tenmin こ
-.\glue 0.0 plus 0.4 minus 0.4
-.etc.
-
-[6] [7] 名称について 表記法 読み方 機能 [8] 数式の表示例
+組版パラメタの調整 [3] 組版パラメタの取得 [4]
+その他の命令 JFMについて [5] 大まかな処理の流れ [6] [7]
+名称について 表記法 読み方 機能 [8] 数式の表示例
 生い立ち T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emXの日本語化
 [9]
 T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emXによる組版の作業工
@@ -279,7 +264,7 @@ opt/texlive/p2010/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/te
 xlive/p2010/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb></opt/texlive/
 p2010/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt8.pfb></opt/texlive/p2010/t
 exmf-dist/fonts/type1/hoekwater/manfnt/manfnt.pfb>
-Output written on sample1.pdf (11 pages, 213643 bytes).
+Output written on sample1.pdf (11 pages, 218012 bytes).
 PDF statistics: 114 PDF objects out of 1000 (max. 8388607)
  82 compressed objects within 1 object stream
  0 named destinations out of 1000 (max. 131072)
index c030c4c..cfa0514 100644 (file)
Binary files a/doc/sample1.pdf and b/doc/sample1.pdf differ
index 348a880..34970a6 100644 (file)
@@ -130,50 +130,29 @@ PSフォント名<PSfont_name>を直接指定することもでき,
 (|test01-noembed.pdf|を参照).
 \enditem
 
+\item 不良なJFMを用いた場合,エラーを返すとともに,<font>の意味は|\relax|となる.
+
 \beginparagraph 「和文文字の範囲」の設定
 
-\item |\defcharrange{<name>}{<char_range>}|: 文字範囲の定義
-\itemitem <name>: 範囲を参照するためにつけるkey
-\itemitem <range>: 文字範囲を|"100-"200, 800, 1701-|のように指定する.
+\item |\defcharrange{<number>}{<char_range>}|: 文字範囲の新規定義/追加
+\itemitem <number>:  文字範囲の番号で,1--216の整数値で指定
+\itemitem <range>: 文字コードの範囲を|"100-"200, 800, 1701-|のように指定する.
 \itemT ASCII codeの範囲 (|0x00|--|0x7F|) は指定できない.
-\itemT 既に他の文字範囲に使われている領域を指定することはできない.
-また,内部処理の都合上,引数に指定している範囲達はdisjointでなければならない.
-\item 各「文字範囲」ごとに,以下の5種類の取り扱い方を設定できる.
-{\bf 下表の3, 4列目の部分についてはまだ未実装である.}
-
-\medskip
-
-\vbox{\leavevmode\hfill\leftskip=0pt\vbox{\lineskiplimit=\maxdimen\lineskip=0pt\halign{%
-\quad\hfil#\hskip.5\zw\vrule height 1.38\zh depth 0.62\zh%
-\hskip.5\zw&\hfil#\hfil\quad&\hfil#\hfil\quad&\hfil#\hfil\quad\cr
-\noalign{\hrule height 0.8pt}
-        &\bf 和文文字扱い&|\catcode|&\bf |\jcharwidowpenalty|無視\cr
-\noalign{\hrule}
-|punct| &○          &12        &○                 \cr
-\noalign{\hrule}
-|letter|&○          &12        &NO                 \cr
-\noalign{\hrule}
-|kanji| &○          &11        &NO                 \cr
-\noalign{\hrule}
-|kana|  &○          &11        &NO                 \cr
-\noalign{\hrule}
-|noncjk|&NO          &|\catcode|依存&---\cr
-\noalign{\hrule height 0.8pt}
-}}\hfill\null}
-
-Lua\TeX-ja では文字範囲の設定用に5つのattributeを確保しており,
-{\bf 1つの文書中に設定できる文字範囲の数は49個までである.}
-
-\item デフォルトでは,|0x100|以降の文字コードは全部|kanji|扱いであり,さらに文字範囲として,
+\itemT 既に他の$n$番の文字範囲に使われている領域を指定した場合は,
+その領域は$n$番の文字範囲からは除外される.即ち,後に定義した文字範囲の方が優先度が高い.
+\itemitem 定義した文字範囲ごとに,「和文扱い」「欧文扱い」をlocalに指定できる.
+% 216 = (31*7-1)
+
+\item デフォルトでは,|U+0100|以降の文字は全部和文扱いであり,さらに文字範囲として,
 \begintt
-  \defcharrange{iso88591}{"80-"FF}
-  \setjaparameter{jcharrange={iso8859-1=noncjk}}
+  \defcharrange{1}{"80-"FF}
+  \setjaparameter{jcharrange={-1}}
 \endtt
\81\8cå®\9a義ã\81\95ã\82\8cã\81¦ã\81\84ã\82\8b{\smallï¼\88ã\81¤ã\81¾ã\82\8a|0x80|--|0xFF|の範囲は欧文扱い)\inhibitglue}.
\81¨æ\8c\87å®\9aã\81\97ã\81¦ã\81\84ã\82\8b{\smallï¼\88ã\81¤ã\81¾ã\82\8aLatin-1 Supplementの範囲は欧文扱い)\inhibitglue}.
 
-TODO: 「{\setjaparameter{jcharrange={iso8859-1=kanji}}× (|U+00D7|)}」等,ISO 8859-1領域
+TODO: 「{\setjaparameter{jcharrange={1}}× (|U+00D7|)}」等,ISO 8859-1領域
 にマッピングされた文字の扱い.
-「{\setjaparameter{jcharrange={iso8859-1=kanji}}¢ (|U+00A2|)}」はHalfwidth and
+「{\setjaparameter{jcharrange={1}}¢ (|U+00A2|)}」はHalfwidth and
 Fullwidth Formsに全角形(\char"FFE0)があるから%"
 luaotfloadの置換処理に割り込めばよいが…….
 \enditem
@@ -206,15 +185,29 @@ p\TeX の|\prebreakpenalty|に対応した設定項目である.
 p\TeX では,同一文字に対して|\prebreakpenalty|, |\postbreakpenalty|の両方を定義する
 ことはできなかったが,Lua\TeX-jaでは可能である.
 
+\item |kcatcode={<chr_code>, <kind>}|★\par\noindent
+文字コード<chr_code>の文字が和文文字扱いされている時,
+「和文文字の種類」を|0|--|"7FFFFFFF|の自然数値<kind>で指定する.%"
+\itemitem 最下位bitはウィドウ防止用penaltyの挿入処理に関係する.
+\itemitem デフォルトでは,次の3つのUnicodeの範囲において,|kcatcode=1|としている.
+\itemT |U+2000|--|U+206F| (General Punctuation)
+\itemT |U+3000|--|U+303F| (CJK Symbols and Punctuation)
+\itemT |U+FF00|--|U+FFEF| (Halfwidth and Fullwidth Forms)
+
 \item |cjkxspmode={<chr_code>, <mode>}|★\par\noindent
 p\TeX の|\inhibitxspcode|に対応した設定項目である.<mode>で許される値は,
-\itemitem 0, 1, 2, 3: p\TeX の対応するprimitiveと同じ意味.
-\itemitem |inhibit|: 前後の欧文文字との間の|\xkanjiskip|自動挿入を禁止.
-\itemitem |preonly|: 前の欧文文字との間の|\xkanjiskip|自動挿入のみを許可.
-\itemitem |postonly|: 後の欧文文字との間の|\xkanjiskip|自動挿入のみを許可.
-\itemitem |allow|: 前後の欧文文字との間の|\xkanjiskip|自動挿入を許可.
+\itemitem |0|, |inhibit|: 前後の欧文文字との間の|\xkanjiskip|自動挿入を禁止.
+\itemitem |2|, |preonly|: 前の欧文文字との間の|\xkanjiskip|自動挿入のみを許可.
+\itemitem |1|, |postonly|: 後の欧文文字との間の|\xkanjiskip|自動挿入のみを許可.
+\itemitem |3|, |allow|: 前後の欧文文字との間の|\xkanjiskip|自動挿入を許可.
 \item |asciixspmode={<chr_code>, <mode>}|★\par\noindent
 同様に,p\TeX の|\xspcode|に対応した設定項目である.
+<mode>で許される値は,
+\itemitem |0|, |inhibit|: 前後の和文文字との間の|\xkanjiskip|自動挿入を禁止.
+\itemitem |1|, |preonly|: 前の和文文字との間の|\xkanjiskip|自動挿入のみを許可.
+\itemitem |2|, |postonly|: 後の和文文字との間の|\xkanjiskip|自動挿入のみを許可.
+\itemitem |3|, |allow|: 前後の和文文字との間の|\xkanjiskip|自動挿入を許可.
+
 \item |yabaselineshift=<dimen>|:
 p\TeX の|\yabaselineshift|に対応したものであり,欧文文字のベースライン補正量をdimensionで指定する.
 \itemitem 正の値を指定すると,その分だけ欧文文字は下にずれることとなる.
@@ -229,9 +222,10 @@ p\TeX では「和文が主」という考えからか,常に和文文字の
 また,この値を適切に調整することで,%
 {\small 異なる文字サイズの文字を「上下中央揃え」で組む}ことも可能である.
 
-\item |kanjiskip=<skip>|★\inhibitglue: |\kanjiskip=<skip>|と同じ意味.
-\item |xkanjiskip=<skip>|★\inhibitglue: |\xkanjiskip=<skip>|と同じ意味.
-\item |jcharwidowpenalty=<penalty>|★\inhibitglue: |\jcharwidowpenalty=<penalty>|と同じ意味.
+\item |kanjiskip=<skip>|★\inhibitglue: 後に述べる|\kanjiskip=<skip>|と同じ意味.
+\item |xkanjiskip=<skip>|★\inhibitglue: 後に述べる|\xkanjiskip=<skip>|と同じ意味.
+\item |jcharwidowpenalty=<penalty>|★\inhibitglue: 
+後に述べる|\jcharwidowpenalty=<penalty>|と同じ意味.
 \item |autospacing[=<bool>]|★◎\par\noindent
 %\item |autospacing[=<bool>]|★\par\noindent
 和文文字間のglue(|\kanjiskip|)の自動挿入をするかしないかを制御.
@@ -248,20 +242,54 @@ glue/kernの計算方法を設定する.
 \itemitem {\tt average}: 両者の相加平均.
 \itemitem {\tt both}: 両者の合計値の幅をもつglue/kernを挿入する.
 
-\item |setjcharrange={<range_name>=<mode>}|: 
-\itemitem <range_name>: |\defcharrange|で定義した「文字コードの範囲」か,|other|を指定する.
-|other|は,今まで定義した文字範囲の中に属さないような文字コード
-$c\in [\hbox{\tt 0x100},\infty)$全体の集合を表す.
-\itemitem <mode>: <range_name>で指定した範囲の文字の取扱を指定.
+\item |jcharrange={<range_num>,<range_num>,...}|: 
+$\lvert\hbox{<range_num>}\rvert$番の文字範囲の文字を和文扱いするか欧文扱いするかを設定する.
+\itemitem $\lvert\hbox{<range_num>}\rvert>216$の場合,
+「どの文字範囲にも属さない|U+0100|以降の文字」に
+対しての処理を行う.
+\itemitem 正値が指定されたら,$\lvert\hbox{<range_num>}\rvert$番の文字範囲は和文文字扱いとなる.
+\itemitem 負値が指定されたら,$\lvert\hbox{<range_num>}\rvert$番の文字範囲は欧文文字扱いとなる.
+\itemitem $\hbox{<range_num>}=0$の場合は,単に無視される.
+\enditem
 
+\beginparagraph 組版パラメタの取得
 
-\enditem
+日本語組版用の各種パラメタの取得には,次の命令を用いる.
+\begintt
+  \getjaparameter{<key>} or \getjaparameter{<key>}{<chr_code>}
+\endtt
+戻り値は全て「空白は|\catcode=10|,それ以外の文字は全て|\catcode=12|」の文字列である.
+
+<key>に指定できる値は,説明がない限りは|\setjaparameter|で指定できる<key>と同じで,次の通りである,
+
+\item |kanjiskip|, |xkanjiskip|, |yabaselineshift|, |ykbaselineshift|, |jcharwidowpenalty|%
+\par\noindent
+それぞれ値を表現する文字列を返す.
+
+\item |differentjfm|: 戻り値は{\tt large}, {\tt small}, {\tt average}, {\tt both}の
+4つの文字列のいずれか.
+
+\item |prebreakpenalty|, |postbreakpenalty|, |kcatcode|, |cjkxspmode|, |asciixspmode|
+\par\noindent
+これらは各文字コード別に設定される値であるので,文字コード<chr_code>を第2引数にとる.
+指定されている整数値を表す文字列を返す.
+
+\item |jcharrange|: 文字範囲の番号$n$を第2引数にとり,$n$番の文字範囲が
+和文文字扱いされていれば|0|,欧文文字扱いされていれば|1|を返す.
+$n\notin [1,216]$の場合は,「どの文字範囲にも属さない|U+0100|以降の文字」に対しての結果を返す.
+
+\item |chartorange|: 文字コード<chr_code>を第2引数にとり,それが属している文字範囲の番号を返す.
+\itemitem <chr_code>がUnicodeの範囲外または|0x80|未満ならば,|-1|を返す.
+\itemitem 上の場合以外で,<chr_code>の文字がどの文字範囲にも属さない場合は,|217|を返す.
 
 \beginparagraph その他の命令
 
 \item skip |\kanjiskip|: 和文文字同士の間に入る空白量を指定.p\TeX の同名の命令と同様.
 \item skip |\xkanjiskip|: 和文文字と欧文文字の間に入る空白量.p\TeX の同名の命令と同様.
-\item count |\jcharwidowpenalty|: {\bf 未実装}
+\item count |\jcharwidowpenalty|: 段落において「最後の1文字のみが次の行に」くることを
+抑制するためのpenalty値.このpenaltyは,段落内にある,最後の「|kcatcode|の最下位bitが
+1で{\bf ない}ような和文文字」の直前に挿入される.
+
 \item dimen |\zw|, |\zh|: 現在の和文フォントの「幅」/「高さ」(メトリックから指定)
 \item dimen |\jQ|, |\jH|${}= 0.25\,{\rm mm}$.
 \item |\inhibitglue|: 
@@ -395,6 +423,7 @@ Lua\TeX で文字を表す|glyph_node|には|y_offset| fieldがあるので,
 
 \enditem 
 
+
 \vfill\eject
 \leftline{{\big 組版サンプル}\hfill
 \noindent 出典: 日本語Wikipediaの「\TeX」の項,2011/3/10}
index a1a21fe..6dca1a8 100644 (file)
@@ -5,6 +5,7 @@ local node_insert_after = node.insert_after
 local node_hpack = node.hpack
 local round = tex.round
 local node_new = node.new
+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')
@@ -13,6 +14,7 @@ local next_node = node.next
 local attr_jchar_class = luatexbase.attributes['luatexja@charclass']
 local attr_curjfnt = luatexbase.attributes['luatexja@curjfnt']
 local attr_yablshift = luatexbase.attributes['luatexja@yablshift']
+local attr_icflag = luatexbase.attributes['luatexja@icflag']
 
 -- error messages
 function ltj.error(s,t)
@@ -75,7 +77,7 @@ end
 
 ltj.stack_ch_table={}; ltj.stack_ch_table[0]={}
 
-local function new_stack_level()
+local function get_stack_level()
   local i = tex.getcount('ltj@stack@pbp')
   if tex.currentgrouplevel > tex.getcount('ltj@group@level@pbp') then
     i = i+1 -- new stack level
@@ -88,9 +90,20 @@ local function new_stack_level()
   end
   return i
 end
-function ltj.set_ch_table(g,m,c,p)
-  local i = new_stack_level()
-  if not ltj.stack_ch_table[i][c] then ltj.stack_ch_table[i][c] = {} end
+function ltj.set_ch_table(g,m,c,p,lb,ub)
+  local i = get_stack_level()
+  if p<lb or p>ub then 
+     ltj.error('Invalid code (' .. p .. '), should in the range '
+              .. tostring(lb) .. '..' .. tostring(ub) .. '.',
+           {"I'm going to use 0 instead of that illegal code value."})
+     p=0
+  elseif c<0 or c>0x10FFFF then
+     ltj.error('Invalid character code (' .. p 
+              .. '), should in the range 0.."10FFFF.',{})
+     return 
+  elseif not ltj.stack_ch_table[i][c] then 
+     ltj.stack_ch_table[i][c] = {} 
+  end
   ltj.stack_ch_table[i][c][m] = p
   if g=='global' then
     for j,v in pairs(ltj.stack_ch_table) do 
@@ -101,15 +114,13 @@ function ltj.set_ch_table(g,m,c,p)
 end
 
 local function get_penalty_table(m,c)
-  local i = tex.getcount('ltj@stack@pbp')
-  i = ltj.stack_ch_table[i][c]
+  local i = ltj.stack_ch_table[tex.getcount('ltj@stack@pbp')][c]
   if i then i=i[m] end
   return i or 0
 end
 
 local function get_inhibit_xsp_table(c)
-  local i = tex.getcount('ltj@stack@pbp')
-  i = ltj.stack_ch_table[i][c]
+  local i = ltj.stack_ch_table[tex.getcount('ltj@stack@pbp')][c]
   if i then i=i.xsp end
   return i or 3
 end
@@ -145,24 +156,29 @@ function ltj.out_ja_parameter_one(k)
    end
 end
 
+
+
 function ltj.out_ja_parameter_two(k,c)
-   if k == 'prebreakpenalty' then
-      tex.write(get_penalty_table('pre',c))
-   elseif k == 'postbreakpenalty' then
-      tex.write(get_penalty_table('post',c))
-   elseif k == 'cjkxspmode' then
-      local i = get_inhibit_xsp_table(c)
-      if i==0 then tex.write('inhibit')
-      elseif i==1 then  tex.write('postonly')
-      elseif i==2 then  tex.write('preonly')
-      else tex.write('allow')
+   if k == 'jcharrange' then
+      if c<0 or c>216 then c=0 end
+      tex.write(ltj.get_jcr_setting(c))
+   else
+      if c<0 or c>0x10FFFF then
+        ltj.error('Invalid character code (' .. c 
+                  .. '), should in the range 0.."10FFFF.',
+               {"I'm going to use 0 instead of that illegal character code."})
+        c=0
       end
-   elseif k == 'asciixspmode' then
-      local i = get_inhibit_xsp_table(c)
-      if i==0 then tex.write('inhibit')
-      elseif i==2 then  tex.write('postonly')
-      elseif i==1 then  tex.write('preonly')
-      else tex.write('allow')
+      if k == 'prebreakpenalty' then
+        tex.write(get_penalty_table('pre',c))
+      elseif k == 'postbreakpenalty' then
+        tex.write(get_penalty_table('post',c))
+      elseif k == 'kcatcode' then
+        tex.write(get_penalty_table('kcat',c))
+      elseif k == 'chartorange' then 
+        tex.write(ltj.get_char_jcrnumber(c))
+      elseif k == 'cjkxspmode' or k == 'asciixspmode' then
+        tex.write(get_inhibit_xsp_table(c))
       end
    end
 end
@@ -213,9 +229,11 @@ end
 function calc_between_two_jchar(q,p)
    -- q, p: node (possibly null)
    local ps,pm,qs,qm,g,h
-   if not p then -- q is the last node
+   if (not p) or (p.id==id_glue and p.subtype==15) then
+      -- q is the last node
+      -- (p is nil or \parfillskip)
       qs, qm = find_size_metric(q)
-      if not qm then 
+      if not qm then
         return nil
       else
         g=new_jfm_glue(qs,qm,
@@ -263,6 +281,7 @@ function calc_between_two_jchar(q,p)
         g=ltj.calc_between_two_jchar_aux(g,h)
       end
    end
+   if g then node.set_attribute(g,attr_icflag,2) end
    return g
 end
 
@@ -271,7 +290,7 @@ end
 --   o a hbox by \parindent
 --   o a whatsit node which contains local paragraph materials.
 -- When we insert jfm glues, we ignore these nodes.
-function ltj.is_parindent_box(p)
+local function parindent_box(p)
    if node_type(p.id)=='hlist' then 
       return (p.subtype==3)
       -- hlist (subtype=3) is a box by \parindent
@@ -285,10 +304,10 @@ local function add_kinsoku_penalty(head,p)
    local e = get_penalty_table('pre',c)
    if e~=0 then
       local q = node.prev(p)
-      if q and node_type(q.id)=='penalty' then
+      if q and q.id==id_penalty then
         q.penalty=q.penalty+e
       else 
-        q=node_new(node.id('penalty'))
+        q=node_new(id_penalty)
         q.penalty=e
         node_insert_before(head,p,q)
       end
@@ -296,11 +315,11 @@ local function add_kinsoku_penalty(head,p)
    e = get_penalty_table('post',c)
    if e~=0 then
       local q = next_node(p)
-      if q and node_type(q.id)=='penalty' then
+      if q and q.id==id_penalty then
         q.penalty=q.penalty+e
         return false
       else 
-        q=node_new(node.id('penalty'))
+        q=node_new(id_penalty)
         q.penalty=e
         node_insert_after(head,p,q)
         return true
@@ -308,19 +327,47 @@ local function add_kinsoku_penalty(head,p)
    end
 end
 
--- Insert jfm glue: main routine
+local function insert_widow_penalty(head,jq)
+   if not jq then 
+      return head 
+   end
+   local p = node.prev(jq)
+   local jwp=tex.getcount('jcharwidowpenalty')
+   if p and has_attr(p,attr_icflag)==2 then
+      jq=p -- the case where jq has the non-zero \prebreakpenalty.
+   end
+   if jq.id==id_penalty then
+      jq.penalty=jq.penalty + jwp
+      return head
+   else
+      local g = node.new(id_penalty)
+      g.penalty=jwp
+      return node_insert_before(head,jq,g)
+   end
+end
 
-local function insert_jfm_glue(head)
+local depth=""
+
+-- Insert jfm glue: main routine
+-- mode = true iff insert_jfm_glue is called from pre_linebreak_filter
+local function insert_jfm_glue(head, mode)
    local p = head
    local q = nil  -- the previous node of p
+   local jq = nil -- 最後の「句読点扱いでない」和文文字
    local g
    local ihb_flag = false
-   local inserted_after_penalty = false
-   if not p then 
-      return head 
+   local pn = nil
+   if not p then return head 
+   elseif mode then
+      while p and  parindent_box(p) do p=next_node(p) end
+      pn=node.tail(head)
+      if pn and pn.id==id_glue and pn.subtype==15 then
+        pn=node.prev(pn)
+        while (pn and pn.id==id_penalty) do pn=node.prev(pn) end
+      end
+      if pn then pn=next_node(pn) end
    end
-   while p and  ltj.is_parindent_box(p) do p=next_node(p) end
-   while p do
+   while p~=pn do
       if p.id==id_whatsit and p.subtype==node.subtype('user_defined')
          and p.user_id==30111 then
         g=p; p=next_node(p); 
@@ -333,15 +380,14 @@ local function insert_jfm_glue(head)
            -- If p is the first node (=head), the skip is inserted
            -- before head. So we must change head.
         end
-        --if is_japanese_glyph_node(q) then
-        --   node.insert(q, inserted_after_penalty)
-        --end
         q=p; ihb_flag=false; 
-        if is_japanese_glyph_node(p) 
-            and add_kinsoku_penalty(head,p) then
-           p=next_node(p); inserted_after_penalty = true
-        else 
-           inserted_after_penalty = false
+        if is_japanese_glyph_node(p) then
+           if get_penalty_table('kcat',p.char)%2~=1 then
+              jq=p
+           end
+           if add_kinsoku_penalty(head,p) then
+              p=next_node(p)
+           end
         end
         p=next_node(p)
       end
@@ -349,6 +395,11 @@ local function insert_jfm_glue(head)
    -- Insert skip after the last node
    g=calc_between_two_jchar(q,nil)
    if g then h = node_insert_after(head,q,g) end
+
+   if mode then
+      -- Insert \jcharwidowpenalty
+      head = insert_widow_penalty(head,jq)
+   end
    return head
 end
 
@@ -518,7 +569,7 @@ local function insks_around_penalty(head,q,p)
    if r  and r.id==id_glyph then
       if is_japanese_glyph_node(r) then
         cx=r.char
-        if is_japanese_glyph_node(p)  then
+        if is_japanese_glyph_node(q)  then
            local g = node_new(id_glue)
            g.subtype=0; g.spec=node.copy(kanji_skip)
            node_insert_before(head,r,g)
@@ -539,7 +590,7 @@ end
 -- Insert \xkanjiskip around p, a kern
 local function insks_around_kern(head,q,p)
    if p.subtype==1 then -- \kern or \/
-      if not has_attr(p,luatexbase.attributes['luatexja@icflag']) then
+      if not has_attr(p,attr_icflag) then
         insert_skip=no_skip
       end
    elseif p.subtype==2 then -- \accent: We ignore the accent character.
@@ -680,9 +731,10 @@ local function set_ja_width(head)
 end
 
 -- main process
-local function main_process(head)
+-- mode = true iff main_process is called from pre_linebreak_filter
+local function main_process(head, mode)
    local p = head
-   p = insert_jfm_glue(p)
+   p = insert_jfm_glue(p,mode)
    p = insert_kanji_skip(p)
    p = baselineshift(p)
    p = set_ja_width(p)
@@ -690,7 +742,6 @@ local function main_process(head)
 end
 
 -- debug
-local depth=""
 function ltj.show_node_list(head)
    local p =head; local k = depth
    depth=depth .. '.'
@@ -708,8 +759,10 @@ function ltj.show_node_list(head)
         print(depth .. ' whatsit', p.subtype)
       elseif pt == 'glue' then
         print(depth .. ' glue', p.subtype, print_spec(p.spec))
+      elseif pt == 'penalty' then
+        print(depth .. ' penalty', p.penalty)
       else
-        print(depth .. ' ' .. s, s.subtype)
+        print(depth .. ' ' .. node.type(p.id), p.subtype)
       end
       p=next_node(p)
    end
@@ -766,11 +819,11 @@ luatexbase.add_to_callback('process_input_buffer',
 
 luatexbase.add_to_callback('pre_linebreak_filter', 
    function (head,groupcode)
-     return main_process(head)
+     return main_process(head, true)
    end,'ltj.pre_linebreak_filter',2)
 luatexbase.add_to_callback('hpack_filter', 
   function (head,groupcode,size,packtype)
-     return main_process(head)
+     return main_process(head, false)
   end,'ltj.hpack_filter',2)
 
 --insert before callbacks from luaotfload
index 9bd8c7e..1c1880a 100644 (file)
@@ -11,6 +11,7 @@
 
 \newcount\luatexja@tempcnta
 \newcount\luatexja@tempcntb
+\newcount\luatexja@tempcntc
 \newdimen\luatexja@tempdima
 
 \newcount\luatexja@autospc
 \newluatexattribute\luatexja@ykblshift % attribute for \ykbaselineshift
 \newluatexattribute\luatexja@icflag    % attribute for italic correction
 \newlanguage\luatexja@japanese
-\expandafter\newluatexattribute\csname luatexja@kcat0\endcsname
-\expandafter\newluatexattribute\csname luatexja@kcat1\endcsname
-\expandafter\newluatexattribute\csname luatexja@kcat2\endcsname
-\expandafter\newluatexattribute\csname luatexja@kcat3\endcsname
-\expandafter\newluatexattribute\csname luatexja@kcat4\endcsname
-\csname luatexja@kcat0\endcsname='0
-\csname luatexja@kcat1\endcsname='0
-\csname luatexja@kcat2\endcsname=0
-\csname luatexja@kcat3\endcsname=0
-\csname luatexja@kcat4\endcsname=0
 
 %%%%%%%% Loading lua files
 \directlua{%
   end
   require('lualibs')
   ltj.loadlua('luatexja-rmlgbm.lua') 
-    % This file must be read before luatexja-jfont.lua. For Ryumin-Light and GothicBBB-Medium.
+    % For Ryumin-Light and GothicBBB-Medium.
   ltj.loadlua('luatexja-core.lua')
   ltj.loadlua('luatexja-jfont.lua')
   ltj.loadlua('luatexja-core-aux.lua')
   ltj.ja_lang_number=\the\luatexja@japanese
 }
 
+
+%%%%%%%% Attributes for character ranges
+\luatexja@tempcnta=0
+\loop\ifnum\luatexja@tempcnta<7
+  \expandafter\newluatexattribute%
+    \csname luatexja@kcat\the\luatexja@tempcnta\endcsname
+  \csname luatexja@kcat\the\luatexja@tempcnta\endcsname=0
+  \advance\luatexja@tempcnta by1
+\repeat
+
 %%%%%%%% \asluastring
 \def\asluastring#1{'\luaescapestring{\detokenize{#1}}'}
 
@@ -77,8 +78,7 @@
 
 %%%%%%%% \defcharrange<name>{100-200,3000-,5000,...}
 \def\defcharrange#1#2{%
-  \def\ltj@nametemp{#1}\expandafter\ltj@dcrange#2,,\relax
-  \ltj@defcrkey{#1}\relax}
+  \ltj@tempcntc=#1 \expandafter\ltj@dcrange#2,,\ignorespaces}
 \def\ltj@dcrange#1,{\def\ltj@temp{#1}%
   \ifx\ltj@temp\empty\let\@next=\relax\else
   \ltj@@dcrange{#1}\let\@next=\ltj@dcrange\fi\@next}
@@ -92,8 +92,8 @@
     \def\ltj@temp{#2}%
     \ifx\ltj@temp\empty\luatexja@tempcntb="10FFFF \else\luatexja@tempcntb=#2 \fi%"
   \fi
-  \directlua{ltj.def_jchar_range(\the\luatexja@tempcnta,\the\luatexja@tempcntb,
-    '\ltj@nametemp')}%
+  \directlua{ltj.def_char_range(\the\luatexja@tempcnta,\the\luatexja@tempcntb,
+    \the\luatexja@tempcntc)}%
   }
 
 %%%%%%%% \setjaparameter
 \ltj@group@level@pbp=0 \ltj@stack@pbp=0
 
 % prebreakpenalty = {<char_code>, <penalty>}
+\define@key[ltj]{japaram}{kcatcode}{%
+  \expandafter\luatexja@setbp#1:{kcat}{0}{0x7FFFFFFF}}
 \define@key[ltj]{japaram}{prebreakpenalty}{%
-  \expandafter\luatexja@setbp#1:{pre}}
+  \expandafter\luatexja@setbp#1:{pre}{-10000}{10000}}
 \define@key[ltj]{japaram}{postbreakpenalty}{%
-  \expandafter\luatexja@setbp#1:{post}}
-\def\luatexja@setbp#1,#2:#3{
+  \expandafter\luatexja@setbp#1:{post}{-10000}{10000}}
+\def\luatexja@setbp#1,#2:#3#4#5{
   \luatexja@tempcnta=#1\relax
   \luatexja@tempcntb=#2\relax
   \directlua{ltj.set_ch_table(ltj.isglobal, \asluastring{#3},
-    tex.getcount('luatexja@tempcnta'),tex.getcount('luatexja@tempcntb'))}}
+    tex.getcount('luatexja@tempcnta'),tex.getcount('luatexja@tempcntb'),#4,#5)}}
 
 % yabaselineshift = <dimen>
 \define@key[ltj]{japaram}{yabaselineshift}{%
   \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
   \luatexja@tempcnta=#1\relax\luatexja@tempcntb=\ltj@temp\relax
   \directlua{ltj.set_ch_table(ltj.isglobal, 'xsp', tex.getcount('luatexja@tempcnta'),
-    tex.getcount('luatexja@tempcntb'))}}
+    tex.getcount('luatexja@tempcntb'),0,3)}}
 
 % asciixspmode = {<char_code>, <mode>}
 % mode: inhibit, preonly, postonly, allow
   \def\ltj@tempa{allow}\ifx\ltj@temp\ltj@tempa\def\ltj@temp{3}\fi
   \luatexja@tempcnta=#1\relax\luatexja@tempcntb=\ltj@temp\relax
   \directlua{ltj.set_ch_table(ltj.isglobal, 'xsp', tex.getcount('luatexja@tempcnta'),
-    tex.getcount('luatexja@tempcntb'))}}
+    tex.getcount('luatexja@tempcntb'),0,3)}}
 
 % autospacing = <bool> (default: true)
 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
   % large, small, average, both
 
 
-% jcharrange = { <range_name> = { kanji | kana | letter | punct | noncjk} }
-\def\ltj@defcrkey#1{\message{(#1)}\define@choicekey*+[ltj]{charrange}{#1}[\ltj@temp\ltj@result]%
-  {kanji,kana,letter,punct,noncjk}{%
-  \directlua{ltj.set_jchar_range(ltj.isglobal, '#1',\ltj@result)}}\relax}
-\define@key[ltj]{japaram}{jcharrange}{\setkeys[ltj]{charrange}{#1}}
+% jcharrange = { +-<range_number> }
+\define@key[ltj]{japaram}{jcharrange}{\expandafter\@setjcharrange#1,,}
+\def\@setjcharrange#1,{%
+  \edef\ltj@temp{#1}%
+  \ifx\ltj@temp\empty\let\next=\relax\else\let\next=\@setjcharrange
+    \luatexja@tempcnta=#1 \directlua{ltj.set_jchar_range(%
+      ltj.is_global,tex.getcount('luatexja@tempcnta'))}%
+  \fi\next
+}
+
+
+
+
 
 \def\setjaparameter#1{\directlua{ltj.isglobal=''}%
-  \setkeys[ltj]{japaram}{#1}}
+  \setkeys[ltj]{japaram}{#1}\ignorespaces}
 \def\globalsetjaparameter#1{\directlua{ltj.isglobal='global'}%
-  \setkeys[ltj]{japaram}{#1}}
+  \setkeys[ltj]{japaram}{#1}\ignorespaces}
 
 %%%%%%%% 
 \def\getjaparameter#1{%
   \def\ltj@tempa{postbreakpenalty}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
   \def\ltj@tempa{cjkxspmode}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
   \def\ltj@tempa{asciixspmode}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
+  \def\ltj@tempa{kcatcode}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
+  \def\ltj@tempa{jcharrange}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
+  \def\ltj@tempa{chartorange}\ifx\ltj@temp\ltj@tempa\let\@next=\getjaparameter@two\fi
   \@next
 }
 \def\getjaparameter@one{\directlua{ltj.out_ja_parameter_one('\ltj@temp')}}
 \def\getjaparameter@two#1{%
   \luatexja@tempcnta=#1
-  \directlua{ltj.out_ja_parameter_two('\ltj@temp', tex.getcount('luatexja@tempcnta'))}%
+  \directlua{ltj.out_ja_parameter_two('\ltj@temp', tex.getcount('luatexja@tempcnta'))}
 }
 
 
index d247da6..a92c85e 100644 (file)
@@ -106,6 +106,8 @@ function ltj.jfontdefY() -- for horizontal font
      ltj.error("bad JFM '" .. jfmfname .. "'",
                {[1]='The JFM file you specified is not valid JFM file.',
                 [2]='Defining Japanese font is cancelled.'})
+     tex.sprint(ltj.is_global .. '\\expandafter\\let\\csname '
+               .. ltj.cstemp .. '\\endcsname=\\relax')
      return 
    end
    ltj.font_metric_table[fn]={}
@@ -156,107 +158,69 @@ end
 
 
 --====== Range of Japanese characters.
-local threshold = 0x100 -- must be >=0x100
--- below threshold: kcat_table_main[chr_code] = index
--- above threshold: kcat_table_range = 
---   { [1] = {b_1, b_2, ...},
---     [2] = {i_1, i_2, ...} }
--- ( Characters b_i<=chr_code <b_{i+1} have the index i_i )
--- kcat_table_index = index1, index2, ...
+-- jcr_table_main[chr_code] = index
+-- index : internal 0, 1, 2, ..., 216               0: 'other'
+--         external    1  2       216, (out of range): 'other'
 
--- init
+-- init
 local ucs_out = 0x110000
-local kcat_table_main = {}
-kcat_table_range = { [1] = {threshold,ucs_out}, [2] = {0,-1} }
-kcat_table_index = { [0] = 'other' ,
-                          [1] = 'iso8859-1'}
-
-local kc_kanji = 0
-local kc_kana = 1
-local kc_letter = 2
-local kc_punct = 3
-local kc_noncjk = 4
+local jcr_table_main = {}
+local jcr_cjk = 0
+local jcr_noncjk = 1
 
 for i=0x80,0xFF do
-   kcat_table_main[i]=1
-end
-for i=0x100,threshold-1 do
-   kcat_table_main[i]=0
+   jcr_table_main[i]=1
 end
-
-local function add_jchar_range(b,e,ind)
-   -- We assume that e>=b
-   if b<threshold then
-      for i=math.max(0x80,b),math.min(threshold-1,e) do
-        kcat_table_main[i]=ind
-      end
-      if e<threshold then return true else b=threshold end
-   end
-   local insp
-   for i,v in ipairs(kcat_table_range[1]) do
-      if v>e then 
-        insp = i-1; break
-      end
-   end
-   if kcat_table_range[1][insp]>b or kcat_table_range[2][insp]>1 then
-      ltj.error("Bad character range",{}); return nil -- error
-   end
-   if kcat_table_range[1][insp]<b  then 
-   -- now [insp]¢« <b .. b .. [insp+1]¢« >e
-      table.insert(kcat_table_range[1],insp+1,b)
-      table.insert(kcat_table_range[2], insp+1, kcat_table_range[2][insp])
-      insp=insp+1
-   end
-   -- [insp]¢« =b .. e .. [insp+1]¢« >e
-   table.insert(kcat_table_range[1], insp+1,e+1)
-   table.insert(kcat_table_range[2], insp+1, kcat_table_range[2][insp])
-   kcat_table_range[2][insp]=ind
+for i=0x100,ucs_out-1 do
+   jcr_table_main[i]=0
 end
 
-function ltj.def_jchar_range(b,e,name) 
-   local ind = #kcat_table_index+1
-   for i,v in pairs(kcat_table_index) do
-      if v==name then ind=i; break  end
-   end
-   if ind>=50 then 
-      ltj.error("No room for new character range",{}); return -- error
+function ltj.def_char_range(b,e,ind) -- ind: external range number
+   if ind<0 or ind>216 then 
+      ltj.error('Invalid range number (' .. ind .. '), should be in the range 1..216.',
+               {}); return
    end
-   if ind == #kcat_table_index+1 then
-      table.insert(kcat_table_index, name)
-      print('New char range: ' .. name, ind) 
+   for i=math.max(0x80,b),math.min(ucs_out-1,e) do
+      jcr_table_main[i]=ind
    end
-   add_jchar_range(b,e,ind)
 end
 
-local function get_char_kcatcode(p)
+local function get_char_jcrcode(p) -- for internal use
    local i
    local c = p.char
-   if c<0x80 then return kc_noncjk
-   elseif c<threshold then i=kcat_table_main[c] 
-   else
-      for j,v in ipairs(kcat_table_range[1]) do
-        if v>c then 
-           i = kcat_table_range[2][j-1]; break
-        end
-      end
-   end
+   if c<0x80 then return jcr_noncjk else i=jcr_table_main[c] end
    return math.floor(has_attr(p,
-         luatexbase.attributes['luatexja@kcat'..math.floor(i/10)])
-         /math.pow(8, i%10))%8
+         luatexbase.attributes['luatexja@kcat'..math.floor(i/31)])
+         /math.pow(2, i%31))%2
+end
+
+function ltj.get_char_jcrnumber(c) -- return the (external) range number
+   if c<0x80 or c>=ucs_out then return -1
+   else 
+      local i = jcr_table_main[c] or 0
+      if i==0 then return 217 else return i end
+   end
+end
+
+function ltj.get_jcr_setting(i) -- i: internal range number
+   return math.floor(tex.getattribute(luatexbase.attributes['luatexja@kcat'..math.floor(i/31)])
+         /math.pow(2, i%31))%2
 end
 
 --  ÏÂʸʸ»ú¤Èǧ¼±¤¹¤ë unicode ¤ÎÈÏ°Ï
 function ltj.is_ucs_in_japanese_char(p)
-   return (get_char_kcatcode(p)~=kc_noncjk) 
+   return (get_char_jcrcode(p)~=jcr_noncjk) 
 end
 
-function ltj.set_jchar_range(g, name,kc)
-   local ind = 0
-   for i,v in pairs(kcat_table_index) do
-      if v==name then ind=i; break  end
+function ltj.set_jchar_range(g, i) -- i: external range number
+   if i==0 then return 
+   else
+      local kc
+      if i>0 then kc=0 else kc=1; i=-i end
+      if i>216 then i=0 end
+      local attr = luatexbase.attributes['luatexja@kcat'..math.floor(i/31)]
+      local a = tex.getattribute(attr)
+      local k = math.pow(2, i%31)
+      tex.setattribute(g,attr,(math.floor(a/k/2)*2+kc)*k+a%k)
    end
-   local attr = luatexbase.attributes['luatexja@kcat'..math.floor(ind/10)]
-   local a = tex.getattribute(attr)
-   local k = math.pow(8, ind%10)
-   tex.setattribute(g,attr,(math.floor(a/k/8)*8+kc)*k+a%k)
 end
\ No newline at end of file
index 5ac503d..47ab680 100644 (file)
 \let\mc=\tenmin
 \let\gt=\tengt
 \mc
-\catcode`\@=11\ltj@defcrkey{other} \ltj@defcrkey{iso8859-1}\catcode`\@=12
-\setjaparameter{jcharrange={iso8859-1=noncjk}}
 \setjaparameter{kanjiskip=0pt plus 0.4pt minus 0.4pt, 
   xkanjiskip=.25\zw plus 1pt minus 1pt,
-  autospacing, autoxspacing,
+  autospacing, autoxspacing, jcharrange={-1}, 
   yabaselineshift=0pt, ykbaselineshift=0pt,
   jcharwidowpenalty=500, differentjfm=average
 }
 
 \input luatexja-kinsoku.tex
 
+\luatexja@tempcnta="2000%"
+\loop\ifnum\luatexja@tempcnta<"2070%"
+  \setjaparameter{kcatcode={\luatexja@tempcnta,1}}%
+  \advance\luatexja@tempcnta by1
+\repeat
+
+\luatexja@tempcnta="3000%"
+\loop\ifnum\luatexja@tempcnta<"3040%"
+  \setjaparameter{kcatcode={\luatexja@tempcnta,1}}%
+  \advance\luatexja@tempcnta by1
+\repeat
+
+\luatexja@tempcnta="FF00%"
+\loop\ifnum\luatexja@tempcnta<"FFF0%"
+  \setjaparameter{kcatcode={\luatexja@tempcnta,1}}%
+  \advance\luatexja@tempcnta by1
+\repeat
 \endinput
\ No newline at end of file
index 8c41c84..a59372c 100644 (file)
Binary files a/test/test03-after.pdf and b/test/test03-after.pdf differ
index 6e2231b..f552683 100644 (file)
@@ -3,6 +3,8 @@
 \def\\{\hfill\break}
 \tentt\tenmin
 
+{\tengt ■パラメタ代入テスト}
+
 \catcode`\@=11
 \the\luatexja@ykblshift
 \setjaparameter{ykbaselineshift=\maxdimen,autoxspacing=false}
 \getjaparameter{ykbaselineshift}
 
 \getjaparameter{kanjiskip},
-\getjaparameter{xkanjiskip},
+\getjaparameter{xkanjiskip}
+
 \getjaparameter{autospacing},
-\getjaparameter{autoxspacing},
+\getjaparameter{autoxspacing}
+
 \getjaparameter{differentjfm}.
 \setjaparameter{ykbaselineshift=0pt,autoxspacing=true}
 
 
-あいうえお{\setjaparameter{ykbaselineshift=2pt}かきくけこ}さしすせそ
+あいうえお{\setjaparameter{ykbaselineshift=2pt}かきくけこ}さしすせそ: local
 
-あいうえお{\globalsetjaparameter{ykbaselineshift=2pt}かきくけこ}さしすせそ
+あいうえお{\globalsetjaparameter{ykbaselineshift=2pt}かきくけこ}さしすせそ: global
 
 \getjaparameter{prebreakpenalty}{`(},
 \getjaparameter{prebreakpenalty}{`)},
@@ -32,6 +36,9 @@
 
 a\inhibitglue (a)\inhibitglue aあa〜a
 
+\medskip
+xspmode
+
 \getjaparameter{cjkxspmode}{`(},
 \getjaparameter{cjkxspmode}{`)},
 \getjaparameter{cjkxspmode}{`あ},
@@ -48,6 +55,9 @@ a\inhibitglue (a)\inhibitglue aあa〜a
 {\setjaparameter{kanjiskip=0pt plus 1fi minus 1fil}\getjaparameter{kanjiskip}\par}
 {x\setjaparameter{kanjiskip=0pt plus 1fill minus 1filll}\getjaparameter{kanjiskip}\par}
 
+\medskip
+{\tengt ■合字テスト}
+
 \tenrm
 {\setjaparameter{asciixspmode={`i,preonly},ykbaselineshift=0pt}
 あiあfiあffiあ\par}
@@ -55,6 +65,6 @@ a\inhibitglue (a)\inhibitglue aあa〜a
 {\setjaparameter{asciixspmode={`f,postonly},ykbaselineshift=0pt}
 あfあfiあffiあ\par}
 
-\setjaparameter{asciixspmode={-1,inhibit}}
+\setjaparameter{asciixspmode={0,inhibit}}
 あ$a$あ
 \end
index ce86689..79f69d4 100644 (file)
@@ -1,4 +1,4 @@
-This is LuaTeX, Version beta-0.66.0-2011032121 (rev 4093)  (format=luatex 2011.3.21)  19 APR 2011 21:02
+This is LuaTeX, Version beta-0.66.0-2011032121 (rev 4093)  (format=luatex 2011.4.20)  23 APR 2011 12:44
  restricted \write18 enabled.
 **test04-jfm.tex
 (./test04-jfm.tex
@@ -170,18 +170,27 @@ Package: infwarerr 2010/04/08 v1.3 Providing info/warning/message (HO)
 )
 \luatexja@tempcnta=\count281
 \luatexja@tempcntb=\count282
+\luatexja@tempcntc=\count283
 \luatexja@tempdima=\dimen256
-\luatexja@autospc=\count283
-\luatexja@autoxspc=\count284
-\jcharwidowpenalty=\count285
+\luatexja@autospc=\count284
+\luatexja@autoxspc=\count285
+\jcharwidowpenalty=\count286
 \kanjiskip=\skip256
 \xkanjiskip=\skip257
 \zw=\dimen257
 \zh=\dimen258
 \jQ=\dimen259
 \jH=\dimen260
+\luatexja@curjfnt=\luatexattribute9
+\luatexja@charclass=\luatexattribute10
+\luatexja@yablshift=\luatexattribute11
+\luatexja@ykblshift=\luatexattribute12
+\luatexja@icflag=\luatexattribute13
+\luatexja@japanese=\language87
 
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-rmlgbm.lua)
+(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-rmlgbm-data.lu
+a)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-core.lua)
 Module luatexbase-mcb info: inserting 'ltj.process_input_buffer'
 (luatexbase-mcb)            at position 1 in 'process_input_buffer'
@@ -195,32 +204,23 @@ Module luatexbase-mcb info: inserting 'ltj.hyphenate'
 (luatexbase-mcb)            at position 1 in 'hyphenate'
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-jfont.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-core-aux.lua)
-\luatexja@curjfnt=\luatexattribute9
-\luatexja@charclass=\luatexattribute10
-\luatexja@yablshift=\luatexattribute11
-\luatexja@ykblshift=\luatexattribute12
-\luatexja@icflag=\luatexattribute13
-\luatexja@japanese=\language87
-\ltj@stack@pbp=\count286
-\ltj@group@level@pbp=\count287
+\luatexja@kcat0=\luatexattribute14
+\luatexja@kcat1=\luatexattribute15
+\luatexja@kcat2=\luatexattribute16
+\luatexja@kcat3=\luatexattribute17
+\luatexja@kcat4=\luatexattribute18
+\luatexja@kcat5=\luatexattribute19
+\luatexja@kcat6=\luatexattribute20
+\ltj@stack@pbp=\count287
+\ltj@group@level@pbp=\count288
 
 plain format: loading luatexja-plain.tex
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-plain.tex
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-rmlgbm-data.lu
-a)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
 (/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/luatexja-kinsoku.tex)))
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)(load: /ho
-me/h7k/.texlive2010/texmf-var/luatex-cache/generic/fonts/otf/temp-ipam.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)(load: /ho
-me/h7k/.texlive2010/texmf-var/luatex-cache/generic/fonts/otf/temp-kozminpr6n-re
-gular.lua)
-(/opt/texlive/p2010/../texmf-local/tex/generic/luatexja/jfm-ujis.lua)
+(load: /home/h7k/.texlive2010/texmf-var/luatex-cache/generic/fonts/otf/temp-ipa
+m.lua)(load: /home/h7k/.texlive2010/texmf-var/luatex-cache/generic/fonts/otf/te
+mp-kozminpr6n-regular.lua)
 (./jfm-bad.lua)
 ! LuaTeX-ja error: bad JFM 'bad'.
 \@jfont ->\directlua {ltj.jfontdefY()}
@@ -228,11 +228,31 @@ gular.lua)
 <to be read again> 
                    \rml 
 l.15 \rml
-          あ󿿿
-? h
+          あ123 % \rml は未定義となる󿿿
 The JFM file you specified is not valid JFM file.
 Defining Japanese font is cancelled.
-? 
+
+(load: /home/h7k/.texlive2010/texmf-var/luatex-cache/generic/fonts/otf/temp-ipa
+exg.lua)
+! Undefined control sequence.
+\defcharrange #1#2->\ltj@tempcntc 
+                                  =#1 \expandafter \ltj@dcrange #2,,\ignores...
+l.25 \defcharrange{2}{`あ,"E0-"FF}
+                                   
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+
+! LuaTeX-ja error: Invalid character code (-1), should in the range 0.."10FFFF.
+.
+\@next ...p ', tex.getcount('luatexja@tempcnta'))}
+                                                   
+l.46 \getjaparameter{chartorange}{-1}
+                                       % must be -1
+I'm going to use 0 instead of that illegal character code.
+
 [1{/opt/texlive/p2010/texmf-var/fonts/map/pdftex/updmap/pdftex.map
 LuaTeX warning (file /opt/texlive/p2010/texmf-var/fonts/map/pdftex/updmap/pdfte
 x.map): fontmap entry for `bchb8r' already exists, duplicates ignored
@@ -251,12 +271,13 @@ x.map): fontmap entry for `bchri8r' already exists, duplicates ignored
 
 LuaTeX warning (file /opt/texlive/p2010/texmf-var/fonts/map/pdftex/updmap/pdfte
 x.map): fontmap entry for `bchro8r' already exists, duplicates ignored
-}] )</opt/texlive/p2010/texmf/fonts/opentype/test/kozuka/KozMinPr6N-Regular.otf
-></opt/texlive/p2010/texmf/fonts/truetype/test/ipam.ttf></opt/texlive/p2010/tex
-mf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
-Output written on test04-jfm.pdf (1 page, 163518 bytes).
-PDF statistics: 31 PDF objects out of 1000 (max. 8388607)
- 19 compressed objects within 1 object stream
+}] )</opt/texlive/p2010/texmf/fonts/truetype/test/ipaexg.ttf></opt/texlive/p201
+0/texmf/fonts/opentype/test/kozuka/KozMinPr6N-Regular.otf></opt/texlive/p2010/t
+exmf/fonts/truetype/test/ipam.ttf></opt/texlive/p2010/texmf-dist/fonts/type1/pu
+blic/amsfonts/cm/cmr10.pfb>
+Output written on test04-jfm.pdf (1 page, 283021 bytes).
+PDF statistics: 43 PDF objects out of 1000 (max. 8388607)
+ 27 compressed objects within 1 object stream
  0 named destinations out of 1000 (max. 131072)
  1 words of extra memory for PDF output out of 10000 (max. 10000000)
 
index a41a10b..2060e17 100644 (file)
Binary files a/test/test04-jfm.pdf and b/test/test04-jfm.pdf differ
index 3cee8e6..6c0ae11 100644 (file)
 \rml あ\inhibitglue\char"201Cあ←KozMinPr6N-Regular
 
 \scrollmode
-\jfont\rml={psft:GothicBBB-Medium:jfm=bad} at 10pt
-\rml あ
+\jfont\rml={psft:GothicBBB-Medium:jfm=bad} at 10pt % must be error
+\rml あ123 % \rml は未定義となる
+
+\bigskip
+\font\rml={file:ipaexg.ttf} at 10pt\rml
+
+ここからは,欧文文字フォントはIPA EXゴシック
+
+
+\medskip{\tengt 文字範囲の代入/取得テスト}
+
+\defcharrange{2}{`あ,"E0-"FF}
+「\char"F4」は2番の文字範囲なので,和文扱いのはず
+
+{iso8859-1 和文扱い:\setjaparameter{jcharrange={1}}%
+\getjaparameter{jcharrange}{1}%
+§ ¶ ° £ ¥ \char"F4}
+
+{iso8859-1 欧文扱い:\setjaparameter{jcharrange={-1}}%
+\getjaparameter{jcharrange}{1}%
+§ ¶ ° £ ¥ \char"F4}
+
+
+\medskip{\tengt 文字範囲の状況取得}
+\getjaparameter{jcharrange}{0}
+\getjaparameter{jcharrange}{1}
+\getjaparameter{jcharrange}{2}
+
+\medskip{\tengt 文字コード→文字範囲}
+\getjaparameter{chartorange}{`い} % must be 217
+\getjaparameter{chartorange}{`§} % must be 1
+\getjaparameter{chartorange}{"F7} % must be 2
+\getjaparameter{chartorange}{-1}  % must be -1
+
+\medskip
+\setjaparameter{jcharrange={-217}}
+ほとんど欧文扱い.2番は別(「あ」)
+\setjaparameter{jcharrange={218}}
+和文扱いにもどる
 \end