Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp155176pxv; Thu, 24 Jun 2021 05:10:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN3xht7GYaHWYbTH5oiyXh7b5InN2m2eV63cJ483loNB24jyEmPG/BmgQDKLR2V8uOv4On X-Received: by 2002:a92:874b:: with SMTP id d11mr3202612ilm.137.1624536616589; Thu, 24 Jun 2021 05:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624536616; cv=none; d=google.com; s=arc-20160816; b=XMmb0w213ndmIUOKhq1NnQRYTImuiqMKIvd67nz9KHNLbx5DlgnGKM94EKFL29k2tP lw0FkZ619xoDBkY/3+OYjV8zJC16Te6rZJ1iahXmrIXZ4ONFQWQnrPHOkL4hzJ3RSDYt TUw70BRkmVq4NbM+jASYae1n6tZDIABFnPtXQXph+//ZhbQMB+5XIbQW5BTi6CUOcBb+ 5fQvGfsfC6DWWlsVN0hc0qwMQ9gzUOOVjKZNHI7AEQedo2K4+ekm2g4XLls0DqFuCGYG XTcypz3vj28XzBFKdwUFdlb+mh7pJ6Dvceer7OUXjzPQBL/+iuYwMDbBF+LY4LhY2Hyb 0PjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=1HIae1IsTpNnOLreRylFk4etMZm5amtWa1pmqvSZnbI=; b=mKKlLk3ckgLDChfiEKGElmuwkYrFP1vlk09ll9V4fJhFlr8UQVEG0mn8KefWr6ykww gSRwvCujYAwZW6ioM3gUhlsjiNeoVj1c3YSf3yaMA1WUaD3w62DuZR2jX5bkIcKRikXz H8H8IowbrcckCwmOV+qvNZR4VzzodVGlqDMLduT58KqAgsMBj7q/jBaTTmhfvP0h5CFo dRJcPPumQXRBW3ar/vyteWuI3d57irIP9KoOu6vosSPvtbI5EVGHT4HbpY/tHFJABW/r lI9r6sUnKU5/oP5DQVK+k3mlm/LSvGs+vpPBYTtHpC4VEU+ahAOELKvwTajcHj0Y+hZS qaig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BU698jLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si2966929ilo.119.2021.06.24.05.10.04; Thu, 24 Jun 2021 05:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BU698jLD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbhFXMLP (ORCPT + 99 others); Thu, 24 Jun 2021 08:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbhFXMLN (ORCPT ); Thu, 24 Jun 2021 08:11:13 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04827C061767; Thu, 24 Jun 2021 05:08:53 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id c5so4980461pfv.8; Thu, 24 Jun 2021 05:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1HIae1IsTpNnOLreRylFk4etMZm5amtWa1pmqvSZnbI=; b=BU698jLDNATJW6K6T1wqHj8gJs1B/N/MXT3RyNcUyJ+CRBqFWVSHBBSHRCC9Nt2RhY BuWxOee+vntpLjNRZSvAd0VL/cEhXmDVciNiyDsIdjtGEMLesgbuO8VN1EPJiEjVVkeX GUY5MXTDZ13VCyRnjSaPrKrNOV5LUHf6bCbPyRQMKs7uyHyjbo03pIGzOO+5R7c4mvMJ s3F0St50qe4dG1e1qTS7xxss7XEE90hjoQUcngLQqHSYQPDCAtShv76gw3bEKpZ+wm/F wWMARP6xL44vr+FV+GJATF206EB+M1ijehcALssmEkzNaXTTeqyVziAy+QpChrgHXQly 8NqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1HIae1IsTpNnOLreRylFk4etMZm5amtWa1pmqvSZnbI=; b=WYbLXo3NTxdOiMFTCS+nBbf/Zqm3BrJ9HKB/WXgIRvK8zwnQZd/5c9hqMR44t+KndO BpmAhW4QQ7NzJPWQnxP1rfOFLZ72tSEBpc6SIdUwW7wviWt9GAkQB4eIOjV7f0a504Jd sJ8mHMzdusLKVlGgrnhDgrEU/vxgOwACXzB3/XgUlcBjvAl4XXzGzlHAWniBA0Jr6KO1 m/37EbVHZFte75wIPoRecmpg0IhGmTyckjTmCcTtl7hw5mE3mjcCf9rSp0kYcGR96rVC gHf7O+kQBfZpU54AQXn78oq6R6gly/yZmMAJnNx11XrGtezZl2kNMYWQlFxBoZJuRN8n Qwig== X-Gm-Message-State: AOAM530C8kinFOOHrzscaxbzU/NuY+6fH3c8YJ9n6Fmybt4kH4bX0BjZ UbFgOO6fBERO4W4nlmkgbqk= X-Received: by 2002:a63:6e87:: with SMTP id j129mr4490153pgc.45.1624536532533; Thu, 24 Jun 2021 05:08:52 -0700 (PDT) Received: from [192.168.11.2] (KD106167171201.ppp-bb.dion.ne.jp. [106.167.171.201]) by smtp.gmail.com with ESMTPSA id lb14sm8237455pjb.5.2021.06.24.05.08.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 05:08:52 -0700 (PDT) Subject: [RFC PATCH 1/3] docs: pdfdocs: Refactor config for CJK document To: Jonathan Corbet , Mauro Carvalho Chehab Cc: "Wu X.C." , SeongJae Park , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Akira Yokosawa References: <386938dc-6290-239c-4b4f-c6153f3d98c5@gmail.com> From: Akira Yokosawa Message-ID: <45a7b96a-bc27-ade4-716a-c319715e1b4d@gmail.com> Date: Thu, 24 Jun 2021 21:08:49 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <386938dc-6290-239c-4b4f-c6153f3d98c5@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To make generated LaTeX code portable across systems with different sets of available fonts, convert font-availability check in python code to LaTeX code by using a conditional command provided by the "fontspec" package. This will help those who want to run Sphinx on one machine/container and run latexmk on other machines/containers with different font configurations. Signed-off-by: Akira Yokosawa --- Documentation/conf.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Documentation/conf.py b/Documentation/conf.py index 7d92ec3e5b6e..22f083bafaae 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -358,26 +358,23 @@ latex_elements = { # At least one book (translations) may have Asian characters # with 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: - latex_elements['preamble'] += ''' +latex_elements['preamble'] += ''' + \\IfFontExistsTF{Noto Sans CJK SC}{ % This is needed for translations - \\usepackage{xeCJK} - \\setCJKmainfont{Noto Sans CJK SC} + \\usepackage{xeCJK} + \\setCJKmainfont{Noto Sans CJK SC} % Define custom macros to on/off CJK \\newcommand{\\kerneldocCJKon}{\\makexeCJKactive} \\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive} - % To customize \sphinxtableofcontents + % Inactivate CJK after tableofcontents (using etoolbox) \\usepackage{etoolbox} - % Inactivate CJK after tableofcontents \\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{} - ''' -else: - latex_elements['preamble'] += ''' + }{ % No CJK font % Custom macros to on/off CJK (Dummy) \\newcommand{\\kerneldocCJKon}{} \\newcommand{\\kerneldocCJKoff}{} - ''' + } +''' # Fix reference escape troubles with Sphinx 1.4.x if major == 1: -- 2.17.1