@@ -225,10 +225,40 @@ class Language:
225
225
"-D latex_elements.fontenc=" ,
226
226
)
227
227
228
- PLATEX_DEFAULT = (
229
- "-D latex_engine=platex " ,
228
+ LUALATEX_FOR_JP = (
229
+ "-D latex_engine=lualatex " ,
230
230
"-D latex_elements.inputenc=" ,
231
231
"-D latex_elements.fontenc=" ,
232
+ "-D latex_docclass.manual=ltjsbook" ,
233
+ "-D latex_docclass.howto=ltjsarticle" ,
234
+
235
+ # supress polyglossia warnings
236
+ "-D latex_elements.polyglossia=" ,
237
+ "-D latex_elements.fontpkg=" ,
238
+
239
+ # preamble
240
+ "-D latex_elements.preamble="
241
+
242
+ # Render non-Japanese letters with luatex
243
+ # https://gist.github.com/zr-tex8r/e0931df922f38fbb67634f05dfdaf66b
244
+ r"\\usepackage[noto-otf]{luatexja-preset}"
245
+ r"\\usepackage{newunicodechar}"
246
+ r"\\newunicodechar{^^^^212a}{K}"
247
+
248
+ # Workaround for the luatex-ja issue (Thanks to @jfbu)
249
+ # https://github.com/sphinx-doc/sphinx/issues/11179#issuecomment-1420715092
250
+ # https://osdn.net/projects/luatex-ja/ticket/47321
251
+ r"\\makeatletter"
252
+ r"\\titleformat{\\subsubsection}{\\normalsize\\py@HeaderFamily}"
253
+ r"{\\py@TitleColor\\thesubsubsection}{0.5em}{\\py@TitleColor}"
254
+ r"\\titleformat{\\paragraph}{\\normalsize\\py@HeaderFamily}"
255
+ r"{\\py@TitleColor\\theparagraph}{0.5em}{\\py@TitleColor}"
256
+ r"\\titleformat{\\subparagraph}{\\normalsize\\py@HeaderFamily}"
257
+ r"{\\py@TitleColor\\thesubparagraph}{0.5em}{\\py@TitleColor}"
258
+ r"\\makeatother"
259
+
260
+ # subpress warning: (fancyhdr)Make it at least 16.4pt
261
+ r"\\setlength{\\footskip}{16.4pt}"
232
262
)
233
263
234
264
XELATEX_WITH_FONTSPEC = (
@@ -257,7 +287,7 @@ class Language:
257
287
Language ("fr" , "fr" , "French" , True , XELATEX_WITH_FONTSPEC ),
258
288
Language ("id" , "id" , "Indonesian" , False , XELATEX_DEFAULT ),
259
289
Language ("it" , "it" , "Italian" , False , XELATEX_DEFAULT ),
260
- Language ("ja" , "ja" , "Japanese" , True , PLATEX_DEFAULT , html_only = True ), # See https://github.com/python/python-docs-ja/issues/35
290
+ Language ("ja" , "ja" , "Japanese" , True , LUALATEX_FOR_JP ),
261
291
Language ("ko" , "ko" , "Korean" , True , XELATEX_FOR_KOREAN ),
262
292
Language ("pl" , "pl" , "Polish" , False , XELATEX_DEFAULT ),
263
293
Language ("pt-br" , "pt_BR" , "Brazilian Portuguese" , True , XELATEX_DEFAULT ),
@@ -726,6 +756,17 @@ def build(self):
726
756
"-D gettext_compact=0" ,
727
757
)
728
758
)
759
+ if self .language .tag == "ja" :
760
+ # Since luatex doesn't support \ufffd, replace \ufffd with '?'.
761
+ # https://gist.github.com/zr-tex8r/e0931df922f38fbb67634f05dfdaf66b
762
+ # Luatex already fixed this issue, so we can remove this once Texlive is updated.
763
+ # (https://github.com/TeX-Live/luatex/commit/eaa95ce0a141eaf7a02)
764
+ subprocess .check_output ("sed -i s/\N{REPLACEMENT CHARACTER} /?/g "
765
+ f"{ locale_dirs } /ja/LC_MESSAGES/**/*.po" ,
766
+ shell = True )
767
+ subprocess .check_output ("sed -i s/\N{REPLACEMENT CHARACTER} /?/g "
768
+ f"{ self .checkout } /Doc/**/*.rst" , shell = True )
769
+
729
770
if self .version .status == "EOL" :
730
771
sphinxopts .append ("-D html_context.outdated=1" )
731
772
maketarget = (
0 commit comments