|
16 | 16 | import os
|
17 | 17 | import sphinx
|
18 | 18 |
|
19 |
| -from subprocess import check_output |
20 |
| - |
21 | 19 | # Get Sphinx version
|
22 | 20 | major, minor, patch = sphinx.version_info[:3]
|
23 | 21 |
|
|
355 | 353 | ''',
|
356 | 354 | }
|
357 | 355 |
|
358 |
| -# At least one book (translations) may have Asian characters |
359 |
| -# with are only displayed if xeCJK is used |
| 356 | +# Translations have Asian (CJK) characters which are only displayed if |
| 357 | +# xeCJK is used |
360 | 358 |
|
361 |
| -cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore') |
362 |
| -if cjk_cmd.find("Noto Sans CJK SC") >= 0: |
363 |
| - latex_elements['preamble'] += ''' |
| 359 | +latex_elements['preamble'] += ''' |
| 360 | + \\IfFontExistsTF{Noto Sans CJK SC}{ |
364 | 361 | % This is needed for translations
|
365 |
| - \\usepackage{xeCJK} |
366 |
| - \\setCJKmainfont{Noto Sans CJK SC} |
| 362 | + \\usepackage{xeCJK} |
| 363 | + \\setCJKmainfont{Noto Sans CJK SC} |
367 | 364 | % Define custom macros to on/off CJK
|
368 | 365 | \\newcommand{\\kerneldocCJKon}{\\makexeCJKactive}
|
369 | 366 | \\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive}
|
370 | 367 | % To customize \sphinxtableofcontents
|
371 | 368 | \\usepackage{etoolbox}
|
372 | 369 | % Inactivate CJK after tableofcontents
|
373 | 370 | \\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{}
|
374 |
| - ''' |
375 |
| -else: |
376 |
| - latex_elements['preamble'] += ''' |
| 371 | + }{ % No CJK font found |
377 | 372 | % Custom macros to on/off CJK (Dummy)
|
378 | 373 | \\newcommand{\\kerneldocCJKon}{}
|
379 | 374 | \\newcommand{\\kerneldocCJKoff}{}
|
380 |
| - ''' |
| 375 | + } |
| 376 | +''' |
381 | 377 |
|
382 | 378 | # Fix reference escape troubles with Sphinx 1.4.x
|
383 | 379 | if major == 1:
|
|
0 commit comments