[lkml]   [2021]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] docs: Activate xeCJK only in CJK chapters
On Sat, 22 May 2021 20:14:39 +0200, Mauro Carvalho Chehab wrote:
> Em Sat, 22 May 2021 16:28:55 +0900
> Akira Yokosawa <> escreveu:
>> Activating xeCJK in English or Italian-translation documents
>> results in sub-optimal typesetting with wide-looking apostrophes
>> and quotation marks.
>> The xeCJK package provides macros for enabling and disabling its
>> effect in the middle of a document, namely \makexeCJKactive and
>> \makexeCJKinactive.
>> So the goal of this change is to activate xeCJK in the relevant
>> chapters in translations.
>> To do this:
>> o Define custom macros in the preamble depending on the
>> availability of the "Noto Sans CJK" font so that those
>> macros can be embedded in translations.tex after the fact.
>> By default, xeCJK is inactive.
>> o Add a script to embed the on/off
>> macros in translations.tex where necessary.
>> The patterns in the script are ad-hoc by nature, and will
>> need updates when the chapter organization changes.
>> o Invoke the script at the final step of target "latexdocs".
> Interesting solution, but there are probably an easy/better
> way of doing something similar to it.
> There is an extension called:
> Documentation/sphinx/
> Which allows using a per-document file. While it can also be
> used to have a "nitpick" version where extra warnings are enabled,
> the main usage were to have separated PDF documents.
> We ended finding a better solution, so most got removed
> on this patch: 9fc3a18a942f ("docs: remove extra files").
> Anyway, perhaps we could simply add a Documentation/translations/
> that would add the CJK font only there.

Ah, that sounds like the way to go!

But I have no idea how I can load that extra for translations.

Simply putting the following as Documentation/translations/
doesn't work.

# -*- coding: utf-8; mode: python -*-

# translations have Asian characters
# which are only displayed if xeCJK is used

cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore')
if cjk_cmd.find("Noto Sans CJK SC") >= 0:
print ("translations: enabling CJK for LaTeX builder")
latex_elements['preamble'] += '''
% This is needed for translations
\\setCJKmainfont{Noto Sans CJK SC}

What am I missing?

Note: I'm not good at python.

Thanks, Akira
> Even better, we could even improve it in a way that each translation
> would generate a separated book, and then use CJK only for the
> non-Latin translations.
> Regards,
> Mauro

 \ /
  Last update: 2021-05-23 01:22    [W:0.187 / U:1.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site