From a4a050ae1386f0f0f0e7dbb06fba265ab7f2c99a Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Thu, 6 Apr 2023 20:45:04 +0900 Subject: [PATCH] better fix of #47723 --- src/ltj-jfont.lua | 4 +- src/luatexja-core.sty | 24 +++++----- src/patches/lltjfont.sty | 4 +- test/speed/jfm-test_01.lua | 106 +++++++++++++++++++++++++++++++++++++++++++++ test/test02-latex.tex | 17 ++++++++ test/zh/jfm-test_02.lua | 106 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 243 insertions(+), 18 deletions(-) create mode 100644 test/speed/jfm-test_01.lua create mode 100644 test/zh/jfm-test_02.lua diff --git a/src/ltj-jfont.lua b/src/ltj-jfont.lua index 8cb0fa4..26c76d8 100644 --- a/src/ltj-jfont.lua +++ b/src/ltj-jfont.lua @@ -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 diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index f150faa..b0c5c80 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -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 % %% Load prerequisite packages. @@ -224,25 +224,21 @@ \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 diff --git a/src/patches/lltjfont.sty b/src/patches/lltjfont.sty index 0241243..9ed791e 100644 --- a/src/patches/lltjfont.sty +++ b/src/patches/lltjfont.sty @@ -1438,7 +1438,7 @@ \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 @@ -1446,5 +1446,5 @@ (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 index 0000000..fab2e5f --- /dev/null +++ b/test/speed/jfm-test_01.lua @@ -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' }, + } +} diff --git a/test/test02-latex.tex b/test/test02-latex.tex index 8b80bc5..5b68625 100644 --- a/test/test02-latex.tex +++ b/test/test02-latex.tex @@ -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 index 0000000..fab2e5f --- /dev/null +++ b/test/zh/jfm-test_02.lua @@ -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' }, + } +} -- 2.11.0