% \iffalse meta-comment
%
% File: lxgw.dtx
% -----------------------------------------------------------------------
%   Runtime: Copyright (C) 2025-2026 by Mingyu Xia <myhsia@outlook.com> *
%                                                                       *
%   Fonts:   Copyright (C) 2021-2026 by LXGW <https://github.com/lxgw>  *
%            Copyright (C) 2021-2026 by TrionesType <x.com/TrionesType> *
% -----------------------------------------------------------------------
%   This work may be distributed and/or modified under the conditions   *
%   of the SIL Open Font License (OFL) version 1.1.                     *
%   The latest version of this license is in                            *
%                                                                       *
%       https://openfontlicense.org                                     *
%                                                                       *
%   This work has the OFL maintenance status `maintained'.              *
%                                                                       *
%   The Current Maintainer of this work on CTAN is Mingyu Xia.          *
%                                                                       *
%   The Current Designer of this font family is LXGW.                   *
% -----------------------------------------------------------------------
%   This work consists of the files lxgw.dtx,                           *
%                                   lxgw.ins,                           *
%                 the derived files ctex-fontset-lxgw.def,              *
%                                   ctex-zhmap-lxgw.tex,                *
%                                   ctex-spa-make-lxgw.tex,             *
%                                   ctexspa-lxgw.def,                   *
%                    the font files LXGWNeoZhiSong.ttf,                 *
%                                   LXGWNeoZhiSongScreen.ttf,           *
%                                   LXGWNeoXiHei.ttf,                   *
%                                   LXGWNeoXiHeiScreen.ttf,             *
%                                   LXGWZhuqueFangsong-Regular.ttf,     *
%                                   LXGWWenKaiGBLite-Regular.ttf,       *
%                                   LXGWZhenKaiGB-Regular.ttf,          *
%           the documentation files lxgw.pdf,                           *
%                               and README.md.                          *
% -----------------------------------------------------------------------
%                                                                       *
%   Any modification of this file should ensure that the copyright and  *
%   license information is placed in the derived files.                 *
%                                                                       *
% -----------------------------------------------------------------------
%
%<*internal>
\iffalse
%</internal>
%
%<*readme>
[![CTAN Version](https://img.shields.io/ctan/v/lxgw-fonts)](https://ctan.org/pkg/lxgw-fonts)
[![GitHub Release](https://img.shields.io/github/v/release/myhsia/lxgw-ctan)](https://github.com/myhsia/lxgw-ctan/releases/latest)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/myhsia/LXGW-CTAN)](https://github.com/myhsia/LXGW-CTAN/commits)
[![Actions Status](https://github.com/myhsia/lxgw-ctan/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/myhsia/lxgw-ctan/actions)
[![GitHub Repo stars](https://img.shields.io/github/stars/myhsia/LXGW-CTAN)](https://github.com/myhsia/LXGW-CTAN)

The `LXGW` Font Family
======================

The `LXGW` Font Family provides an open-source CJK font family with a
comprehensive character set for Chinese (Simplified/Traditional), Cantonese,
and Japanese. A `fontset` configuration of this font family for the `ctex-kit`
is also provided in this package, which provides four commands for loading the
listed regular and **bold** font files

|  Command  | Name |         Regular Font File        |        Bold Font File       |
| --------- | ---- | -------------------------------- | --------------------------- |
|`\songti`  | 宋体 | `LXGWNeoZhiSong.ttf`             | `LXGWNeoZhiSongScreen.ttf`  |
|`\heiti`   | 黑体 | `LXGWNeoXiHei.ttf`               | `LXGWNeoXiHeiScreen.ttf`    |
|`\fangsong`| 仿宋 | `LXGWZhuqueFangsong-Regular.ttf` | (AutoFakeBold enabled)      |
|`\kaishu`  | 楷书 | `LXGWWenKaiGBLite-Regular.ttf`   | `LXGWZhenKaiGB-Regular.ttf` |

Issues
------

The issue tracker for `LXGW` is currently located
[on GitHub](https://github.com/myhsia/LXGW-CTAN).

Build status
------------

This project uses [GitHub Actions](https://github.com/features/actions) as a
hosted continuous integration service. For each commit, the build status is
tested using the current release of TeX Live.

_Current build status:_
![build status](https://github.com/myhsia/lxgw-ctan/actions/workflows/test.yaml/badge.svg?branch=main)

Copyright and License
---------------------

- Runtime: Copyright (C) 2025-2026 by Mingyu Xia
  [`<myhsia@outlook.com>`](mailto:myhsia@outlook.com)

- Fonts:   Copyright (C) 2021-2026 by [LXGW](https://github.com/lxgw) and
                                      [TrionesType](https://x.com/TrionesType)

This work may be distributed and/or modified under the conditions
of the SIL Open Font License (OFL) version 1.1.
The latest version of this license is in

    https://openfontlicense.org

This work has the OFL maintenance status `maintained'.

The Current Maintainer of this work on CTAN is **Mingyu Xia**.

