OSDN Git Service

better fix of #47723
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 6 Apr 2023 11:45:04 +0000 (20:45 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 6 Apr 2023 11:45:04 +0000 (20:45 +0900)
src/ltj-jfont.lua
src/luatexja-core.sty
src/patches/lltjfont.sty
test/speed/jfm-test_01.lua [new file with mode: 0644]
test/test02-latex.tex
test/zh/jfm-test_02.lua [new file with mode: 0644]

index 8cb0fa4..26c76d8 100644 (file)
@@ -3,7 +3,7 @@
 --
 luatexbase.provides_module({
   name = 'luatexja.jfont',
-  date = '2023-03-11',
+  date = '2023-04-06',
   description = 'Loader for Japanese fonts',
 })
 
@@ -288,7 +288,7 @@ do
          jfm_name, jfm_spec = 'ujis', 'ujis'
       end
       for j,v in ipairs(metrics) do if v.name==jfm_spec then return j end end
-      luatexja.load_lua('jfm-' .. jfm_name .. '.lua')
+      defjfm_res=nil; luatexja.load_lua('jfm-' .. jfm_name .. '.lua')
       if defjfm_res then
          defjfm_res.name = jfm_spec; table.insert(metrics, defjfm_res)
          return #metrics
index f150faa..b0c5c80 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2023-02-11 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2023-04-06 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
 \let\ltj@@convert@input@path@to@lua\relax % defined in LaTeX only (ltj-latex.sty)
 
 %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
-\protected\def\jfont#1{%
-  \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
-\protected\def\globaljfont#1{%
-  \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true,  'yoko')}}
+%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
+\begingroup
+\def\ltj@@jfdef#1#2#3{%
+  \protected\gdef#1##1{%
+    \ltj@@convert@input@path@to@lua\def\ltj@temp{##1}%
+    \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(#2, '#3')}}}
+\ltj@@jfdef\jfont{false}{yoko}\ltj@@jfdef\globaljfont{true}{yoko}
+\ltj@@jfdef\tfont{false}{tate}\ltj@@jfdef\globaltfont{true}{tate}
+\endgroup
 \newluafunction\ltj@@jfont@inner
 \directlua{
   (lua.get_functions_table())[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY
 }
 \def\ltj@@jfont{\expandafter\expandafter\expandafter\luafunction\expandafter\ltj@@jfont@inner\ltj@temp}
 
-%%%%%%%% \tfont\CS={...:...;jfm=metric;...}, \globaltfont
-\protected\def\tfont#1{%
-  \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'tate')}}
-\protected\def\globaltfont#1{%
-  \ltj@@convert@input@path@to@lua\def\ltj@temp{#1}%
-  \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true,  'tate')}}
 
 %%%%%%%% \zw, \zh
 \newluafunction\ltj@zw@inner
index 0241243..9ed791e 100644 (file)
 \def\ltj@@convert@input@path@to@lua{%
   \ltj@@cipath@clear
   \ifdefined\input@path
-    \@tfor\ltj@temp:=\input@path\do{\ltj@@cipath@add{\ltj@temp}}%
+    \expandafter\@tfor\expandafter\ltj@temp\expandafter:\expandafter=\input@path\do{\ltj@@cipath@add{\ltj@temp}}%
   \fi
 }
 \newluafunction\ltj@@cipath@clear@inner
   (lua.get_functions_table())[\the\ltj@@cipath@clear@inner] = luatexja.input_path_clear
 }
 \protected\luadef\ltj@@cipath@clear\ltj@@cipath@clear@inner
-\def\ltj@@cipath@add#1{\directlua{luatexja.input_path_add('\luatexluaescapestring#1')}}
+\def\ltj@@cipath@add#1{\directlua{luatexja.input_path_add('\luatexluaescapestring{#1}')}}
 \endinput
