summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/ctex/ctexspamacro.tex
blob: 36a1535a247eaee5ca113d297c85452d442c0b23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%%
%% This is file `ctexspamacro.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex.dtx  (with options: `spa,macro')
%% 
%%     Copyright (C) 2003--2017
%%     CTEX.ORG and any individual authors listed in the documentation.
%% ------------------------------------------------------------------------------
%% 
%%     This work may be distributed and/or modified under the
%%     conditions of the LaTeX Project Public License, either
%%     version 1.3c of this license or (at your option) any later
%%     version. This version of this license is in
%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
%%     and the latest version of this license is in
%%        http://www.latex-project.org/lppl.txt
%%     and version 1.3 or later is part of all distributions of
%%     LaTeX version 2005/12/01 or later.
%% 
%%     This work has the LPPL maintenance status `maintained'.
%% 
%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
%% 
%% ------------------------------------------------------------------------------
%% 
\input expl3-generic %
\ExplSyntaxOn
\sys_if_engine_xetex:F
  {
    \msg_new:nn { ctex } { xetex }
      { XeTeX~is~required~to~compile~this~document! }
    \msg_fatal:nn { ctex } { xetex }
  }
\seq_new:N \c__ctex_punct_seq
\seq_gset_from_clist:Nn \c__ctex_punct_seq
  {
    "2018 , "201C , "300C , "300E , "3014 , "FF08 , "FF3B , "FF5B ,
    "3008 , "300A , "3016 , "3010 ,
    "2014 , "2026 , "3001 , "3002 , "FF0C , "FF0E , "FF1A , "FF1B ,
    "FF01 , "FF1F , "FF05 , "3015 , "FF09 , "FF3D , "FF5D , "3009 ,
    "300B , "3017 , "3011 , "2019 , "201D , "300D , "300F
  }
\cs_new_protected_nopar:Npn \ctex_make_spa:nn #1#2
  {
    \iow_open:Nn \g__ctex_spa_iow {#1}
    \clist_map_inline:nn {#2}
      { \__ctex_write_family:nn ##1 }
    \iow_close:N \g__ctex_spa_iow
  }
\iow_new:N \g__ctex_spa_iow
\cs_new_eq:NN \MAKESPA \ctex_make_spa:nn
\cs_new_protected:Npn \__ctex_write_family:nn #1#2
  {
    \group_begin:
      \tex_font:D \l__ctex_punct_font = "#2" ~ at ~ 100 pt \scan_stop:
      \l__ctex_punct_font
      \clist_clear:N \l__ctex_punct_bounds_clist
      \seq_map_inline:Nn \c__ctex_punct_seq
        { \exp_args:No \__ctex_save_bounds:n { \int_use:N \xetex_charglyph:D ##1 } }
      \iow_now:Nx \g__ctex_spa_iow
        {
          \token_to_str:N \ctexspadef {#1}
            { \l__ctex_punct_bounds_clist , , , }
        }
    \group_end:
  }
\cs_new_protected_nopar:Npn \__ctex_save_bounds:n #1
  {
    \clist_put_right:Nx \l__ctex_punct_bounds_clist
      {
        \__ctex_calc_bounds:nn { \c_one }   {#1} ,
        \__ctex_calc_bounds:nn { \c_three } {#1}
      }
  }
\clist_new:N \l__ctex_punct_bounds_clist
\cs_new_nopar:Npn \__ctex_calc_bounds:nn #1#2
  {
    \fp_eval:n
      {
        round
          (
            \dim_to_decimal_in_unit:nn
              { 100 \xetex_glyphbounds:D #1 ~ #2 }
              { 1 em }
          )
      }
  }
\ExplSyntaxOff
%% 
%%
%% End of file `ctexspamacro.tex'.