The Current Designer of this font family is **LXGW** and **TrionesType**.
%</readme>
%
%<*internal>
\fi
%</internal>
%
%<*fontset>
%<+!driver>\GetIdInfo $Id: lxgw.dtx v1.522F 2026-07-01 myhsia<myhsia@outlook.com>$
%<fontset>  {lxgw fontset configuration for ctex-kit}
%<fontset>\ProvidesExplFile {ctex-fontset-lxgw.def}
%<+!driver>  {\ExplFileDate} {\ExplFileVersion} {\ExplFileDescription}
%<fontset>\edef \LXGWFileDate        {\ExplFileDate}
%<fontset>\edef \LXGWFileVersion     {\ExplFileVersion}
%<fontset>\edef \LXGWFileDescription {\ExplFileDescription}
%</fontset>
%<*driver>
\documentclass[cs-break = true, svgnames]{l3doc}
\usepackage[mono = false, osf]{libertine}
\usepackage[punct  = plain, fontset    = lxgw,
            scheme = plain, linespread = 1.05]{ctex}
\defaultfontfeatures{Extension = .ttf, Scale = .95}
\usepackage{tikz, framed}
\tikzset{every picture/.append style = {line cap = round}}
\ExplSyntaxOn \makeatletter
\newcommand \mail[1]{\href{mailto:#1}{\ttfamily #1}}
\dim_set:Nn \FrameSep {2pt}
\tex_tracinglostchars:D = 0
\tex_XeTeXcharclass:D "2370 = 1
\DeclareDocumentCommand \key { s O { \ttfamily } m }
  {
    \IfBooleanTF {#1}
      {
        \color_group_begin:
        \color_select:n { red } \bfseries #2 #3
        \color_group_end:
      }
      {
        \group_begin: #2
        \seq_set_from_clist:Nn \l_tmpa_seq {#3}
        \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
          {
            \exp_not:n
              {
                \color_group_begin:
                \color_select:n { red } \bfseries #2 ##1
                \color_group_end:
              }
          }
        \seq_use:Nn \l_tmpb_seq { ,~ } ~ = ~
        \group_end:
      }
  }
\DeclareCommandCopy \val \meta
\newlist{keyval}{itemize}{10}
\setlist[keyval]{leftmargin = 0pt, labelsep = 0pt}
\tl_greplace_all:Nnn \LXGWFileDate { / } { - }
\def \HoLogo@LXGW#1{^^A
  \tex_XeTeXcharclass:D "004C = 1^^A L
  \tex_XeTeXcharclass:D "0058 = 1^^A X
  \tex_XeTeXcharclass:D "0047 = 1^^A G
  \tex_XeTeXcharclass:D "0057 = 1^^A W
  \kaishu LX\kern-.05emG\kern-.05emW}
\def \HoLogo@TrionesType#1{^^A
  \tex_XeTeXcharclass:D "0054 = 1^^A T
  \tex_XeTeXcharclass:D "0072 = 1^^A r
  \tex_XeTeXcharclass:D "0069 = 1^^A i
  \tex_XeTeXcharclass:D "006F = 1^^A o
  \tex_XeTeXcharclass:D "006E = 1^^A n
  \tex_XeTeXcharclass:D "0065 = 1^^A e
  \tex_XeTeXcharclass:D "0073 = 1^^A s
  \tex_XeTeXcharclass:D "0054 = 1^^A T
  \tex_XeTeXcharclass:D "0079 = 1^^A y
  \tex_XeTeXcharclass:D "0070 = 1^^A p
  \tex_XeTeXcharclass:D "0065 = 1^^A e
  \fangsong TrionesType
}
\def\@thanks{\Copyright}
\makeatother \ExplSyntaxOff
\makeindex
\begin{document}
  \DocInput{\jobname.dtx}
  \clearpage
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \title{\bfseries
%   The \hologo{LXGW} Font Family\thanks{^^A
%     \url{https://github.com/myhsia/LXGW-CTAN}
%   }\texorpdfstring{\enspace \textbar \enspace\parbox{4em}{^^A
%     \kaishu
%     \scalebox{\fpeval{4/7}}{落霞与孤鹜齐飞}\\[-.75em]
%     \scalebox{\fpeval{4/7}}{秋水共长天一色}^^A
%   }}{}^^A
% }
%
% \author{^^A
%   Designer: \texorpdfstring{\hologo{LXGW} ({\kaishu 霞鹜})}{LXGW} /
%             \texorpdfstring{\hologo{TrionesType} ({\fangsong 璇璣造字})}
%               {TrionesType}\thanks{^^A
%     \url{https://github.com/lxgw},
%     \url{https://github.com/TrionesType/zhuque}},
%   \texorpdfstring{\enspace}{ }
%   Maintainer: Mingyu Xia\thanks{\mail{xiamingyu@westlake.edu.cn}}^^A
% }
%
% \date{Released \LXGWFileDate\quad \texttt{\LXGWFileVersion}}
%
% \def\Copyright{^^A
%   \begin{center}
%   \setlength \fboxrule {1.2pt} \fbox{\setlength \fboxrule {.6pt}^^A
%     \fbox{\parbox {.8\linewidth} {^^A
%     This package packs a selection of open-source CJK fonts from
%     \href{https://github.com/lxgw/LxgwNeoZhiSong}
%       {\songti 霞鶩新緻宋},
%     \href{https://github.com/lxgw/LxgwNeoXiHei}
%       {\heiti 霞鶩新晰黑},
%     \href{https://github.com/lxgw/LxgwWenKaiGB-Lite}
%       {\kaishu 霞鶩文楷},
%     \href{https://github.com/lxgw/LxgwZhenKai}
%       {\kaishu \bfseries 霞鶩臻楷},
%     which are released into public domain by
%     \href{https://lxgw.github.io}{\hologo{LXGW}} and
%     \href{https://github.com/TrionesType/zhuque}
%       {\fangsong 朱雀仿宋}
%     released into public domain by
%     \href{https://x.com/TrionesType}{\hologo{TrionesType}} since 2021.
%     They are licensed under the
%     \href{https://opensource.org/license/IPA}{IPA Font License}
%     and~\href{https://ctan.org/license/ofl}{SIL Open Font License}.
%   }}}
%   \end{center}}
%
% \maketitle
% \tikz[remember picture, overlay] {^^A
%   \node [ above right,     minimum width  = 1.2\ccwd,
%           inner sep = 0pt, minimum height = 1.2\ccwd,
%           rotate = -10, font = \kaishu,
%           scale = 15, opacity = .3, gray ] (xia) at
%         ([shift = {(-3 * 10pt, 2 * 10pt)}]
%           current page.south west) {驗};
%   \draw [ loosely dashed, DarkGreen, opacity = .15,
%           line width = .2 * 10pt ]
%         (xia.north west) -- (xia.south east)
%         (xia.north east) -- (xia.south west);
%   \draw [ DarkGreen, opacity = .15, line width = .2 * 10pt ]
%         (xia.north) -- (xia.south) (xia.west) -- (xia.east);
%   \draw [ rotate around = {-10:(xia.center)}, line width = .5 * 10pt,
%           DarkGreen, opacity = .1 ]
%         (xia.north west) rectangle (xia.south east);
%   \node [ right,           minimum width  = 1.2\ccwd,
%           inner sep = 0pt, minimum height = 1.2\ccwd,
%           rotate = -10, font = \kaishu,
%           scale = 15, opacity = .3, gray ] (wu) at
%         (xia.east) {訖};
%   \draw [ loosely dashed, DarkGreen, opacity = .15,
%           line width = .2 * 10pt ]
%         (wu.north west) -- (wu.south east)
%         (wu.north east) -- (wu.south west);
%   \draw [ DarkGreen, opacity = .15, line width = .2 * 10pt ]
%         (wu.north) -- (wu.south) (wu.west) -- (wu.east);
%   \draw [ rotate around = {-10:(wu.center)}, line width = .5 * 10pt,
%           DarkGreen, opacity = .1 ]
%         (wu.north west) rectangle (wu.south east);
%   \draw [ rotate around = {-10:(xia.east)}, line width = .5 * 10pt,
%           DarkGreen, opacity = .1]
%         (xia.north west) rectangle (wu.south east);
%   \node [ below left,      minimum width  = 1.2\ccwd,
%           inner sep = 0pt, minimum height = 1.2\ccwd,
%           rotate = -10, font = \fangsong,
%           scale = 15, opacity = .3, gray ] (xuan) at
%         ([shift = {(3 * 10pt, -2 * 10pt)}]
%           current page.north east) {檢};
%   \draw [ loosely dashed, DarkRed, opacity = .15,
%           line width = .2 * 10pt ]
%         (xuan.north west) -- (xuan.south east)
%         (xuan.north east) -- (xuan.south west);
%   \draw [ DarkRed, opacity = .15, line width = .2 * 10pt ]
%         (xuan.north) -- (xuan.south) (xuan.west) -- (xuan.east);
%   \draw [ rotate around = {-10:(xuan.center)},
%           line width = .5 * 10pt, DarkRed, opacity = .1 ]
%         (xuan.north west) rectangle (xuan.south east);
%   \node [ left,            minimum width  = 1.2\ccwd,
%           inner sep = 0pt, minimum height = 1.2\ccwd,
%           rotate = -10, font = \kaishu,
%           scale = 15, opacity = .3, gray ] (ji) at
%         (xuan.west) {肉};
%   \draw [ loosely dashed, DarkRed, opacity = .15,
%           line width = .2 * 10pt ]
%         (ji.north west) -- (ji.south east)
%         (ji.north east) -- (ji.south west);
%   \draw [ DarkRed, opacity = .15, line width = .2 * 10pt ]
%         (ji.north) -- (ji.south) (ji.west) -- (ji.east);
%   \draw [ rotate around = {-10:(ji.center)}, line width = .5 * 10pt,
%           DarkRed, opacity = .1 ]
%         (ji.north west) rectangle (ji.south east);
%   \draw [ rotate around = {-10:(ji.west)}, line width = .5 * 10pt,
%           DarkRed, opacity = .1]
%         (xuan.north east) rectangle (ji.south west);
% }
%
% \begin{documentation}
%
% \begin{abstract}
%   The \hologo{LXGW} Font Family provides an open-source CJK font family with a
%   comprehensive character set for Chinese (Simplified/Traditional), Cantonese,
%   and~Japanese. A |fontset| configuration of this font family for the
%   \pkg{ctex-kit} is also provided in this package.
% \end{abstract}
%
% \section{Usage}
%
% Users are allowed to use the friendly interface:
% the |fontset| key in \CTeX\ kit
% \begin{quote}
%   "\documentclass[fontset = lxgw]{ctex(art|book|rep|beamer)}"\\
%   "\usepackage   [fontset = lxgw]{ctex}"
% \end{quote}
% with engines \hologo{pdfTeX}, \hologo{XeTeX}, \hologo{LuaTeX}, \hologo{upTeX},
% and~\hologo{ApTeX} supported. Four commands are provided for loading the
% listed regular and \textbf{bold} font files
% \begin{function}{\songti, \heiti, \fangsong, \kaishu} \footnotesize
%   \begin{syntax}
%   \songti   宋体 (|CJKmainfont|):^^A
% \file{LXGWNeoZhiSong.ttf}, \file{LXGWNeoZhiSongScreen.ttf}\\
%   \heiti    黑体 (|CJKsansfont|):^^A
% \file{LXGWNeoXiHei.ttf}, \file{LXGWNeoXiHeiScreen.ttf}\\
%   \fangsong 仿宋 (|CJKmonofont|):^^A
% \file{LXGWZhuqueFangsong-Regular.ttf} (|AutoFakeBold| enabled)\\
%   \kaishu   楷书 (it. \kern-1.5exof |CJKmainfont|):^^A
% \file{LXGWWenKaiGBLite-Regular.ttf}, \file{LXGWZhenKaiGB-Regular.ttf}
%   \end{syntax}
% \end{function}
% This user-friendly interface is implemented in
% \ref{subsec:fontset}, \ref{subsec:spa}, and~\ref{subsec:zhmap}.
%
% The \file{.ttf} files are sourced from the following links
% \def \fetch#1{\href{#1}{\ttfamily #1}}
% \begin{itemize}[itemsep = 2pt, topsep = 4pt, leftmargin = 2em] \scriptsize
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwNeoZhiSong/releases/latest/download/LXGWNeoZhiSong.ttf
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwNeoXiZhi-Screen/releases/latest/download/LXGWNeoZhiSongScreen.ttf
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwNeoXiHei/releases/latest/download/LXGWNeoXiHei.ttf
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwNeoXiZhi-Screen/releases/latest/download/LXGWNeoXiHeiScreen.ttf
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/TrionesType/zhuque/releases/download/v0.212/ZhuqueFangsong-v0.212.zip
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwWenkaiGB-Lite/releases/latest/download/LXGWWenKaiGBLite-Regular.ttf
% \iffalse
%</fetch>
% \fi
% }
%   \item \fetch{^^A
% \iffalse
%<*fetch>
% \fi
https://github.com/lxgw/LxgwZhenKai/releases/latest/download/LXGWZhenKaiGB-Regular.ttf
% \iffalse
%</fetch>
% \fi
% }
% \end{itemize}
%
% \section{Font Demos}
%
% The following lists the Chinese/English name, filename, and~demos of the
% fonts: Cantonese, Japanese, Chinese (Simplified/Traditional) versions of
% ``\textbf{I Can Eat Glass}'', and missing character markers are provided with
% punctuation compression disabled.
% \ExplSyntaxOn
% \NewDocumentCommand \shufa { O{} m }
%   {
%     \group_begin:
%     \tl_map_inline:nn {#2}
%       {
%         \tikz {
%           \node [ minimum ~ width  = 1.5\ccwd, outer ~ sep = 0pt,
%                   draw = DarkGreen!40, thick,  font = #1,
%                   minimum ~ height = 1.5\ccwd, inner ~ sep = 0pt ]
%             (tmp) {##1};
%           \draw [densely ~ dashed, DarkGreen, opacity = .2]
%                 (tmp.north ~ west) -- (tmp.south ~ east)
%                 (tmp.north ~ east) -- (tmp.south ~ west);
%           \draw [DarkGreen, opacity = .2, thin]
%                 (tmp.north) -- (tmp.south) (tmp.west) -- (tmp.east);
%         } \kern-.8pt
%       }
%     \group_end:
% }
% \def\0{\centering
%   \shufa[\Large]{私ガラスを食べられます。^^^^2370}
%   \shufa[\Large\bfseries]{それは私を傷つけません。}
%   \kern.8pt \\[\dimexpr-.2\baselineskip+.8pt]
%   \shufa[\Large]{我能吞下玻璃而不伤身体。}
%   \shufa[\Large\bfseries]{^^^^2370我能吞下玻璃而不伤身体。}
%   \kern.8pt\\[\dimexpr-.2\baselineskip+.8pt]
%   \shufa[\Large]{我能吞下玻璃而不傷身體。}
%   \shufa[\Large]{我可以食玻璃，}
%   \shufa[\Large\bfseries]{佢傷唔到我。}
%   \kern.8pt
% }
% \ExplSyntaxOff
% \begin{keyval}
%   \item[{\key[\mdseries\songti]{霞鶩新緻宋}}]
%   \file{LXGWNeoZhiSong.ttf}, \file{LXGWNeoZhiSongScreen.ttf}
%   \begin{framed}
%     \songti\0
%   \end{framed}
%   \item[{\key[\mdseries\heiti]{霞鶩新晰黑}}]
%   \file{LXGWNeoXiHei.ttf}, \file{LXGWNeoXiHeiScreen.ttf}
%   \begin{framed}
%     \heiti\0
%   \end{framed}
%   \item[{\key[\mdseries\fangsong]{朱雀仿宋}}]
%   \file{LXGWZhuqueFangsong-Regular.ttf}
%   \begin{framed}
%     \fangsong\0
%   \end{framed}
%   \item[{\key[\mdseries\kaishu]{霞鹜文楷, \textbf{霞鹜臻楷}}}]
%   \file{LXGWWenKaiGBLite-Regular.ttf}, \file{LXGWZhenKaiGB-Regular.ttf}
%   \begin{framed}
%     \kaishu\0
%   \end{framed}
% \end{keyval}
% \end{documentation}
%
% \StopEventually{\PrintIndex}
% \clearpage \appendix
%
% \begin{implementation}
%
% \section{The Source Code}
%
% \subsection{The \texttt{ctex-fontset-lxgw.def} file}\label{subsec:fontset}
%
% Start the optionlist |fontset| for \pkg{l3docstrip}.
%    \begin{macrocode}
%<*fontset>
%    \end{macrocode}
%
% Load CJK font family, the interface provided by \pkg{ctex-kit} accepts the
% following 3 branches.
%    \begin{macrocode}
\ctex_fontset_case:nnn
%    \end{macrocode}
%
% \DescribeOption{\hologo{pdfTeX}}
% For those \hologo{pdfTeX} or \hologo{LaTeX} + \hologo{DVIPDFMx}.
%    \begin{macrocode}
  {
%    \end{macrocode}
% Load the \file{.spa} file for the \pkg{CJKpunct} package
% under \hologo{pdfTeX}.
%    \begin{macrocode}
    \ctex_file_input:n { ctexspa-lxgw.def }
%    \end{macrocode}
% Case choice controlled by the |zhmap| key of \pkg{ctex-kit}.
%    \begin{macrocode}
    \ctex_zhmap_case:nnn
%    \end{macrocode}
% \begin{arguments}
%   \item Content of this argument will be outputted to the input stream when
%   |zhmap = zhmCJK|
%   \begin{quote}
%     \color{gray}|\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_i:nnn|
%   \end{quote}
% The \hologo{LXGW} font family uses |UniGB-UTF16-H|
% \underline{\textbf{C}haracter To Glyph Index \textbf{Map}ping Table}.
%    \begin{macrocode}
      {
        \setCJKmainfont { LXGWNeoZhiSong.ttf              }
          [
            cmap           = UniGB-UTF16-H, AutoFakeBold,
            ItalicFont     = LXGWWenKaiGBLite-Regular.ttf,
            BoldItalicFont = LXGWZhenKaiGB-Regular.ttf
          ]
        \setCJKsansfont { LXGWNeoXiHei.ttf                }
          [ cmap = UniGB-UTF16-H, AutoFakeBold, AutoFakeSlant ]
        \setCJKmonofont { LXGWZhuqueFangsong-Regular.ttf  }
          [ cmap = UniGB-UTF16-H, AutoFakeBold, AutoFakeSlant ]
        \setCJKfamilyfont { zhsong } { LXGWNeoZhiSong.ttf             }
          [ cmap = UniGB-UTF16-H, AutoFakeBold, AutoFakeSlant ]
        \setCJKfamilyfont { zhhei  } { LXGWNeoXiHei.ttf               }
          [ cmap = UniGB-UTF16-H, AutoFakeBold, AutoFakeSlant ]
        \setCJKfamilyfont { zhfs   } { LXGWZhuqueFangsong-Regular.ttf }
          [ cmap = UniGB-UTF16-H, AutoFakeBold, AutoFakeSlant ]
        \setCJKfamilyfont { zhkai  } { LXGWWenKaiGBLite-Regular.ttf   }
          [ cmap = UniGB-UTF16-H, AutoFakeSlant,
            BoldFont        = LXGWZhenKaiGB-Regular.ttf,
            SlantedFont     = LXGWWenKaiGBLite-Regular.ttf,
            ItalicFont      = LXGWWenKaiGBLite-Regular.ttf,
            BoldSlantedFont = LXGWZhenKaiGB-Regular.ttf,
            BoldItalicFont  = LXGWZhenKaiGB-Regular.ttf       ]
%    \end{macrocode}
% Configure the usages of the edge information of the defined CJK families.
%    \begin{macrocode}
        \ctex_punct_set:n { lxgw }
        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhhei   }
        \ctex_punct_map_family:nn   { \CJKttdefault         } { zhfs    }
        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
        \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei  } { zhheib  }
        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
      }
%    \end{macrocode}
%   \item Content of this argument will be outputted to the input stream when
%   |zhmap = true|
%   \begin{quote}
%     \color{gray}|\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn|
%   \end{quote}
%   Load the mapping file \file{ctex-zhmap-lxgw.tex} (see~\ref{subsec:zhmap})
%   for \pkg{zhmatrices} and set \tn{CJKrmdefault}, \tn{CJKsfdefault},
%   \tn{CJKttdefault}, respectively.
%    \begin{macrocode}
      {
        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { lxgw }
%    \end{macrocode}
%   Configure the usages of the edge information of \tn{CJKrmdefault}.
%    \begin{macrocode}
        \ctex_punct_set:n { lxgw }
        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
      }
%    \end{macrocode}
%   \item Content of this argument will be outputted to the input stream when
%   |zhmap = false|
%   \begin{quote}
%     \color{gray}|\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn|
%   \end{quote}
%   Here will raise a \underline{|fontset-unavailable|} error.
%    \begin{macrocode}
      { \ctex_fontset_error:n { lxgw } }
  }
%    \end{macrocode}
% \end{arguments}
%
% \DescribeOption{\hologo{upTeX}, \hologo{ApTeX}}
% For those use \hologo{upLaTeX} + \hologo{DVIPDFMx}.
% Configure the basic font mapping for \hologo{upTeX}. Due to the definition in
% \pkg{zhmetrics-uptex}, configure
% \begin{multicols}{3}
% \begin{enumerate}
%   \item |upshape|  of serif font.
%   \item |bfseries| of serif font.
%   \item |itshape|  of serif font.
%   \item |upshape|  of sans font.
%   \item |bfseries| of sans font.
%   \item |upshape|  of mono font.
% \end{enumerate}
% \end{multicols}
%    \begin{macrocode}
  {
    \ctex_set_upfonts:nnnnnn
      { LXGWNeoZhiSong.ttf              }
      { LXGWNeoZhiSongScreen.ttf        }
      { LXGWWenKaiGBLite-Regular.ttf    }
      { LXGWNeoXiHei.ttf                }
      { LXGWNeoXiHeiScreen.ttf          }
      { LXGWZhuqueFangsong-Regular.ttf  }
%    \end{macrocode}
%   Config the \textsf{NFSS} font families |zhsong|, |zhhei|, |zhfs|, and
%   |zhkai| to the \textsf{JFM} name in normal type and bold type.
%   Leave empty for those font families with no bold version.
%    \begin{macrocode}
    \ctex_set_upfamily:nnn { zhsong } { upzhserif    } { upzhserifb }
    \ctex_set_upfamily:nnn { zhhei  } { upzhsans     } { upzhsans   }
    \ctex_set_upfamily:nnn { zhfs   } { upzhmono     } { }
    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit  } { }
  }
%    \end{macrocode}
%
% \DescribeOption{\hologo{XeTeX}, \hologo{LuaTeX}}
% For those use \hologo{XeLaTeX} or \hologo{LuaLaTeX}.
%    \begin{macrocode}
  {
    \setCJKmainfont { LXGWNeoZhiSong              }
      [
        Extension      = .ttf, AutoFakeBold,
        ItalicFont     = LXGWWenKaiGBLite-Regular,
        BoldItalicFont = LXGWZhenKaiGB-Regular.ttf,
      ]
    \setCJKsansfont { LXGWNeoXiHei                }
      [ Extension = .ttf, AutoFakeBold,                     AutoFakeSlant ]
    \setCJKmonofont { LXGWZhuqueFangsong-Regular  }
      [ Extension = .ttf, AutoFakeBold,                     AutoFakeSlant ]
    \setCJKfamilyfont { zhsong } { LXGWNeoZhiSong }
      [ Extension = .ttf, AutoFakeBold,                     AutoFakeSlant ]
    \setCJKfamilyfont { zhhei  } { LXGWNeoXiHei               }
      [ Extension = .ttf, AutoFakeBold,                     AutoFakeSlant ]
    \setCJKfamilyfont { zhfs   } { LXGWZhuqueFangsong-Regular }
      [ Extension = .ttf, AutoFakeBold,                     AutoFakeSlant ]
    \setCJKfamilyfont { zhkai  } { LXGWWenKaiGBLite-Regular   }
      [ Extension = .ttf, BoldFont        = LXGWZhenKaiGB-Regular,
                          SlantedFont     = LXGWWenKaiGBLite-Regular,
                          ItalicFont      = LXGWWenKaiGBLite-Regular,
                          BoldSlantedFont = LXGWZhenKaiGB-Regular,
                          BoldItalicFont  = LXGWZhenKaiGB-Regular         ]
  }
%    \end{macrocode}
%
% \begin{macro}{\songti, \heiti, \fangsong, \kaishu}
% Shortcuts that same as those in the \pkg{ctex-kit}.
%    \begin{macrocode}
\NewDocumentCommand \songti   { } { \CJKfamily { zhsong } }
\NewDocumentCommand \heiti    { } { \CJKfamily { zhhei  } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs   } }
\NewDocumentCommand \kaishu   { } { \CJKfamily { zhkai  } }
%    \end{macrocode}
% \end{macro}
%
% End the optionlist |fontset| for \pkg{l3docstrip}.
%    \begin{macrocode}
%</fontset>
%    \end{macrocode}
%
% \subsection{The \texttt{ctex-spa-make-lxgw.tex} and
%   the \texttt{ctexspa-lxgw.def} file}\label{subsec:spa}
%
% The \file{.spa} file of the corresponding font will be used
% for the \pkg{CJKpunct} package to achieve the punctuation compression,
% which can ensure the best typeset effect (under the \hologo{pdfTeX} engine).
% Run the following script, \file{ctex-spa-make-lxgw.tex} by executing
% \begin{verbatim}
%   xetex ctex-spa-make-lxgw
% \end{verbatim}
% in the terminal. Then, one can obtain the \file{ctexpunct-lxgw.spa} file.
%
% Start the optionlist |makespa| for \pkg{l3docstrip}.
%    \begin{macrocode}
%<*makespa>
%    \end{macrocode}
%
% Loading the macro file \file{ctex-spa-macro.tex} provided by \pkg{ctex-kit}.
%    \begin{macrocode}
\input ctex-spa-macro %
%    \end{macrocode}
%
% List all the CJK families with the corresponding font files in terms of
% ``case-pairs''.
%    \begin{macrocode}
\MAKESPA {ctexpunct-lxgw.spa}
  {
    {lxgwzhsong}      {LXGWNeoZhiSong} ,
    {lxgwzhsongb}     {LXGWNeoZhiSongScreen} ,
    {lxgwzhhei}       {LXGWNeoXiHei} ,
    {lxgwzhheib}      {LXGWNeoXiHeiScreen} ,
    {lxgwzhfs}        {LXGWZhuqueFangsong-Regular} ,
    {lxgwzhkai}       {LXGWWenKaiGBLite-Regular} ,
    {lxgwzhkaib}      {LXGWZhenKaiGB-Regular} ,
  }
%    \end{macrocode}
%
% End of the script.
%    \begin{macrocode}
\primitive\end
%    \end{macrocode}
%
% End the optionlist |makespa| for \pkg{l3docstrip}.
%    \begin{macrocode}
%</makespa>
%    \end{macrocode}
%
% Start the optionlist |lxgw-spa| for \pkg{l3docstrip}.
%    \begin{macrocode}
%<*lxgw-spa>
%    \end{macrocode}
%
% Define the edge information of the corresponding font families for the
% \pkg{CJKpunct} package.
%    \begin{macrocode}
\ctexspadef{lxgwzhsong}{10,8,9,8,67,8,58,8,71,8,65,9,67,8,65,10,55,5,54,4,64,9,71,9,0,0,10,10,5,72,4,71,9,77,9,77,19,69,18,69,19,70,5,50,12,12,8,71,9,65,8,67,10,65,5,55,4,53,9,64,9,71,8,10,8,9,8,67,8,58,,,}
\ctexspadef{lxgwzhsongb}{9,7,8,7,67,8,58,8,70,8,65,8,67,8,65,9,55,5,53,3,63,8,70,8,-0,-0,10,10,5,72,4,71,8,77,8,76,18,68,18,68,18,69,4,50,12,12,8,70,8,65,8,67,9,65,5,55,3,53,8,63,8,70,7,9,7,8,8,67,8,58,,,}
\ctexspadef{lxgwzhhei}{9,5,10,5,65,8,58,5,68,8,66,8,61,8,67,8,53,5,52,3,60,7,71,7,0,0,11,11,4,72,6,67,8,77,9,77,19,69,18,69,20,69,4,48,8,8,8,68,8,66,8,61,8,67,6,53,3,52,7,60,7,71,5,9,5,10,8,65,5,58,,,}
\ctexspadef{lxgwzhheib}{9,5,9,5,64,8,57,5,68,8,65,7,61,8,67,8,53,5,52,3,60,6,70,6,0,0,11,11,4,72,6,67,8,77,9,77,19,69,17,69,20,69,4,47,8,8,8,67,7,65,8,61,8,67,5,53,3,52,6,60,6,70,5,9,5,9,8,64,5,57,,,}
\ctexspadef{lxgwzhfs}{3,2,3,2,60,8,60,5,65,16,62,17,63,18,59,17,60,13,49,12,60,6,69,8,0,0,11,11,12,64,12,62,17,66,11,76,19,69,16,68,20,66,15,58,20,18,18,63,17,62,18,63,17,59,13,60,11,49,7,59,8,69,2,3,2,3,12,56,8,57,,,}
\ctexspadef{lxgwzhkai}{12,11,6,4,72,6,68,5,72,6,71,7,72,6,68,7,66,5,52,5,70,-1,72,4,0,0,12,12,7,71,8,65,10,77,12,76,20,70,18,70,17,72,7,50,12,12,6,72,7,71,6,72,7,68,5,66,5,52,-1,70,4,72,11,12,4,6,6,72,5,68,,,}
\ctexspadef{lxgwzhkaib}{6,8,6,8,71,4,64,5,71,5,70,6,71,5,67,6,65,4,47,4,62,3,66,3,-1,-1,10,10,7,67,4,65,14,67,16,68,17,68,14,67,16,71,6,49,11,11,5,71,6,70,5,71,6,67,4,65,4,47,3,62,3,66,8,6,8,6,4,71,5,64,,,}
%    \end{macrocode}
%
% End the optionlist |lxgw-spa| for \pkg{l3docstrip}.
%    \begin{macrocode}
%</lxgw-spa>
%    \end{macrocode}
%
% \subsection{The \texttt{ctex-zhmap-lxgw.tex} file}\label{subsec:zhmap}
%
% Start the optionlist |zhmap-lxgw| for \pkg{l3docstrip}.
%    \begin{macrocode}
%<*zhmap-lxgw>
%    \end{macrocode}
%
% Forked from the |zhmap| optionlist of \file{ctex.dtx}\footnote{^^A
%   \url{https://github.com/CTeX-org/ctex-kit/blob/master/ctex/ctex.dtx}}.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode 35=6  % #
  \catcode 45=12 % -
  \catcode123=1  % {
  \catcode125=2  % }
  \toks0{\endlinechar=\the\endlinechar\relax}%
  \toks2{\endlinechar=-1 }%
  \def\x#1 #2 {%
    \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
    \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
  \x  13  5 % carriage return
  \x  32 10 % space
  \x  35  6 % #
  \x  40 12 % (
  \x  41 12 % )
  \x  45 12 % -
  \x  46 12 % .
  \x  47 12 % /
  \x  58 12 % :
  \x  60 12 % <
  \x  61 12 % =
  \x  64 11 % @
  \x  91 12 % [
  \x  93 12 % ]
  \x 123  1 % {
  \x 125  2 % }
  \edef\x#1{\endgroup%
    \edef\noexpand#1{%
      \the\toks0 %
      \let\noexpand\noexpand\noexpand#1%
          \noexpand\noexpand\noexpand\undefined%
      \noexpand\noexpand\noexpand\endinput}%
    \the\toks2}%
\expandafter\x\csname ctex@zhmap@endinput\endcsname
\begingroup\expandafter\endgroup
\expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname
  \expandafter\ifx\csname ifctexpdf\endcsname\relax
    \expandafter\ifx\csname pdfoutput\endcsname\relax
      iffalse\else\ifnum\pdfoutput < 1 iffalse\else iftrue\fi\fi
  \else ifctexpdf\fi
\endcsname
\begingroup
\expandafter\ifx\csname ProvidesFile\endcsname\relax
  \long\def\x#1\ProvidesFile#2[#3]{%
    #1%
    \immediate\write-1{File: #2 #3}%
    \expandafter\xdef\csname ver@#2\endcsname{#3}}
  \expandafter\x%
\fi
\endgroup
%    \end{macrocode}
%
% Provides the identification information of the font map loader.
%    \begin{macrocode}
\ProvidesFile{ctex-zhmap-lxgw.tex}%
  [\LXGWFileDate\ \LXGWFileVersion\ lxgw font map loader for DVIPDFMx (CTEX)]
%    \end{macrocode}
%
% Font map loader for \hologo{pdfTeX} (generate PDF).
%    \begin{macrocode}
\ifzhmappdf
%    \end{macrocode}
%    \begin{macrocode}
  \pdfmapline{=gbk@UGBK@          <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbksong@UGBK@      <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbkkai@UGBK@       <LXGWWenKaiGBLite-Regular.ttf}
  \pdfmapline{=gbkhei@UGBK@       <LXGWNeoXiHei.ttf}
  \pdfmapline{=gbkfs@UGBK@        <LXGWZhuqueFangsong-Regular.ttf}
  \pdfmapline{=cyberb@Unicode@    <LXGWNeoZhiSong.ttf}
  \pdfmapline{=unisong@Unicode@   <LXGWNeoZhiSong.ttf}
  \pdfmapline{=unikai@Unicode@    <LXGWWenKaiGBLite-Regular.ttf}
  \pdfmapline{=unihei@Unicode@    <LXGWNeoXiHei.ttf}
  \pdfmapline{=unifs@Unicode@     <LXGWZhuqueFangsong-Regular.ttf}
  \pdfmapline{=gbksongsl@UGBK@    <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbkkaisl@UGBK@     <LXGWWenKaiGBLite-Regular.ttf}
  \pdfmapline{=gbkheisl@UGBK@     <LXGWNeoXiHei.ttf}
  \pdfmapline{=gbkfssl@UGBK@      <LXGWZhuqueFangsong-Regular.ttf}
  \pdfmapline{=unisongsl@Unicode@ <LXGWNeoZhiSong.ttf}
  \pdfmapline{=unikaisl@Unicode@  <LXGWWenKaiGBLite-Regular.ttf}
  \pdfmapline{=uniheisl@Unicode@  <LXGWNeoXiHei.ttf}
  \pdfmapline{=unifssl@Unicode@   <LXGWZhuqueFangsong-Regular.ttf}
%    \end{macrocode}
%
% Configuration for \hologo{pdfTeX} (generate DVI).
%    \begin{macrocode}
\else
%    \end{macrocode}
% Configure the upright shape of \tn{songti}, \tn{kaishu}, \tn{heiti},
% and~\tn{fangsong} mapping for GBK encoding and UTF8 encoding.
%    \begin{macrocode}
\special{pdf:mapline gbk@UGBK@          UniGB-UTF16-H LXGWNeoZhiSong.ttf}
\special{pdf:mapline gbksong@UGBK@      UniGB-UTF16-H LXGWNeoZhiSong.ttf}
\special{pdf:mapline gbkkai@UGBK@       UniGB-UTF16-H LXGWWenKaiGBLite-Regular.ttf}
\special{pdf:mapline gbkhei@UGBK@       UniGB-UTF16-H LXGWNeoXiHei.ttf}
\special{pdf:mapline gbkfs@UGBK@        UniGB-UTF16-H LXGWZhuqueFangsong-Regular.ttf}
\special{pdf:mapline cyberb@Unicode@    UniGB-UTF16-H LXGWNeoZhiSong.ttf}
\special{pdf:mapline unisong@Unicode@   UniGB-UTF16-H LXGWNeoZhiSong.ttf}
\special{pdf:mapline unikai@Unicode@    UniGB-UTF16-H LXGWWenKaiGBLite-Regular.ttf}
\special{pdf:mapline unihei@Unicode@    UniGB-UTF16-H LXGWNeoXiHei.ttf}
\special{pdf:mapline unifs@Unicode@     UniGB-UTF16-H LXGWZhuqueFangsong-Regular.ttf}
%    \end{macrocode}
% Similar for the (fake) slant shape, set the
% \emph{Afine Transformation coefficient} to |0.167|, which is the same as the
% default value of |AutoFakeSlant| in the \pkg{xeCJK} package.
%    \begin{macrocode}
\special{pdf:mapline gbksongsl@UGBK@    UniGB-UTF16-H LXGWNeoZhiSong.ttf -s .167}
\special{pdf:mapline gbkkaisl@UGBK@     UniGB-UTF16-H LXGWWenKaiGBLite-Regular.ttf -s .167}
\special{pdf:mapline gbkheisl@UGBK@     UniGB-UTF16-H LXGWNeoXiHei.ttf -s .167}
\special{pdf:mapline gbkfssl@UGBK@      UniGB-UTF16-H LXGWZhuqueFangsong-Regular.ttf -s .167}
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H LXGWNeoZhiSong.ttf -s .167}
\special{pdf:mapline unikaisl@Unicode@  UniGB-UTF16-H LXGWWenKaiGBLite-Regular.ttf -s .167}
\special{pdf:mapline uniheisl@Unicode@  UniGB-UTF16-H LXGWNeoXiHei.ttf -s .167}
\special{pdf:mapline unifssl@Unicode@   UniGB-UTF16-H LXGWZhuqueFangsong-Regular.ttf -s .167}
\fi
%    \end{macrocode}
%
% End the optionlist |zhmap-lxgw| for \pkg{l3docstrip}.
%    \begin{macrocode}
%</zhmap-lxgw>
%    \end{macrocode}
% \end{implementation}