diff --git a/test/speed/jfm-test_01.lua b/test/speed/jfm-test_01.lua
new file mode 100644 (file)
index 0000000..fab2e5f
--- /dev/null
@@ -0,0 +1,106 @@
+luatexja.jfont.define_jfm {
+   version = 3,
+   dir = 'yoko',
+   zw = 1.0, zh = 1.0,
+   kanjiskip = { 0.1, 0.04, 0.05 },
+   xkanjiskip = { 0.31, 0.045, 0.057 },
+
+   [0] = {
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+   },
+   [1] = {
+      chars = { 'あ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0}, [399] = {1.25, 0.43, 0.87} },
+      kern = { [8] = -1.41 , [2] = 2.0, 
+        [99] = 1.21, [599] = 1.22, [699] = 1.23, [799] = 1.24 }
+   },
+   [11] = {
+      chars = { 'い' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0} },
+      kern = { [2] = 2.0, }
+   },
+   [21] = {
+      chars = { 'う' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0}, 
+        [99] ={ 1.73, 0, 0}, [599] ={ 1.74, 0, 0}, [699] ={ 1.75, 0, 0}, [799] ={ 1.77, 0, 0}  },
+      kern = { [8] = -1.41 , [2] = 2.0, }
+   },
+   [31] = {
+      chars = { 'え' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0} },
+      kern = { [2] = 2.0, [99] = 1.73, [599] = 1.74, [699] = 1.75, [799] = 1.76, }
+   },
+   [41] = {
+      chars = { 'お' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      kern = { [8] = -1.41 , [2] = 2.0}
+   },
+   [51] = {
+      chars = { 'か' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      kern = { [199] = 0.85 },
+   },
+
+   [2] = {
+      chars = { 'ア' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0
+   },
+   [3] = {
+      chars = { 'ウ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0
+   },
+   [4] = {
+      chars = { 'エ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [199] = { 0.78, 0, 0} },
+   },
+   [99] = {
+      chars = { 'jcharbdd' },
+      glue = { [11] = { 1.41, 0, 0} },
+      kern = { [21] = 2.0, }
+   },
+   [599] = {
+      chars = { 'alchar' },
+      glue = { [11] = { 1.42, 0, 0}, [1] = {0.51, 0, 0 } },
+      kern = { [21] = 2.01, }
+   },
+   [699] = {
+      chars = { 'nox_alchar' },
+      glue = { [11] = { 1.43, 0, 0}, [1] = {0.52, 0, 0 } },
+      kern = { [21] = 2.02, }
+   },
+   [799] = {
+      chars = { 'glue' },
+      glue = { [11] = { 1.44, 0, 0}, [1] = {0.53, 0, 0 } },
+      kern = { [21] = 2.03, }
+   },
+   [199] = {
+      chars = { 'boxbdd' },
+      glue = { [51] = { 1.03, 0, 0} , [1] = { 0.94, 0.23, 0.45 }},
+   },
+   [299] = {
+      chars = { 'parbdd' },
+      glue = { [51] = { 0.68, 0.02, 0.04} },
+   },
+   [399] = {
+      chars = { -1 }, -- math
+      glue = { [0] = { 0.68, 0.02, 0.04} },
+   },
+   [8] = {
+      chars = { 'lineend' },
+   }
+}
index 8b80bc5..5b68625 100644 (file)
@@ -82,6 +82,23 @@ TT {\ttfamily (\f@family, \k@family) XYZかきく}\verb+あいうABC+\par
 
 {\fontfamily{gt}\fontseries{x}\selectfont あいう}
 
+
+\makeatletter
+\def\input@path{}
+%\tracingall
+\jfont\a=HaranoAjiMincho-Regular.otf:jfm=test_01
+
+\def\input@path{{speed/}}
+\jfont\a=HaranoAjiMincho-Light.otf:jfm=test_01
+\jfont\az=HaranoAjiMincho-Light.otf:jfm=test_02
+
+\def\input@path{{speed/}{zh/}}
+\jfont\aw=HaranoAjiMincho-Bold.otf:jfm=test_01
+\jfont\as=HaranoAjiGothic-Bold.otf:jfm=test_02
+
+\def\input@path{}
+\jfont\ar=HaranoAjiMincho-Medium.otf:jfm=test_01
+\jfont\af=HaranoAjiMincho-Medium.otf:jfm=test_02
 \end{document}
 
 \paragraph{italic correction inserted by {\tt\char92text...}}\
diff --git a/test/zh/jfm-test_02.lua b/test/zh/jfm-test_02.lua
new file mode 100644 (file)
index 0000000..fab2e5f
--- /dev/null
@@ -0,0 +1,106 @@
+luatexja.jfont.define_jfm {
+   version = 3,
+   dir = 'yoko',
+   zw = 1.0, zh = 1.0,
+   kanjiskip = { 0.1, 0.04, 0.05 },
+   xkanjiskip = { 0.31, 0.045, 0.057 },
+
+   [0] = {
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+   },
+   [1] = {
+      chars = { 'あ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0}, [399] = {1.25, 0.43, 0.87} },
+      kern = { [8] = -1.41 , [2] = 2.0, 
+        [99] = 1.21, [599] = 1.22, [699] = 1.23, [799] = 1.24 }
+   },
+   [11] = {
+      chars = { 'い' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0} },
+      kern = { [2] = 2.0, }
+   },
+   [21] = {
+      chars = { 'う' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0}, 
+        [99] ={ 1.73, 0, 0}, [599] ={ 1.74, 0, 0}, [699] ={ 1.75, 0, 0}, [799] ={ 1.77, 0, 0}  },
+      kern = { [8] = -1.41 , [2] = 2.0, }
+   },
+   [31] = {
+      chars = { 'え' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [3] = { 1.41, 0, 0} },
+      kern = { [2] = 2.0, [99] = 1.73, [599] = 1.74, [699] = 1.75, [799] = 1.76, }
+   },
+   [41] = {
+      chars = { 'お' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      kern = { [8] = -1.41 , [2] = 2.0}
+   },
+   [51] = {
+      chars = { 'か' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      kern = { [199] = 0.85 },
+   },
+
+   [2] = {
+      chars = { 'ア' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0
+   },
+   [3] = {
+      chars = { 'ウ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0
+   },
+   [4] = {
+      chars = { 'エ' },
+      align = 'left', left = 0.0, down = 0.0,
+      width = 1.0, height = 0.88, depth = 0.12, italic=0.0,
+      glue = { [199] = { 0.78, 0, 0} },
+   },
+   [99] = {
+      chars = { 'jcharbdd' },
+      glue = { [11] = { 1.41, 0, 0} },
+      kern = { [21] = 2.0, }
+   },
+   [599] = {
+      chars = { 'alchar' },
+      glue = { [11] = { 1.42, 0, 0}, [1] = {0.51, 0, 0 } },
+      kern = { [21] = 2.01, }
+   },
+   [699] = {
+      chars = { 'nox_alchar' },
+      glue = { [11] = { 1.43, 0, 0}, [1] = {0.52, 0, 0 } },
+      kern = { [21] = 2.02, }
+   },
+   [799] = {
+      chars = { 'glue' },
+      glue = { [11] = { 1.44, 0, 0}, [1] = {0.53, 0, 0 } },
+      kern = { [21] = 2.03, }
+   },
+   [199] = {
+      chars = { 'boxbdd' },
+      glue = { [51] = { 1.03, 0, 0} , [1] = { 0.94, 0.23, 0.45 }},
+   },
+   [299] = {
+      chars = { 'parbdd' },
+      glue = { [51] = { 0.68, 0.02, 0.04} },
+   },
+   [399] = {
+      chars = { -1 }, -- math
+      glue = { [0] = { 0.68, 0.02, 0.04} },
+   },
+   [8] = {
+      chars = { 'lineend' },
+   }
+}