OSDN Git Service

Supprted '(文字)*' syntax in JFM.
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 7 Jul 2012 08:16:36 +0000 (17:16 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 7 Jul 2012 08:16:36 +0000 (17:16 +0900)
 - autospacing and autoxspacing now uses the same attributes.
   (1 bit + 1 bit)
 - some parameters such as prebreakpenalty won't be affected
   by luaotfload's glyph replacement process.

doc/luatexja.dtx
src/jfm-ujis.lua
src/ltj-jfmglue.lua
src/ltj-jfont.lua
src/ltj-pretreat.lua
src/luatexja-core.sty
src/luatexja.lua

index b1ca377..529ecf0 100644 (file)
@@ -2524,7 +2524,7 @@ JFMは「望ましい\Param{kanjiskip}の値」や「望ましい\Param{xkanjisk
 %</zh>
 
 %<en>\subsection{Insertion Setting of \Param{xkanjiskip}}
-%<ja>\subsection{\Param{xkanjiskip} の設定の挿入}
+%<ja>\subsection{\Param{xkanjiskip} の挿入設定}
 %<zh>\subsection{\Param{xkanjiskip}插入设定}
 
 %<*en>
@@ -2603,11 +2603,16 @@ One can use also numbers to specify these two parameters (see Subsection~\ref{ss
 If you want to enable/disable all insertions of \Param{kanjiskip} and
 \Param{xkanjiskip}, set \Param{autospacing} and \Param{autoxspacing}
 parameters to \texttt{true}/\texttt{false}, respectively.
+Note that if you sets one of the parameters 
+\Param{autospacing}~and~\Param{autoxspacing},
+the other parameter also will be set globally.
 %</en>
 %<*ja>
 もし全ての\Param{kanjiskip}と\Param{xkanjiskip}の挿入を有効化/無効化
 したければ,それぞれ\Param{autospacing}と\Param{autoxspacing}を
 \texttt{true}/\texttt{false}に設定すればよい.
+なお,\Param{autospacing}と\Param{autoxspacing}の片方をグローバルに設定した場合,
+他方のパラメタもグローバルに設定されることになる.
 %</ja>
 %<*zh>
 如果你想要启用/屏蔽所有的\Param{kanjiskip}和\Param{xkanjiskip}插入,设定
@@ -4654,18 +4659,10 @@ The amount of shifting the baseline of Japanese fonts in scaled point ($2^{-16}\
 
 \attr{ltj@autospc}
 %<*en>
-Whether the auto insertion of \Param{kanjiskip} is allowed at the node.
+Whether the auto insertion of \Param{kanjiskip} and \Param{xkanjiskip} is allowed at the node.
 %</en>
 %<*ja>
-そのノードで\Param{kanjiskip}の自動挿入が許されるかどうか.
-%</ja>
-
-\attr{ltj@autoxspc}
-%<*en>
-Whether the auto insertion of \Param{xkanjiskip} is allowed at the node.
-%</en>
-%<*ja>
-そのノードで\Param{xkanjiskip}の自動挿入が許されるかどうか.
+そのノードで\Param{kanjiskip}や\Param{xkanjiskip}の自動挿入が許されるかどうか.
 %</ja>
 
 \attr{ltj@icflag}
index 4b984c5..d2cd13b 100644 (file)
@@ -30,7 +30,7 @@ luatexja.jfont.define_jfm {
    [2] = { -- 閉じ括弧類
       chars = {
         '’', '”', '、', '〉', '》', '」', '』', '】', '〕', 
-        '〗', '〙', '〟', ')', ',', ']', '}', '⦆'
+        '〗', '〙', '〟', ')', ',*', ']', '}', '⦆', 
       },
       align = 'left', left = 0.0, down = 0.0,
       width = 0.5, height = 0.88, depth = 0.12, italic=0.0,
index d5f512d..da49723 100644 (file)
@@ -74,7 +74,6 @@ local attr_jchar_class = luatexbase.attributes['ltj@charclass']
 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
 local attr_icflag = luatexbase.attributes['ltj@icflag']
 local attr_autospc = luatexbase.attributes['ltj@autospc']
-local attr_autoxspc = luatexbase.attributes['ltj@autoxspc']
 local attr_uniqid = luatexbase.attributes['ltj@uniqid']
 local max_dimen = 1073741823
 
@@ -434,8 +433,9 @@ end
 -- 和文文字のデータを取得
 function set_np_xspc_jachar(Nx, x)
    local z = ltjf_font_metric_table[x.font]
-   local c = x.char
-   local cls = ltjf_find_char_class(c, z)
+   local c = has_attr(x, attr_jchar_class) or 0
+   local cls = ltjf_find_char_class(x.char, z) or 0
+   if cls==0 then cls = ltjf_find_char_class(-c, z) end
    local m = ltjf_metrics[z.jfm]
    set_attr(x, attr_jchar_class, cls)
    Nx.class = cls
@@ -451,8 +451,9 @@ function set_np_xspc_jachar(Nx, x)
    y = ltjs_get_penalty_table('xsp', c, 3, box_stack_level)
    Nx.xspc_before = (y%2==1)
    Nx.xspc_after  = (y>=2)
-   Nx.auto_kspc = (has_attr(x, attr_autospc)==1)
-   Nx.auto_xspc = (has_attr(x, attr_autoxspc)==1)
+   y = has_attr(x, attr_autospc) or 0
+   Nx.auto_kspc = (y>=2)
+   Nx.auto_xspc = (y%2==1)
 end
 
 -- 欧文文字のデータを取得
@@ -479,7 +480,7 @@ function set_np_xspc_alchar(Nx, c,x, lig)
    local y = ltjs_get_penalty_table('xsp', c, 3, box_stack_level)
    Nx.xspc_before = (y%2==1)
    Nx.xspc_after  = (y>=2)
-   Nx.auto_xspc = (has_attr(x, attr_autoxspc)==1)
+   Nx.auto_xspc = (has_attr(x, attr_autospc)%2==1)
 end
 
 -- Np の情報取得メインルーチン
index 4c6d666..b1245c9 100644 (file)
@@ -56,6 +56,8 @@ function define_jfm(t)
                  real_char = true;
               elseif type(w) == 'string' and utf.len(w)==1 then
                  real_char = true; w = utf.byte(w)
+              elseif type(w) == 'string' and utf.len(w)==2 and utf.sub(w,2) == '*' then
+                 real_char = true; w = -utf.byte(utf.sub(w,1,1))
               end
               if not t.chars[w] then
                  t.chars[w] = i
index deb7516..87cbdd6 100644 (file)
@@ -35,6 +35,9 @@ local attr_ykblshift = luatexbase.attributes['ltj@ykblshift']
 
 local ltjf_font_metric_table = ltjf.font_metric_table
 local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
+local attr_jchar_class = luatexbase.attributes['ltj@charclass']
+local ltjf_find_char_class = ltjf.find_char_class
+
 ------------------------------------------------------------------------
 -- MAIN PROCESS STEP 1: replace fonts
 ------------------------------------------------------------------------
@@ -47,6 +50,7 @@ local function suppress_hyphenate_ja(head)
       if p.id == id_glyph and non_math then
         if (has_attr(p, attr_icflag) or 0)==0 and ltjc_is_ucs_in_japanese_char(p) then
            p.font = has_attr(p, attr_curjfnt) or p.font
+           set_attr(p, attr_jchar_class, p.char)
            set_attr(p, attr_yablshift, has_attr(p, attr_ykblshift) or 0)
            p.subtype = floor(p.subtype/2)*2
         end
index 43308cd..f1baada 100644 (file)
 \newluatexattribute\ltj@yablshift % attribute for \yabaselineshift
 \newluatexattribute\ltj@ykblshift % attribute for \ykbaselineshift
 \newluatexattribute\ltj@autospc   % attribute for autospacing
-\newluatexattribute\ltj@autoxspc  % attribute for autoxspacing
+\ltj@autospc=0
 \newluatexattribute\ltj@icflag    % attribute for italic correction
 
 %%%%%%%% Attributes for character ranges
     \ltj@safe@num@or{nil}{\ltj@temp},0,3)}}
 
 % autospacing = <bool> (default: true)
+%% \numexpr 3/2\relax yields 2, so we use \numexpr (2*3-1)/4\relax to get [3/2].
 \define@boolkey[ltj]{japaram}{autospacing}[true]{%
   \ifltj@japaram@autospacing
-    \directlua{luatexja.ext_print_global()}\ltj@autospc=1
+    \directlua{luatexja.ext_print_global()}\ltj@autospc%
+      =\numexpr\ltj@autospc-((2*\the\ltj@autospc-1)/4)*2+2\relax
   \else
-    \directlua{luatexja.ext_print_global()}\ltj@autospc=0
+    \directlua{luatexja.ext_print_global()}\ltj@autospc%
+      =\numexpr\ltj@autospc-((2*\the\ltj@autospc-1)/4)*2\relax
   \fi}
 
 % autoxspacing = <bool> (default: true)
 \define@boolkey[ltj]{japaram}{autoxspacing}[true]{%
   \ifltj@japaram@autoxspacing
-    \directlua{luatexja.ext_print_global()}\ltj@autoxspc=1
+    \directlua{luatexja.ext_print_global()}\ltj@autospc%
+      =\numexpr((2*\the\ltj@autospc-1)/4)*2+1\relax
   \else
-    \directlua{luatexja.ext_print_global()}\ltj@autoxspc=0
+    \directlua{luatexja.ext_print_global()}\ltj@autospc%
+      =\numexpr((2*\the\ltj@autospc-1)/4)*2\relax
   \fi}
 
 % [x]]kanjiskip = <dimen>
index 4b134d6..02cf1b8 100644 (file)
@@ -151,9 +151,9 @@ function luatexja.ext_get_parameter_unary(k)
    elseif k == 'jcharwidowpenalty' then
       tex.write(ltjs.get_penalty_table('jwp', 0, 0, tex.getcount('ltj@@stack')))
    elseif k == 'autospacing' then
-      tex.write(tex.getattribute('ltj@autospc'))
+      tex.write(math.floor(tex.getattribute('ltj@autospc')/2))
    elseif k == 'autoxspacing' then
-      tex.write(tex.getattribute('ltj@autoxspc'))
+      tex.write(tex.getattribute('ltj@autospc')%2)
    elseif k == 'differentjfm' then
       if luatexja.jfmglue.diffmet_rule == math.max then
         tex.write('large')
@@ -249,7 +249,7 @@ local function debug_show_node_X(p,print_fn)
    local base = debug_depth .. string.format('%X', has_attr(p,attr_icflag) or 0)
    .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
    if pt == 'glyph' then
-      s = base .. ' ' .. utf.char(p.char) .. ' ' .. tostring(p.font)
+      s = base .. ' ' .. utf.char(p.char) .. ' (' .. p.char .. ') ' .. tostring(p.font)
          .. ' (' .. print_scaled(p.height) .. '+' 
          .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
       print_fn(s)