% \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-lxgw.spa,                  *
%                                   ctexpunct-lxgw.tex,                 *
%                    the font files LXGWNeoZhiSong.ttf,                 *
%                                   LXGWNeoZhiSongScreen.ttf,           *
%                                   LXGWNeoXiHei.ttf,                   *
%                                   LXGWNeoXiHeiScreen.ttf,             *
%                                   LXGWZhuqueFangsong-Regular.ttf,     *
%                                   LXGWWenKaiLite-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 Last Commit](https://img.shields.io/github/last-commit/myhsia/LXGW-CTAN)](https://github.com/myhsia/LXGW-CTAN/commits)
[![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.

Issues
------

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

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

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 and TrionesType.
%</readme>
%
%<*internal>
\fi
%</internal>
%
%<*driver>
\documentclass{l3doc}
\usepackage[mono = false, osf]{libertine}
\usepackage[punct = plain, fontset = lxgw, scheme = plain]{ctex}
\defaultfontfeatures{Extension = .ttf, Scale = .95}
\usepackage{tikz, framed, xfrac}
\ExplSyntaxOn \makeatletter
\dim_set:Nn \FrameSep {2pt}
\tex_tracinglostchars:D = 0
\tex_XeTeXcharclass:D "2370 = 1
\DeclareDocumentCommand \key { s m }
  {
    \IfBooleanTF {#1} { \color_select:n { red } #2 ~ }
      {
        \seq_set_from_clist:Nn \l_tmpa_seq {#2}
        \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
          {
            \color_group_begin:
            \color_select:n { red } \exp_not:n { ##1 }
            \color_group_end:
          }
        \seq_use:Nn \l_tmpb_seq { ,~ } \:=\:
      }
  }
\cs_gset_eq:NN \val \meta
\newlist{keyval}{itemize}{10}
\setlist[keyval]{leftmargin = 0pt, labelsep = 0pt}
\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
}
\makeatother \ExplSyntaxOff
\makeindex
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \makeatletter
% \title{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}}{LXGW} ({\kaishu 霞鹜}) /
%             \texorpdfstring{\hologo{TrionesType}}{TrionesType} ({\fangsong 璇璣造字})\thanks{^^A
%     \url{https://github.com/lxgw},
%     \url{https://github.com/TrionesType/zhuque}},
%   \texorpdfstring{\enspace}{ }
%   Maintainer: Mingyu Xia\thanks{\texttt{^^A
%     \href{mailto:xiamingyu@westlake.edu.cn}{xiamingyu@westlake.edu.cn}^^A
%   }}
% }
%
% \date{Released 2026-01-13\quad \texttt{v1.521K}}
%
% \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/LxgwWenKaiLite}
%       {\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://ctan.org/license/ofl}{SIL Open Font License (OFL)}.
%   }}}
%   \end{center}}
% \def\@thanks{\Copyright}
%
% \maketitle
% \tikz[remember picture, overlay]
%   \node [ rotate = -10, font = \songti,
%           scale = 50, opacity = .1 ] at
%         ([shift = {(10 * \f@size \p@, 8 * \f@size \p@)}]
%           current page.south west) {鹜};
% \makeatother
%
% \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 the \pkg{ctex} package
% \begin{quote}
%   |\usepackage[fontset = lxgw]{ctex}|
% \end{quote}
% or the \cls{ctex} classes
% \begin{quote}
%   |\documentclass[fontset = lxgw]{ctex|^^A
%   \meta{art\textup\textbar book\textup\textbar rep\textup\textbar beamer}|}|
% \end{quote}
% with \hologo{XeLaTeX}, \hologo{LuaLaTeX}, \hologo{LaTeX} + \hologo{DVIPDFMx},
% \hologo{upLaTeX} + \hologo{DVIPDFMx}, and \hologo{ApLaTeX}
% (aka \hologo{pLaTeX}-ng) supported. \hologo{pdfLaTeX} is not
% supported temporarily since the long mapping time of |zhmap|.
% Additionally, the following four commands are provided for convenience.
% \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. of |CJKmainfont|):^^A
% \file{LXGWWenKaiLite-Regular.ttf}, \file{LXGWZhenKaiGB-Regular.ttf}
%   \end{syntax}
% \end{function}
% \NB{tag}{cmt}
% \begin{NOTE}{tag}
% \end{NOTE}
% Note that the names of the four control sequences make no sense here,
% just to \emph{keep the same naming habit of \pkg{ctex-kit}}.
%
% The implementation of this user-friendly interface is included in
% \ref{subsec:fontset}, \ref{subsec:spa}, and~\ref{subsec:zhmap}.
%
% \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}'', missing
% character markers are provided with punctuation compression disabled and
% fulfilling line.
% \def\0{^^A
%   \makebox[\linewidth][s]{^^A
%     我可以食玻璃，\textbf{佢傷唔到我㗎。}^^A
%     私はガラスを食べられます。\textbf{それは私を傷つけません。}}\\
%   \makebox[\linewidth][s]{^^A
%     我能吞下玻璃而不伤身体。\textbf{我能吞下玻璃而不伤身体。}^^A
%     我能吞下玻璃而不傷身體。^^^^2370^^^^2370^^^^2370^^A
%   }^^A
% }
% \begin{keyval}
%   \item[\key*{\songti 霞鹜新智宋 (\pkg{LXGW Neo ZhiSong})}]
%         \file{LXGWNeoZhiSong.ttf}, \file{LXGWNeoZhiSongScreen.ttf}
%   \begin{framed}
%     \songti\0
%   \end{framed}
%   \item[\key*{\heiti 霞鹜新晰黑 (\pkg{LXGW Neo XiHei})}]
%         \file{LXGWNeoXiHei.ttf}, \file{LXGWNeoXiHeiScreen.ttf}
%   \begin{framed}
%     \heiti\0
%   \end{framed}
%   \item[\key*{\fangsong 朱雀仿宋 (\pkg{\textsc{Zhuque Fangsong}})}]
%         \file{LXGWZhuqueFangsong-Regular.ttf}
%   \begin{framed}
%     \fangsong\0
%   \end{framed}
%   \item[\key*{\kaishu 霞鹜$\sfrac{\text{文楷}}{\text{臻楷}}$
%         (\pkg{LXGW $\sfrac{\text{WenKai}}{\text{ZhenKai}}$})}]
%         \file{LXGWWenKaiLite-Regular.ttf}, \file{LXGWZhenKaiGB-Regular.ttf}
%   \begin{framed}
%     \kaishu\0
%   \end{framed}
% \end{keyval}
%
% \end{documentation}
% \clearpage \appendix
% \begin{implementation}
%
% \section{The Source Code}
%
% \subsection{The \texttt{ctex-fontset-lxgw.def} file}\label{subsec:fontset}
%
% Start the optionlist |fontset| for l3docstrip.
%    \begin{macrocode}
%<*fontset>
%    \end{macrocode}
% Declare the \pkg{ctex-kit} font configuration file with date, version, and
% description.
%    \begin{macrocode}
\ProvidesExplFile {ctex-fontset-lxgw.def} {2026-01-13} {v1.521K}
  {lxgw fontset configuration for ctex-kit}
