Skip to content

Commit 2712be5

Browse files
committed
lualatex
1 parent 30f9731 commit 2712be5

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

build_docs.py

+34-3
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,46 @@ class Language:
225225
"-D latex_elements.fontenc=",
226226
)
227227

228+
preamble = r"""\usepackage[noto-otf]{luatexja-preset}
229+
% 欧文はLatin Modernのまま
230+
\usepackage{newunicodechar,luacode}
231+
%↓入力中のU+FFFDを一旦U+F8FDに置き換える
232+
\begin{luacode*}
233+
luatexbase.add_to_callback('process_input_buffer', function (s)
234+
if s ~= nil then
235+
if s:match('\xef\xbf\xbd') then
236+
return s:gsub('\xef\xbf\xbd', '\xef\xa3\xbd')
237+
end
238+
end
239+
end, 'hedge_fffd')
240+
\end{luacode*}
241+
%
242+
% - 基本的に"その字形があるフォント"を指定すればOK
243+
% - "欧文側"のフォントで出したい場合は \ltjalchar"<符号値>
244+
% - 特定の文字だけフォントを変えたい場合は \newunicodechar
245+
% で文字を"命令化"して命令定義中でフォントを変える
246+
%
247+
%↓U+212Aの入力 → 'K'(U+004B)を出力
248+
\newunicodechar{^^^^212a}{K}
249+
%↓U+FFFDのグリフをもつフォントを用意する
250+
\newfontface{\fRepC}{DejaVu Sans Mono}
251+
%↓U+F8FDの入力 → U+FFFDを(欧文で, フォント変更して)出力
252+
\newunicodechar{^^^^f8fd}{{\fRepC\ltjalchar"FFFD}}"""
253+
254+
255+
preamble = "".join(L for L in s.split("\n") if L[0] != '%')
256+
257+
228258
PLATEX_DEFAULT = (
229-
"-D latex_engine=uplatex",
259+
"-D latex_engine=lualatex",
230260
"-D latex_elements.inputenc=",
231261
"-D latex_elements.fontenc=",
232-
r"-D latex_elements.preamble=\\usepackage[prefernoncjk]{pxcjkcat} "
262+
"-D latex_docclass.manual=ltjsbook",
263+
"-D latex_docclass.howto=ltjsarticle",
264+
'-D "latex_elements.preamble=' + preamble + '"'
233265
)
234266

235267

236-
237268
XELATEX_WITH_FONTSPEC = (
238269
"-D latex_engine=xelatex",
239270
"-D latex_elements.inputenc=",

0 commit comments

Comments
 (0)