OSDN Git Service

ltj-jfont.lua: check 'luaotfload.letterspace' position at \jfont
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 6 Sep 2020 06:12:07 +0000 (15:12 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 6 Sep 2020 06:12:07 +0000 (15:12 +0900)
src/ltj-jfont.lua
test/test33-jfm_feature.pdf
test/test33-jfm_feature.tex

index 7999af2..d400599 100644 (file)
@@ -279,7 +279,7 @@ end
 -- LOADING JAPANESE FONTS
 ------------------------------------------------------------------------
 
-local load_jfont_metric
+local load_jfont_metric, check_callback_order
 do
    local cstemp
    local global_flag -- true if \globaljfont, false if \jfont
@@ -328,7 +328,7 @@ do
          return
       end
       if not f then return end
-      update_jfm_cache(j, f.size)
+      update_jfm_cache(j, f.size); check_callback_order()
       local sz = metrics[j].size_cache[f.size]
       local fmtable = { jfm = j, size = f.size, var = jfm_var,
                         with_kanjiskip = jfm_ksp,
@@ -352,6 +352,25 @@ do
 end
 
 do
+    local ltb = luatexbase
+    local to_be_checked = { 'pre_linebreak_filter', 'hpack_filter' }
+    check_callback_order = function()
+        for i,n in pairs(to_be_checked) do
+            local lotf_cb = ltb.priority_in_callback(n, 'luaotfload.letterspace')
+            local ltj_cb  = ltb.priority_in_callback(n, 'ltj.main')
+            if lotf_cb then
+                to_be_checked[i]=nil
+                if ltj_cb<lotf_cb then
+                    local f = ltb.remove_from_callback(n,'luaotfload.letterspace')
+                    ltb.add_to_callback(n, f, 'luaotfload.letterspace', 
+                        ltb.priority_in_callback(n, 'luaotfload.node_processor') + 1)
+                end
+            end
+        end
+    end
+end
+
+do
    local get_dir_count = ltjd.get_dir_count
    local dir_tate = luatexja.dir_table.dir_tate
    local tex_get_attr = tex.getattribute
@@ -387,7 +406,7 @@ do
     local jf_feature_list   = P'{' * jf_feature_expr^0 * P'}' + jf_feature_expr^0
     local jf_list           = C((1-slash)^1) * (slash * Cf(Ct'' * jf_feature_list, rawset))^-1
     local jf_value          = (1 - semicolon)^1
-    local function rem(name,value,sep)
+    local function rem(name,value)
       if name=='jfm' then
         local flag, t; jfm_name, t = lpegmatch(jf_list, value)
         if type(t)=='table' then
@@ -401,7 +420,7 @@ do
       return ''
     end
     local jf_remainder      = Cs( ( ( B(S':;') *
-      C(P'jfm' * P'var'^-1) * ws * equals * ws * C(jf_value) * C(semicolon^-1) ) / rem +1 )^0 )
+      C(P'jfm' * P'var'^-1) * ws * equals * ws * C(jf_value) * semicolon^-1 ) / rem +1 )^0 )
 
    local parser=luaotfload.parsers.font_request
    function is_feature_specified(s,fname)
index ea12a1f..040a60a 100644 (file)
Binary files a/test/test33-jfm_feature.pdf and b/test/test33-jfm_feature.pdf differ
index e91cf39..1f2a647 100644 (file)
@@ -1,19 +1,48 @@
 %#!luatex
-\input luatexja.sty
+\input lua-visual-debug.sty
+\input luatexja-otf.sty
 \catcode`\@=11
 \jfont \testA=\ltj@stdmcfont:jfm=ujis/hoge,piyo at 9.62216pt
 \jfont \testB=\ltj@stdmcfont:jfm=ujis/{piyo,,,,,+hoge,,,,};jp90 at 9.62216pt
 \jfont \testC=\ltj@stdgtfont:jfm=ujis/,,,,;+jp90 at 9.62216pt
 %\jfont \testD=\ltj@stdgtfont:jfm=/abcd;+trad at 9.62216pt % error
 \jfont \testE=\ltj@stdmcfont:jfm=ujis/piyo,hoge=2,+foo,-bar,mog=6,,l=true,g=false;jp90 at 9.62216pt
-\jfont \testE=\ltj@stdmcfont:jp90;jfm=ujis/{-bar,-g,foo,hoge=2,l,mog=6,piyo} at 9.62216pt
+\jfont \testE=\ltj@stdmcfont:jp90;jfm=ujis/{-bar,-g,foo,hoge=2,l,mog=6,piyo};color=6faf5f at 9.62216pt
 
+\def\DISP#1{{\noindent\tentt \string#1: \meaning#1}\par}
 
+\DISP\testA
+\DISP\testB
+\DISP\testC
+\DISP\testD
+\DISP\testE
 
 \ltjsetparameter{differentjfm=both}
-{\testA (あ葛鴎)}{\testB (い葛鴎)}{\testC (う葛鴎)}(え葛鴎){\tengt(あ葛鴎)}\par
+{\testA (あ葛鴎)}{\testB (い葛鴎)}{\testC (う葛鴎)}(え葛鴎){\tengt(あ葛鴎)}{\testE あおうえお}\par
 
 \ltjsetparameter{differentjfm=paverage}
-{\testA (あ葛鴎)}{\testB (い葛鴎)}{\testC (う葛鴎)}(え葛鴎){\tengt(あ葛鴎)}\par
+{\testA (あ葛鴎)}{\testB (い葛鴎)}{\testC (う葛鴎)}(え葛鴎){\tengt(あ葛鴎)}{\testE あおうえお}\par
+
+\medskip
+\hrule
+\medskip
+\font\testOA=lmroman10-regular:letterspace=0.01
+\jfont\testF=\ltj@stdmcfont:jfm=ujis;letterspace=50 at 9.62216pt
+{\testOA \testF
+  A quick brown fox 跳』\inhibitglue (躍)(した:) over the のろ……まな 犬.
+}
+
+\directlua{
+  local ltb = luatexbase
+  print(table.serialize(ltb.callback_descriptions('pre_linebreak_filter')))
+  print(table.serialize(ltb.callback_descriptions('hpack_filter')))
+}
+
+{\testOA \testF
+  A quick brown fox 跳』\inhibitglue (躍)(した:) over the のろ……まな 犬.
+  A quick fox 跳』\inhibitglue (躍)(した:) over the のろ……まな 犬.ああああああ
+
+}
+
 
 \bye