%    \end{macrocode}
% Load CJK font family, interface, accepts the following 4 branches,
% provided by \pkg{ctex-kit}.
%    \begin{macrocode}
\ctex_fontset_case:nnnn
%    \end{macrocode}
% \DescribeOption{\hologo{pdfTeX} (generate PDF)}
% This branch is no longer supported here, and a
% \underline{|fontset-unavailable|} error will raise.
%    \begin{macrocode}
  { \ctex_fontset_error:n { lxgw } }
%    \end{macrocode}
% \begin{texnote}
% For some fontset that supports this branch, line |4| -- |5| should be
% replaced as a line
% \begin{verbatim}
%   \ctex_fontset_case:nnn
% \end{verbatim}
% \end{texnote}
% \DescribeOption{\hologo{pdfTeX} (generate DVI)}
% For those use \hologo{LaTeX} + \hologo{DVIPDFMx}.
%    \begin{macrocode}
  {
%    \end{macrocode}
% Load the \file{.spa} file for the \pkg{CJKpunct} package.
%    \begin{macrocode}
    \ctex_file_input:n { ctex-spa-lxgw.spa }
%    \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{verbatim}[commandchars = \\\{\}]
%     \color{gray}\cs{cs_gset_eq:NN} \cs{ctex_zhmap_case:nnn} \cs{use_i:nnn}
%   \end{verbatim}
% The \hologo{LXGW} font family uses the |UniGB-UTF16-H| cmap (Character To
% Glyph Index Mapping Table).
%    \begin{macrocode}
      {
        \setCJKmainfont { LXGWNeoZhiSong.ttf              }
          [
            cmap           = UniGB-UTF16-H, AutoFakeBold,
            ItalicFont     = LXGWWenKaiLite-Regular.ttf,
            BoldItalicFont = LXGWZhenKaiGB-Regular.ttf
          ]
        \setCJKsansfont { LXGWNeoXiHei.ttf                }
          [ cmap = UniGB-UTF16-H, AutoFakeBold ]
        \setCJKmonofont { LXGWZhuqueFangsong-Regular.ttf  }
          [ cmap = UniGB-UTF16-H, AutoFakeBold ]
        \setCJKfamilyfont { zhsong } { LXGWNeoZhiSong.ttf             }
          [ cmap = UniGB-UTF16-H, AutoFakeBold ]
        \setCJKfamilyfont { zhhei  } { LXGWNeoXiHei.ttf               }
          [ cmap = UniGB-UTF16-H, AutoFakeBold ]
        \setCJKfamilyfont { zhfs   } { LXGWZhuqueFangsong-Regular.ttf }
          [ cmap = UniGB-UTF16-H, AutoFakeBold ]
        \setCJKfamilyfont { zhkai  } { LXGWWenKaiLite-Regular.ttf     }
          [ cmap = UniGB-UTF16-H, BoldFont = 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{verbatim}[commandchars = \\\{\}]
%     \color{gray}\cs{cs_gset_eq:NN} \cs{ctex_zhmap_case:nnn} \cs{use_ii:nnn}
%   \end{verbatim}
%   Load the mapping file \file{ctex-zhmap-lxgw.tex} for \pkg{zhmatrices} and
%   set \cs{CJKrmdefault}, \cs{CJKsfdefault}, \cs{CJKttdefault}, respectively.
%    \begin{macrocode}
      {
        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { lxgw }
%    \end{macrocode}
%   Configure the usages of the edge information of \cs{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{verbatim}[commandchars = \\\{\}]
%     \color{gray}\cs{cs_gset_eq:NN} \cs{ctex_zhmap_case:nnn} \cs{use_iii:nnn}
%   \end{verbatim}
%   Here will raise a \underline{|fontset-unavailable|} error.
%    \begin{macrocode}
      { \ctex_fontset_error:n { lxgw } }
  }
%    \end{macrocode}
% \end{arguments}
% \DescribeOption{\hologo{upTeX}, \hologo{ApTeX} (aka \hologo{pTeX}-ng)}
% 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        }
      { LXGWWenKaiLite-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     = LXGWWenKaiLite-Regular,
        BoldItalicFont = LXGWZhenKaiGB-Regular.ttf
      ]
    \setCJKsansfont { LXGWNeoXiHei                }
      [ Extension = .ttf, AutoFakeBold ]
    \setCJKmonofont { LXGWZhuqueFangsong-Regular  }
      [ Extension = .ttf, AutoFakeBold  ]
    \setCJKfamilyfont { zhsong } { LXGWNeoZhiSong }
      [ Extension = .ttf, AutoFakeBold ]
    \setCJKfamilyfont { zhhei  } { LXGWNeoXiHei               }
      [ Extension = .ttf, AutoFakeBold ]
    \setCJKfamilyfont { zhfs   } { LXGWZhuqueFangsong-Regular }
      [ Extension = .ttf, AutoFakeBold ]
    \setCJKfamilyfont { zhkai  } { LXGWWenKaiLite-Regular     }
      [ Extension = .ttf, BoldFont = 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 l3docstrip.
%    \begin{macrocode}
%</fontset>
%    \end{macrocode}
%
% \subsection{The \texttt{ctex-spa-make.tex} and
%   the \texttt{ctexpunct-lxgw.tex} 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.tex}, by executing
% \begin{verbatim}
%   xetex ctex-spa-make
% \end{verbatim}
% in the terminal. Then, one can obtain the \file{ctexpunct-lxgw.tex} file.
% \paragraph{Implementation of the script}
% Start the optionlist |makespa| for l3docstrip.
%    \begin{macrocode}
%<*makespa>
%    \end{macrocode}
% Assign the module name of the variables and control sequences, which will be
% automatically replaced by \pkg{l3docstrip}.
%    \begin{macrocode}
%<@@=ctex>
%    \end{macrocode}
% Loading the macro file \file{ctex-spa-macro.tex} provided by \pkg{ctex-kit}.
%    \begin{macrocode}
\input ctex-spa-macro %
%    \end{macrocode}
% However, the macro file needs to be hacked due to the interface change
% of \hologo{XeTeX}.
%    \begin{macrocode}
\ExplSyntaxOn
\cs_set_protected:Npn \@@_write_family:nn #1#2
  {
    \group_begin:
      \tex_font:D \l_@@_punct_font = "[#2]" ~ at ~ 100 pt \scan_stop:
      \l_@@_punct_font
      \clist_clear:N \l_@@_punct_bounds_clist
      \seq_map_inline:Nn \c_@@_punct_seq
        {
          \exp_args:No \_@@_save_bounds:n
            { \int_use:N \tex_XeTeXcharglyph:D ##1 }
        }
      \iow_now:Nx \g_@@_spa_iow
        {
          \token_to_str:N \ctexspadef {#1}
            { \l_@@_punct_bounds_clist , , , }
        }
    \group_end:
  }
\ExplSyntaxOff
%    \end{macrocode}
% List all the CJK families with the corresponding font files in terms of
% ``case-pairs''.
%    \begin{macrocode}
\MAKESPA {ctexpunct-lxgw.tex}
  {
    {lxgwzhsong}      {LXGWNeoZhiSong} ,
    {lxgwzhsongb}     {LXGWNeoZhiSongScreen} ,
    {lxgwzhhei}       {LXGWNeoXiHei} ,
    {lxgwzhheib}      {LXGWNeoXiHeiScreen} ,
    {lxgwzhfs}        {LXGWZhuqueFangsong-Regular} ,
    {lxgwzhkai}       {LXGWWenKaiLite-Regular} ,
    {lxgwzhkaib}      {LXGWZhenKaiGB-Regular} ,
  }
%    \end{macrocode}
% End of the script.
%    \begin{macrocode}
\primitive\end
%    \end{macrocode}
% Restore the module name.
%    \begin{macrocode}
%<@@=>
%    \end{macrocode}
% End the optionlist |zhmap| for l3docstrip.
%    \begin{macrocode}
%</makespa>
%    \end{macrocode}
% \iffalse
%    \begin{macrocode}
%<*lxgw-spa>
%    \end{macrocode}
%    \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}
%    \begin{macrocode}
%</lxgw-spa>
%    \end{macrocode}
% \fi
%
% \subsection{The \texttt{ctex-zhmap-lxgw.tex} file}\label{subsec:zhmap}
%
% Start the optionlist |zhmap| for l3docstrip.
%    \begin{macrocode}
%<*zhmap>
%    \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}%
  [2026-01-13 v1.521K lxgw font map loader for DVIPDFMx (CTEX)]
%    \end{macrocode}
% Font map loader for \hologo{pdfTeX} and \hologo{DVIPDFMx}.
%    \begin{macrocode}
\ifzhmappdf
%    \end{macrocode}
% Since \hologo{pdfTeX} maps too slowly, this mode is obsolete.
%    \begin{macrocode}
\iffalse
  \pdfmapline{=gbk@UGBK@          <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbksong@UGBK@      <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbkkai@UGBK@       <LXGWWenKaiLite-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@    <LXGWWenKaiLite-Regular.ttf}
  \pdfmapline{=unihei@Unicode@    <LXGWNeoXiHei.ttf}
  \pdfmapline{=unifs@Unicode@     <LXGWZhuqueFangsong-Regular.ttf}
  \pdfmapline{=gbksongsl@UGBK@    <LXGWNeoZhiSong.ttf}
  \pdfmapline{=gbkkaisl@UGBK@     <LXGWWenKaiLite-Regular.ttf}
  \pdfmapline{=gbkheisl@UGBK@     <LXGWNeoXiHei.ttf}
  \pdfmapline{=gbkfssl@UGBK@      <LXGWZhuqueFangsong-Regular.ttf}
  \pdfmapline{=unisongsl@Unicode@ <LXGWNeoZhiSong.ttf}
  \pdfmapline{=unikaisl@Unicode@  <LXGWWenKaiLite-Regular.ttf}
  \pdfmapline{=uniheisl@Unicode@  <LXGWNeoXiHei.ttf}
  \pdfmapline{=unifssl@Unicode@   <LXGWZhuqueFangsong-Regular.ttf}
\fi
%    \end{macrocode}
% Configuration for \hologo{pdfTeX} (generate DVI).
%    \begin{macrocode}
\else
%    \end{macrocode}
% Configure the upright shape of \cs{songti}, \cs{kaishu}, \cs{heiti},
% and \cs{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 LXGWWenKaiLite-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 LXGWWenKaiLite-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 LXGWWenKaiLite-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 LXGWWenKaiLite-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| for l3docstrip.
%    \begin{macrocode}
%</zhmap>
%    \end{macrocode}
% \end{implementation}
% \clearpage
% \PrintIndex
