<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%     Copyright (C) 2020-2025 by Nan Geng &lt;nangeng@nwafu.edu.cn&gt;
%% --------------------------------------------------------------------------
%%
%%     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 Maintainer of this work is Nan Geng.
%%
%% --------------------------------------------------------------------------
%%
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{expl3}
\ProvidesExplPackage{circledtext}{2025-08-27}{v1.1.2}
  {Typeset circled text with l3draw}

\RequirePackage { xtemplate, l3keys2e, l3draw, xparse }

% 菫晁ｯゝeXLive逧�髄荳句�螳ｹ
\cs_if_free:NT \box_ht_plus_dp:N
  {
    \cs_new_protected:Npn \box_ht_plus_dp:N #1
      { \tex_dimexpr:D \box_ht:N #1 + \box_dp:N #1 \scan_stop: }
  }

% 蟶ｦ蝨域枚蟄礼畑謌ｷ謗･蜿｣
% #1 *蜿ｷ蜻ｽ莉､�悟ｮ樒鴫髦ｴ譁�
% #2 譬ｼ蠑城蛾｡ｹ
% #3 譁�ｭ�
\NewDocumentCommand{\circledtext}{ s O{} m }
  {
    \group_begin:
      \IfBooleanTF{ #1 }
        {
          \bool_set_true:N  \l__circledtext_negative_bool
        }{
          \bool_set_false:N \l__circledtext_negative_bool
        }
      \__circledtext_handle:nn { #2 } { #3 }
    \group_end:
  }

% 譏ｯ蜷ｦ蜿咲區譬�ｿ�
\bool_new:N   \l__circledtext_negative_bool

% 蝓ｺ蟄礼ｬｦ逶貞ｭ�
\box_new:N    \l__circledtext_basebox_box

% 蟄礼ｬｦ逶貞ｭ千ｱｻ蝙�
\tl_new:N     \l__circledtext_char_box_type_tl
% 蟄礼ｬｦ逶貞ｭ千ｱｻ蝙句�陦ｨ
\clist_new:N  \g__circledtext_char_box_list_clist

% 郛ｩ謾ｾ譁ｹ蠑�
\tl_new:N     \l__circledtext_resize_method_tl
% 郛ｩ謾ｾ譁ｹ蠑丞�陦ｨ
\clist_new:N  \g__circledtext_resize_method_clist

% 蝓ｺ蟄礼ｬｦ逶貞ｭ先ｭ｣譁ｹ蠖｢霑樣柄
\dim_new:N    \l__circledtext_char_box_size_dim
% 蝓ｺ蟄礼ｬｦ逶貞ｭ先ｭ｣譁ｹ蠖｢螟匁磁蝨�濠蠕�
\dim_new:N    \l__circledtext_char_box_radius_dim
% 蝓ｺ蟄礼ｬｦ螳ｽ蠎ｦ
\dim_new:N    \l__circledtext_char_width_dim
% 蝓ｺ蟄礼ｬｦ鬮伜ｺｦ
\dim_new:N    \l__circledtext_char_height_dim
% 蟄礼ｬｦ(荳ｲ)逶貞ｭ仙ｮｽ蠎ｦ
\dim_new:N    \l__circledtext_box_width_dim
% 蟄礼ｬｦ(荳ｲ)逶貞ｭ宣ｫ伜ｺｦ
\dim_new:N    \l__circledtext_box_height_dim
% 蟄礼ｬｦ(荳ｲ)螟匁｡�ｺｿ螳ｽ
\dim_new:N    \l__circledtext_box_linewidth_dim
% 蟄礼ｬｦ(荳ｲ)蜀�Κ蜊∝ｭ励∫ｱｳ蟄苓｣�･ｰ郤ｿ郤ｿ螳ｽ
\dim_new:N    \l__circledtext_cross_linewidth_dim
% 蟄礼ｬｦ(荳ｲ)豺ｱ蠎ｦ(蟶ｦ譬ｼ蠑�)
\dim_new:N    \l__circledtext_char_dp_dim

% 蟄礼ｬｦ(荳ｲ)逶貞ｭ仙ｮｹ蝎ｨ
\coffin_new:N \l__circledtext_str_box_coffin
% 蟄礼ｬｦ譯�將蟄仙ｮｹ蝎ｨ
\coffin_new:N \l__circledtext_box_coffin
% 蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ
\coffin_new:N \l__circledtext_char_coffin
% 荳ｴ譌ｶ逶貞ｭ仙ｮｹ蝎ｨ
\coffin_new:N \l__circledtext_tmpa_coffin
% 荳ｴ譌ｶ逶貞ｭ仙ｮｹ蝎ｨ
\coffin_new:N \l__circledtext_tmpb_coffin

% 蝓ｺ蟄礼ｬｦ螳ｽ蠎ｦ
\dim_new:N    \charboxwd
% 蝓ｺ蟄礼ｬｦ鬮伜ｺｦ
\dim_new:N    \charboxht

% 蠕�､�炊蟄礼ｬｦ(荳ｲ)
\tl_new:N     \l__circledtext_chars_tl
% 蟄礼ｬｦ(荳ｲ)謗堤沿譬ｼ蠑�
\tl_new:N     \l__circledtext_character_format_tl
% 蜀�Κ蜊∝ｭ励∫ｱｳ蟄苓｣�･ｰ郤ｿ鬚懆牡轤ｹ霎ｹ譯�｢懆牡豈比ｾ�
\int_new:N    \l__circledtext_cross_color_ratio_int
\int_set:Nn   \l__circledtext_cross_color_ratio_int { 30 }
% 蟄礼ｬｦ(荳ｲ)逧�ｭ怜ｽ｢邀ｻ蝙�(螳樒ｺｿ縲∬劒郤ｿ遲�)
\int_new:N    \l__circledtext_charstroke_type_int

% 蟄嶺ｽ楢�霄ｫ郛ｩ謾ｾ豈比ｾ�
\fp_new:N     \l__circledtext_char_shrink_fp

% 蝪ｫ蜈�牡霎�勧蜃ｽ謨ｰ
\cs_new_nopar:Nn \__circledtext_aux_color_boxfill:
  { }

% 逶貞ｭ千罰l3draw螳樒鴫��
% 隶ｾ隶｡諤晁ｷｯ蜥碁Κ蛻�ｺ千�∵擂閾ｪzitie螳丞桁(\url{https://www.ctan.org/pkg/zitie})縲�

% 鬚懆牡蜻ｽ蜷榊�謨ｰ
% #1 鬚懆牡蜷咲ｧｰ
% #2 鬚懆牡陦ｨ霎ｾ蠑�
\cs_set_nopar:Npn \__circledtext_color_select:nn #1#2
  {
    \color_set:nn {#1} {#2}
  }
\cs_generate_variant:Nn \__circledtext_color_select:nn {nx}

% 鬚懆牡蜻ｽ蜷榊�謨ｰ
% #1 鬚懆牡蜷咲ｧｰ
% #2 鬚懆牡遨ｺ髣ｴ
% #3 鬚懆牡蛻�㍼蛟ｼ
\cs_set_nopar:Npn \__circledtext_color_select:nnn #1#2#3
  {
    \color_set:nnn {#1} {#2} {#3}
  }
\cs_generate_variant:Nn \__circledtext_color_select:nnn {nnx}

% 隶｡邂怜渕蟄礼ｬｦ逧�ｮｽ蜥碁ｫ�
\cs_new:Npn \__circledtext_calc_basechar_w_h:
  {
    \dim_set:Nn \l__circledtext_char_width_dim
      {
        \box_wd:N \l__circledtext_basebox_box
      }
    \dim_set:Nn \l__circledtext_char_height_dim
      {
        \box_ht_plus_dp:N \l__circledtext_basebox_box
      }
  }

% 逶貞ｭ仙ｮｹ蝎ｨ諤ｻ鬮伜ｺｦ隶｡邂怜�謨ｰ
\cs_new_nopar:Npn \__circledtext_coffin_ht_plus_dp:N #1
  {
    \coffin_ht:N #1 + \coffin_dp:N #1
  }

% 隶｡邂怜渕蟄礼ｬｦ螟匁｡�､ｧ蟆�(螟匁磁豁｣譁ｹ蠖｢霎ｹ髟ｿ蜥悟､匁磁蝨�濠蠕�)
\cs_new:Npn \__circledtext_calc_char_box_size:
  {
    % 隶ｾ鄂ｮ蝓ｺ蟄礼ｬｦ譬ｼ蠑冗噪蝓ｺ蟄礼ｬｦ逶貞ｭ�
    \hbox_set:Nn \l_tmpa_box
      {
        \tl_use:N \l__circledtext_character_format_tl
        \tl_use:N \c__circledtext_basechar_tl
      }

    % 逶貞ｭ仙ｮｽ蠎ｦ
    \dim_set:Nn \l_tmpa_dim
      {
        \box_wd:N \l_tmpa_box
      }
    % 逶貞ｭ宣ｫ伜ｺｦ
    \dim_set:Nn \l_tmpb_dim
      {
        \box_ht_plus_dp:N \l_tmpa_box
      }

    % 逶貞ｭ先ｷｱ蠎ｦ
    \dim_set:Nn \l__circledtext_char_dp_dim
      {
        \box_dp:N \l_tmpa_box
      }

    % 豁｣譁ｹ蠖｢霎ｹ髟ｿ
    \dim_compare:nNnTF \l_tmpa_dim &gt; \l_tmpb_dim
      {
        \dim_set_eq:NN \l__circledtext_char_box_size_dim \l_tmpa_dim
      }
      {
        \dim_set_eq:NN \l__circledtext_char_box_size_dim \l_tmpb_dim
      }

    % 隶ｾ鄂ｮ蝓ｺ蟄礼ｬｦ逶貞ｭ先ｭ｣譁ｹ蠖｢螳ｽ蜥碁ｫ�(逶ｸ遲�)
    \dim_set_eq:NN \charboxwd \l__circledtext_char_box_size_dim
    \dim_set_eq:NN \charboxht \l__circledtext_char_box_size_dim

    % 螟匁磁蝨�濠蠕�
    \dim_set:Nn \l__circledtext_char_box_radius_dim
      {
        \fp_to_dim:n
          {
            \fp_eval:n { \l__circledtext_char_box_size_dim * sqrt(2)/ 2 }
          }
      }
  }

% 蟄礼ｬｦ逶貞ｭ先桷騾�邀ｻ蝙句�謨ｰ蜷咲ｧｰ逕滓�蜃ｽ謨ｰ
% 蜷咲ｧｰ荳ｭ6荳ｪ蜿よ焚蛻�悪陦ｨ遉ｺ��
% #1 蟾ｦ荳玖ｧ遅蝮先��
% #2 蟾ｦ荳玖ｧ馳蝮先��
% #3 蜿ｳ荳願ｧ遅蝮先��
% #4 蜿ｳ荳願ｧ馳蝮先��
% #5 x譁ｹ蜷醍ｼｩ謾ｾ豈比ｾ�(謇ｩ螻穂ｿ晉蕗蜿よ焚)
% #6 y譁ｹ蜷醍ｼｩ謾ｾ豈比ｾ�(謇ｩ螻穂ｿ晉蕗蜿よ焚)
\cs_new_nopar:Npn \__circledtext_char_box_type:n #1
  {
    __circledtext_char_box_construct_type_ #1 :nnnnnn
  }
% 蟄礼ｬｦ逶貞ｭ先桷騾�邀ｻ蝙句�謨ｰ蜷咲ｧｰ蜻ｽ莉､逕滓�蜃ｽ謨ｰ
% 蜷咲ｧｰ蜻ｽ莉､荳ｭ6荳ｪ蜿よ焚蛻�悪陦ｨ遉ｺ��
% #1 蟾ｦ荳玖ｧ遅蝮先��
% #2 蟾ｦ荳玖ｧ馳蝮先��
% #3 蜿ｳ荳願ｧ遅蝮先��
% #4 蜿ｳ荳願ｧ馳蝮先��
% #5 x譁ｹ蜷醍ｼｩ謾ｾ豈比ｾ�(謇ｩ螻穂ｿ晉蕗蜿よ焚)
% #6 y譁ｹ蜷醍ｼｩ謾ｾ豈比ｾ�(謇ｩ螻穂ｿ晉蕗蜿よ焚)
\cs_new_nopar:Npn \__circledtext_char_box_type_c:n #1
  {
    \use:c
      {
        __circledtext_char_box_construct_type_ #1 :nnnnnn
      }
  }

% 蟄礼ｬｦ逶貞ｭ先桷騾�邀ｻ蝙句�謨ｰ逕滓�蝎ｨ蜃ｽ謨ｰ
% #1 邀ｻ蝙句錐遘ｰ
\cs_new:Npn \__circledtext_new_char_box_construct:nn #1
  {
    % 蟆�ｱｻ蝙句錐遘ｰ隶ｰ蜈･clist
    \clist_put_right:Nn \g__circledtext_char_box_list_clist {#1}
    % 邀ｻ莨ｼ\cs_new:cn __circledtext_char_box_construct_type_none:nnnnnn
    \cs_new:cn { \__circledtext_char_box_type:n {#1} }
  }
\cs_generate_variant:Nn \__circledtext_new_char_box_construct:nn { V }
\cs_generate_variant:Nn \__circledtext_new_char_box_construct:nn { x }

% 螳壻ｹ牙ｭ礼ｬｦ霎ｹ譯�將蟄千ｱｻ蝙�

% 譌�霎ｹ譯�
\__circledtext_new_char_box_construct:nn { none } { }

% 蝪ｫ蜈�ｭ｣譁ｹ蠖｢
\__circledtext_new_char_box_construct:nn { __filledsquare }
  {
    \cs_if_eq:NNF \__circledtext_aux_color_boxfill: \c_empty_tl
      {
        \__circledtext_aux_color_boxfill:
        \draw_scope_begin:
          \bool_if:NTF \l__circledtext_negative_bool
            {
              \color_fill:n { circledtextcharcolor }
            }{
              \color_fill:n { circledtextboxfill   }
            }
          \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
          \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
          \draw_path_use_clear:n { fill }
        \draw_scope_end:
      }
  }

% 蜿崎牡蝪ｫ蜈�ｭ｣譁ｹ蠖｢
\__circledtext_new_char_box_construct:nn { __negfilledsquare }
  {
    \cs_if_eq:NNF \__circledtext_aux_color_boxfill: \c_empty_tl
      {
        \__circledtext_aux_color_boxfill:
        \draw_scope_begin:
          \bool_if:NTF \l__circledtext_negative_bool
            {
              \color_fill:n { circledtextboxfill   }
            }{
              \color_fill:n { circledtextcharcolor }
            }
          \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
          \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
          \draw_path_use_clear:n { fill }
        \draw_scope_end:
      }
  }

% 豁｣譁ｹ蠖｢蝪ｫ蜈��蛻�怕
\__circledtext_new_char_box_construct:nn { __innerfilledcircle }
  {
    \cs_if_eq:NNF \__circledtext_aux_color_boxfill: \c_empty_tl
      {
        \__circledtext_aux_color_boxfill:
        \draw_scope_begin:
          \bool_if:NTF \l__circledtext_negative_bool
            {
              \color_fill:n { circledtextcharcolor }
            }{
              \color_fill:n { circledtextboxfill   }
            }
          \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
          \draw_path_use_clear:n { fill }
        \draw_scope_end:
      }
  }

% 豁｣譁ｹ蠖｢蝪ｫ蜈�､匁磁蝨�
\__circledtext_new_char_box_construct:nn { __outerfilledcircle }
  {
    \cs_if_eq:NNF \__circledtext_aux_color_boxfill: \c_empty_tl
      {
        \__circledtext_aux_color_boxfill:
        \draw_scope_begin:
          \bool_if:NTF \l__circledtext_negative_bool
            {
              \color_fill:n { circledtextcharcolor }
            }{
              \color_fill:n { circledtextboxfill   }
            }
          \draw_path_circle:nn { #3/2, #4/2 } { \l__circledtext_char_box_radius_dim*#5 }
          \draw_path_use_clear:n { fill }
        \draw_scope_end:
      }
  }

% 譌�蜿崎牡蠎募ｱょ｡ｫ蜈�ｭ｣譁ｹ蠖｢
\__circledtext_new_char_box_construct:nn { __lowerfilledsquare }
  {
    \draw_scope_begin:
      \color_fill:n { lowerbgboxfill   }
      \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
      \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡荳雁ｱょ｡ｫ蜈�ｭ｣譁ｹ蠖｢
\__circledtext_new_char_box_construct:nn { __upperfilledsquare }
  {
    \draw_scope_begin:
      \color_fill:n { upperbgboxfill   }
      \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
      \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡髦ｴ蠖ｱ蝪ｫ蜈�ｭ｣譁ｹ蠖｢
\__circledtext_new_char_box_construct:nn { __shadowfilledsquare }
  {
    \draw_scope_begin:
      \color_fill:n { shadowboxfill   }
      \draw_transform_shift:n { (#3-#3*#5)/2 + \charboxwd * 0.1,
                                (#4-#4*#6)/2 - \charboxht * 0.1 }
      \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡蠎募ｱょ｡ｫ蜈��蛻�怕
\__circledtext_new_char_box_construct:nn { __innerlowerfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { lowerbgboxfill   }
      \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡荳雁ｱょ｡ｫ蜈��蛻�怕
\__circledtext_new_char_box_construct:nn { __innerupperfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { upperbgboxfill   }
      \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡髦ｴ蠖ｱ蝪ｫ蜈��蛻�怕
\__circledtext_new_char_box_construct:nn { __innershadowfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { shadowboxfill   }
      \draw_transform_shift:n { \charboxwd*0.1, -\charboxht*0.1 }
      \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡蠎募ｱょ｡ｫ蜈�､匁磁蝨�
\__circledtext_new_char_box_construct:nn { __outerlowerfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { lowerbgboxfill   }
      \draw_path_circle:nn { #3/2, #4/2 }
        { \l__circledtext_char_box_radius_dim*#5 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡荳雁ｱょ｡ｫ蜈�､匁磁蝨�
\__circledtext_new_char_box_construct:nn { __outerupperfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { upperbgboxfill   }
      \draw_path_circle:nn { #3/2, #4/2 }
        { \l__circledtext_char_box_radius_dim*#5 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 譌�蜿崎牡髦ｴ蠖ｱ蝪ｫ蜈�､匁磁蝨�
\__circledtext_new_char_box_construct:nn { __outershadowfilledcircle }
  {
    \draw_scope_begin:
      \color_fill:n { shadowboxfill   }
      \draw_transform_shift:n { \charboxwd*0.1, -\charboxht*0.1 }
      \draw_path_circle:nn { #3/2, #4/2 }
        { \l__circledtext_char_box_radius_dim*#5 }
      \draw_path_use_clear:n { fill }
    \draw_scope_end:
  }

% 豁｣譁ｹ蠖｢霎ｹ譯�
\__circledtext_new_char_box_construct:nn { __squarebox }
  {
    \draw_scope_begin:
      \color_stroke:n { circledtextcharboxcolor   }
      \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
      \draw_path_rectangle:nn { #1, #2 } { #3*#5, #4*#6 }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 豁｣譁ｹ蠖｢蜀��蝨�ｾｹ譯�
\__circledtext_new_char_box_construct:nn { __innercirclebox }
  {
    \__circledtext_aux_color_boxfill:
    \draw_scope_begin:
      \color_stroke:n { circledtextcharboxcolor   }
      \draw_path_circle:nn { #3/2, #4/2 } { #3*#5/2 }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 豁｣譁ｹ蠖｢螟匁磁蝨�ｾｹ譯�
\__circledtext_new_char_box_construct:nn { __outercirclebox }
  {
    \draw_scope_begin:
      \color_stroke:n { circledtextcharboxcolor }
      \draw_path_circle:nn { #3/2, #4/2 }
        { \l__circledtext_char_box_radius_dim*#5 }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 豁｣譁ｹ蠖｢譁懷香蟄礼ｺｿ(豁｣譁ｹ蠖｢蟇ｹ隗定ｿ樒ｺｿ)
\__circledtext_new_char_box_construct:nn { __dcross }
  {
    \draw_scope_begin:
      \tl_if_empty:NF \l__circledtext_dash_pattern_tl
        {
          \exp_args:No \draw_set_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_set_linewidth:n{ \l__circledtext_cross_linewidth_dim }
      \color_stroke:n { circledtextcrosscolor }
      \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
      \draw_path_moveto:n { #1   ,    #2 }
      \draw_path_lineto:n { #3*#5, #4*#6 }
      \draw_path_moveto:n { #1   , #4*#6 }
      \draw_path_lineto:n { #3   , #2*#5 }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 豁｣譁ｹ蠖｢豁｣蜊∝ｭ礼ｺｿ(豁｣譁ｹ蠖｢蟇ｹ霎ｹ荳ｭ轤ｹ霑樒ｺｿ)
\__circledtext_new_char_box_construct:nn { __scross }
  {
    \draw_scope_begin:
      \tl_if_empty:NF \l__circledtext_dash_pattern_tl
        {
          \exp_args:No \draw_set_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_set_linewidth:n{ \l__circledtext_cross_linewidth_dim }
      \color_stroke:n { circledtextcrosscolor }
      \draw_transform_shift:n { (#3-#3*#5)/2, (#4-#4*#6)/2 }
      \draw_path_moveto:n { #3*#5/2,      #2 }
      \draw_path_lineto:n { #3*#5/2,   #4*#6 }
      \draw_path_moveto:n { #1     , #4*#6/2 }
      \draw_path_lineto:n { #3*#5  , #4*#6/2 }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 蜀��蝨�万蜊∝ｭ礼ｺｿ(髴隕∵ｱゆｺ､轤ｹ)
\__circledtext_new_char_box_construct:nn { __innerdcross }
  {
    \draw_scope_begin:
      \tl_if_empty:NF \l__circledtext_dash_pattern_tl
        {
          \exp_args:No \draw_set_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_set_linewidth:n{ \l__circledtext_cross_linewidth_dim }
      \color_stroke:n { circledtextcrosscolor }
      \draw_path_moveto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #2 } % line's first point
            { #3, #4 } % line's second point
            { #3/2, #4/2 } { #3*#5/2 }
            {1}  % index of intersect
        }
      \draw_path_lineto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #2 } % line's first point
            { #3, #4 } % line's second point
            { #3/2, #4/2 } { #3*#5/2 }
            {2}  % index of intersect
        }
      \draw_path_moveto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #4 } % line's first point
            { #3, #2 } % line's second point
            { #3/2, #4/2 } { #3*#5/2 }
            {1}  % index of intersect
        }
      \draw_path_lineto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #4 } % line's first point
            { #3, #2 } % line's second point
            { #3/2, #4/2 } { #3*#5/2 }
            {2}  % index of intersect
        }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 螟匁磁蝨�ｭ｣蜊∝ｭ礼ｺｿ(髴隕∵ｱゆｺ､轤ｹ)
\__circledtext_new_char_box_construct:nn { __outercross }
  {
    \draw_scope_begin:
      \tl_if_empty:NF \l__circledtext_dash_pattern_tl
        {
          \exp_args:No \draw_set_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_set_linewidth:n{ \l__circledtext_cross_linewidth_dim }
      \color_stroke:n { circledtextcrosscolor }
      \draw_path_moveto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #3/2, #2 } % line's first point
            { #3/2, #4 } % line's second point
            { #3/2, #4/2 } { \l__circledtext_char_box_radius_dim*#5 }
            {1}  % index of intersect
        }
      \draw_path_lineto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #3/2, #2 } % line's first point
            { #3/2, #4 } % line's second point
            { #3/2, #4/2 } { \l__circledtext_char_box_radius_dim*#5 }
            {2}  % index of intersect
        }
      \draw_path_moveto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #4/2 } % line's first point
            { #3, #4/2 } % line's second point
            { #3/2, #4/2 } { \l__circledtext_char_box_radius_dim*#5 }
            {1}  % index of intersect
        }
      \draw_path_lineto:n
        {
          \draw_point_intersect_line_circle:nnnnn
            { #1, #4/2 } % line's first point
            { #3, #4/2 } % line's second point
            { #3/2, #4/2 } { \l__circledtext_char_box_radius_dim*#5 }
            {2}  % index of intersect
        }
      \draw_path_use_clear:n { stroke }
    \draw_scope_end:
  }

% 蝪ｫ蜈��蛻�怕蜿�蜉�蜀��蝨�ｾｹ譯�
\__circledtext_new_char_box_construct:nn { o }
  {
    \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
  }

% 蝪ｫ蜈��蛻�怕蜿�蜉�豁｣譁ｹ蠖｢豁｣蜊∝ｭ礼ｺｿ荳主�蛻�怕霎ｹ譯�
\clist_map_variable:nNn {o+,+o} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蝪ｫ蜈��蛻�怕蜿�蜉�蜀��蝨�万蜊∝ｭ礼ｺｿ荳主�蛻�怕霎ｹ譯�
\clist_map_variable:nNn {ox,xo} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蝪ｫ蜈��蛻�怕蜿�蜉�蜀��蝨�ｭ｣譁懷香蟄礼ｺｿ荳主�蛻�怕霎ｹ譯�
\clist_map_variable:nNn {ox+,o+x,xo+,x+o,+ox,+xo} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn  \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蜀��蝨�万蜊∝ｭ礼ｺｿ蜿�蜉�豁｣蜊∝ｭ礼ｺｿ
\clist_map_variable:nNn {x+,+x} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __innerdcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蝪ｫ蜈�ｭ｣譁ｹ蠖｢蜿�蜉�豁｣譁ｹ蠖｢霎ｹ譯�
\__circledtext_new_char_box_construct:nn { O }
  {
    \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
  }

% 蝪ｫ蜈�ｭ｣譁ｹ蠖｢蜿�蜉�豁｣譁ｹ蠖｢豁｣蜊∝ｭ礼ｺｿ荳取ｭ｣譁ｹ蠖｢霎ｹ譯�
\clist_map_variable:nNn {O+,+O} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蝪ｫ蜈�ｭ｣譁ｹ蠖｢蜿�蜉�豁｣譁ｹ蠖｢譁懷香蟄礼ｺｿ荳取ｭ｣譁ｹ蠖｢霎ｹ譯�
\clist_map_variable:nNn {OX,XO} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蝪ｫ蜈�ｭ｣譁ｹ蠖｢蜿�蜉�豁｣譁ｹ蠖｢譁懈ｭ｣蜊∝ｭ礼ｺｿ荳取ｭ｣譁ｹ蠖｢霎ｹ譯�
\clist_map_variable:nNn {OX+,O+X,XO+,X+O,+OX,+XO} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 豁｣譁ｹ蠖｢譁懷香蟄礼ｺｿ蜿�蜉�豁｣蜊∝ｭ礼ｺｿ
\clist_map_variable:nNn {X+,+X} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __dcross } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __scross } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 蜀��蝨�匠蜉�蜷悟ｿ�82%蜀��蝨�ｾｹ譯�
\__circledtext_new_char_box_construct:nn { oo }
  {
    \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __innercirclebox } {#1} {#2} {#3} {#4} {0.82} {0.82}
  }

% 蜿崎牡豁｣譁ｹ蠖｢蜿�蜉�蜀��蝪ｫ蜈�怕
\clist_map_variable:nNn {Oo,oO} \l_tmpa_tl
  {
    \__circledtext_new_char_box_construct:Vn \l_tmpa_tl
      {
        \__circledtext_char_box_type_c:n { __negfilledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __innerfilledcircle } {#1} {#2} {#3} {#4} {#5} {#6}
        \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
      }
  }

% 豁｣譁ｹ蠖｢蜿�蜉�蜷悟ｿ�82%豁｣譁ｹ蠖｢霎ｹ譯�
\__circledtext_new_char_box_construct:nn { OO }
  {
    \__circledtext_char_box_type_c:n { __filledsquare } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {#5} {#6}
    \__circledtext_char_box_type_c:n { __squarebox } {#1} {#2} {#3} {#4} {0.82} {0.82}
  }

% 3蜷悟ｿ�怕蜿�蜉�(邀ｻ莨ｼ荳ｭ蝗ｽ雎｡譽区｣句ｭ仙ｽ｢迥ｶ)
\__circledtext_new_char_box_construct:nn { ooo }
  {
    % 扈伜宛蝪ｫ蜈�､匁磁蝨�亢蠖ｱ
    \__circledtext_char_box_type_c:n { __outershadowfilledcircle }
                                       {#1} {#2} {#3} {#4} {1.0} {1.0}
    % 扈伜宛蝪ｫ蜈�､匁磁蝨�､門怦閭梧勹
    \__circledtext_char_box_type_c:n { __outerlowerfilledcircle }
                                     {#1} {#2} {#3} {#4} {#5} {#6}
    % 扈伜宛蝪ｫ蜈�､匁磁霎ｹ邇ｯ閭梧勹
    \__circledtext_char_box_type_c:n { __outerupperfilledcircle }
                                     {#1} {#2} {#3} {#4} {0.88} {0.88}
    % 扈伜宛蝪ｫ蜈�､匁磁蝨��蝨郁レ譎ｯ
    \__circledtext_char_box_type_c:n { __outerlowerfilledcircle }
                                     {#1} {#2} {#3} {#4} {0.72} {0.72}
    % 扈伜宛蜿瑚ｾｹ蛻ｻ邇ｯ郤ｿ
    \__circledtext_char_box_type_c:n { __outercirclebox }
                                     {#1} {#2} {#3} {#4} {0.88} {0.88}
    \__circledtext_char_box_type_c:n { __outercirclebox }
                                     {#1} {#2} {#3} {#4} {0.72} {0.72}

  }

% 3蜷悟ｿ�ｭ｣譁ｹ蠖｢蜿�蜉�
\__circledtext_new_char_box_construct:nn { OOO }
  {
    % 扈伜宛蝪ｫ蜈�ｭ｣譁ｹ蠖｢髦ｴ蠖ｱ
    \__circledtext_char_box_type_c:n { __shadowfilledsquare }
                                       {#1} {#2} {#3} {#4} {1.0} {1.0}
    % 扈伜宛蝪ｫ蜈�ｭ｣譁ｹ蠖｢螟門怦閭梧勹
    \__circledtext_char_box_type_c:n { __lowerfilledsquare}
                                     {#1} {#2} {#3} {#4} {#5} {#6}
    % 扈伜宛蝪ｫ蜈�ｭ｣譁ｹ蠖｢霎ｹ邇ｯ閭梧勹
    \__circledtext_char_box_type_c:n { __upperfilledsquare}
                                     {#1} {#2} {#3} {#4} {0.88} {0.88}
    % 扈伜宛蝪ｫ蜈�ｭ｣譁ｹ蠖｢蜀�怦閭梧勹
    \__circledtext_char_box_type_c:n { __lowerfilledsquare}
                                     {#1} {#2} {#3} {#4} {0.72} {0.72}
    % 扈伜宛蜿瑚ｾｹ蛻ｻ邇ｯ郤ｿ
    \__circledtext_char_box_type_c:n { __squarebox }
                                     {#1} {#2} {#3} {#4} {0.88} {0.88}
    \__circledtext_char_box_type_c:n { __squarebox }
                                     {#1} {#2} {#3} {#4} {0.72} {0.72}

  }

\msg_new:nnn { circledtext } { box-exists } { The~ box~ type~ `#1~ not~ exists. }

% 郛ｩ謾ｾ邀ｻ蝙句錐遘ｰ逕滓�蜃ｽ謨ｰ
\cs_new_nopar:Npn \__circledtext_resize:n #1
  {
    __circledtext_processor_resize_ #1 :w
  }

% 郛ｩ謾ｾ邀ｻ蝙句�謨ｰ蜷咲ｧｰ蜻ｽ莉､逕滓�蜃ｽ謨ｰ
\cs_new_nopar:Npn \__circledtext_resize_c:n #1
  {
    \use:c
      {
        __circledtext_processor_resize_ #1 :w
      }
  }

% 郛ｩ謾ｾ莉｣遐∫函謌仙�謨ｰ
% #1 dim髟ｿ蠎ｦ蜿倬㍼1
% #2 dim髟ｿ蠎ｦ蜿倬㍼2
% #3 郛ｩ謾ｾ莉｣遐�1
% #4 郛ｩ謾ｾ莉｣遐�2
% #5 郛ｩ謾ｾ莉｣遐�3
% 螯よ棡 #1 &gt; 0           �悟叙#3莉｣遐�
% 螯よ棡 #1 &lt;= 0 荳�#2 &gt; 0 �悟叙#4莉｣遐�
% 螯よ棡 #1 &lt;= 0 荳�#2 &lt;= 0�悟叙#5莉｣遐�
\cs_new:Npn \__circledtext_dim_gezero_dispatch:NNnnn #1#2 #3#4#5
  {
    \dim_compare:nNnTF #1 &gt; \c_zero_dim
      { #3 }
      {
        \dim_compare:nNnTF #2 &gt; \c_zero_dim
          { #4 } { #5 }
      }
  }

% 郛ｩ謾ｾ莉｣遐∫函謌仙�謨ｰ
% #1 dim髟ｿ蠎ｦ蜿倬㍼1
% #2 dim髟ｿ蠎ｦ蜿倬㍼2
% #3 郛ｩ謾ｾ莉｣遐�1
% #4 郛ｩ謾ｾ莉｣遐�2
% #5 郛ｩ謾ｾ莉｣遐�3
% #6 郛ｩ謾ｾ莉｣遐�4
% 螯よ棡 #1 &gt; 0  荳� #2 &gt; 0 �悟叙#3莉｣遐�
% 螯よ棡 #1 &gt; 0  荳� #2 &lt;= 0�悟叙#4莉｣遐�
% 螯よ棡 #1 &lt;= 0 荳� #2 &gt; 0 �悟叙#5莉｣遐�
% 螯よ棡 #1 &lt;= 0 荳� #2 &lt;= 0�悟叙#6莉｣遐�
\cs_new:Npn \__circledtext_dim_gezero_dispatch:NNnnnn #1#2 #3#4#5#6
  {
    \dim_compare:nNnTF #1 &gt; \c_zero_dim
      {
        \dim_compare:nNnTF #2 &gt; \c_zero_dim
          { #3 } { #4 }
      }
      {
        \dim_compare:nNnTF #2 &gt; \c_zero_dim
          { #5 } { #6 }
      }
  }

% 郛ｩ謾ｾ莉｣遐∫函謌仙�謨ｰ(蛻�悪謖蛾ｫ伜ｺｦ縲∝ｮｽ蠎ｦ謌門ｮ樣刔蟆ｺ蟇ｸ郛ｩ謾ｾ)
\cs_new:Npn \__circledtext_force_size_dispatch:nnn % height, width, none
  {
    \__circledtext_dim_gezero_dispatch:NNnnn \l__circledtext_height_dim
      \l__circledtext_width_dim
  }

% 郛ｩ謾ｾ莉｣遐∫函謌仙�謨ｰ(蛻�悪謖蛾ｫ伜ｮｽ縲�ｫ伜ｺｦ縲∝ｮｽ蠎ｦ謌門ｮ樣刔蟆ｺ蟇ｸ郛ｩ謾ｾ)
\cs_new:Npn \__circledtext_force_size_dispatch:nnnn % both, height, width, none
  {
    \__circledtext_dim_gezero_dispatch:NNnnnn \l__circledtext_box_height_dim
      \l__circledtext_box_width_dim
  }

% 譫��郛ｩ謾ｾ邀ｻ蝙�
\cs_new:Npn \__circledtext_new_resize_method:nn #1
  {
    \clist_put_right:Nn \g__circledtext_resize_method_clist {#1}
    \cs_new:cpn { \__circledtext_resize:n {#1} }
  }

% 譌�郛ｩ謾ｾ
\__circledtext_new_resize_method:nn { none } { }

% 謖牙ｮ樣刔蜿よ焚郛ｩ謾ｾ
\__circledtext_new_resize_method:nn { real }
  {
    \__circledtext_force_size_dispatch:nnnn
      {% 逶貞ｭ仙ｮｽ鬮倡ｼｩ謾ｾ
        \coffin_resize:Nnn \l__circledtext_box_coffin
                           \l__circledtext_box_width_dim
                           \l__circledtext_box_height_dim
      }
      {% 謖�ｮ夐ｫ伜ｺｦ荳ｺ豈比ｾ狗ｼｩ謾ｾ
        \coffin_scale:Nnn \l__circledtext_box_coffin
          {
            \dim_ratio:nn { \l__circledtext_box_height_dim }
                          { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
          }
          {
            \dim_ratio:nn { \l__circledtext_box_height_dim }
                          { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
          }
      }
      {% 謖�ｮ壼ｮｽ蠎ｦ荳ｺ豈比ｾ狗ｼｩ謾ｾ
        \coffin_scale:Nnn \l__circledtext_box_coffin
          {
            \dim_ratio:nn { \l__circledtext_box_width_dim }
                          { \coffin_wd:N \l__circledtext_box_coffin }
          }
          {
            \dim_ratio:nn { \l__circledtext_box_width_dim }
                          { \coffin_wd:N \l__circledtext_box_coffin }
          }
      }
      {% 螳樣刔螳ｽ縲�ｫ俶ｯ比ｾ狗ｼｩ謾ｾ
        \coffin_scale:Nnn \l__circledtext_box_coffin
                          { \l__circledtext_x_scale_tl }
                          { \l__circledtext_y_scale_tl }
      }
  }

% 謖牙渕蟄礼ｬｦ蜿よ焚郛ｩ謾ｾ
\__circledtext_new_resize_method:nn { base }
  {
    \__circledtext_force_size_dispatch:nnnn
      {% 謖画欠螳夂將蟄仙ｮｽ鬮倡ｼｩ謾ｾ
        \coffin_resize:Nnn \l__circledtext_box_coffin
                           \l__circledtext_box_width_dim
                           \l__circledtext_box_height_dim
      }
      {% 蝓ｺ蟄礼ｬｦ螳ｽ鬮倅ｹ倅ｻ･鬮伜ｺｦ豈比ｾ狗ｼｩ謾ｾ
        \coffin_resize:Nnn \l__circledtext_box_coffin
           {
             \l__circledtext_char_width_dim * \dim_ratio:nn { \l__circledtext_box_height_dim }
               { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
           }
           {
             \l__circledtext_box_height_dim
           }
      }
      {% 蝓ｺ蟄礼ｬｦ螳ｽ鬮倅ｹ倅ｻ･螳ｽ蠎ｦ豈比ｾ狗ｼｩ謾ｾ
        \coffin_resize:Nnn \l__circledtext_box_coffin
           {
             \l__circledtext_box_width_dim
           }
           {
             \l__circledtext_char_height_dim * \dim_ratio:nn { \l__circledtext_box_width_dim }
               { \coffin_wd:N \l__circledtext_box_coffin }
           }
      }
      {% 蝓ｺ蟄礼ｬｦ荵俶ｯ比ｾ狗ｳｻ謨ｰ蜷守ｼｩ謾ｾ
        \coffin_resize:Nnn \l__circledtext_box_coffin
           {
             \l__circledtext_x_scale_tl \l__circledtext_char_width_dim
           }
           {
             \l__circledtext_y_scale_tl \l__circledtext_char_height_dim
           }
      }
  }
\msg_new:nnn { circledtext } { resize-type } { using~ `#1'~ resize. }

% 隨皮判隶ｾ鄂ｮ蜃ｽ謨ｰ
\cs_new:Npn \__circledtext_chars_stroke:nn #1#2
  {
    \special { pdf:code ~ q ~ #1 } #2 \special { pdf:code ~ Q }
  }
% 隨皮判譫��蜃ｽ謨ｰ
\cs_new_protected:Npn \__circledtext_chars_stroke_construct:n #1
  {
    \int_case:nn {\l__circledtext_charstroke_type_int}
      {
        {1}{ #1 }
        {2}{
          \__circledtext_chars_stroke:nn { 1 ~ Tr ~ 0.10 ~ w ~ [] ~ 0 ~ d ~ 1 ~ J } {#1}
        }
        {3}{
          \__circledtext_chars_stroke:nn { 1 ~ Tr ~ 0.10 ~ w ~ [1~1] ~ 0 ~ d ~ 1 ~ J } {#1}
        }
        {4}{
          \__circledtext_chars_stroke:nn { 3 ~ Tr } {#1}
        }

      }
  }
\cs_generate_variant:Nn  \__circledtext_chars_stroke_construct:n { V }
\cs_generate_variant:Nn  \__circledtext_chars_stroke_construct:n { x }

% key_value騾蛾｡ｹ隶ｾ隶｡
\keys_define:nn { circledtext }
  {
    % 蝓ｺ蟄礼ｬｦ
    basechar  .code:n = { \tl_gset:Nx \c__circledtext_basechar_tl {#1}
                          \__circledtext_calc_basechar_w_h:
                        },
    % 蟄礼ｬｦ譬ｼ蠑�
    charf .code:n = { \tl_gset:Nn \l__circledtext_character_format_tl {#1}
                      \__circledtext_calc_char_box_size:
                    },
    % charf .initial:n = \normalsize ,
    % 霎ｹ譯�ｱｻ蝙�
    boxtype .code:n = { \exp_args:NNx \clist_if_in:NnTF
                            \g__circledtext_char_box_list_clist {#1}
                            { \tl_set:Nx \l__circledtext_char_box_type_tl {#1} }
                            { \msg_error:nnx { circledtext } { box-exists } {#1} }
                        % \__circledtext_calc_char_box_size:
                      },
    % 郛ｩ謾ｾ譁ｹ蠑�
    resize    .code:n = { \exp_args:NNx \clist_if_in:NnTF
                            \g__circledtext_resize_method_clist {#1}
                            { \tl_set:Nx \l__circledtext_resize_method_tl {#1} }
                            { \msg_error:nnx { circledtext } { resize-method } {#1} }
                        },
    % 郛ｩ謾ｾ蜿よ焚
    xscale .tl_set:N = \l__circledtext_x_scale_tl ,
    xscale .initial:n = 1 ,
    yscale .tl_set:N = \l__circledtext_y_scale_tl ,
    yscale .initial:n = 1 ,
    scale  .meta:n = { xscale = #1 , yscale = #1 } ,
    width  .dim_set:N = \l__circledtext_box_width_dim ,
    height .dim_set:N = \l__circledtext_box_height_dim ,

    % 蟄礼ｬｦ霎ｹ譯�ｺｿ螳ｽ
    boxlinewidth .dim_set:N = \l__circledtext_box_linewidth_dim ,
    boxlinewidth .initial:n = 0.4pt ,
    % 蜊∝ｭ礼ｺｿ郤ｿ螳ｽ
    crosslinewidth .dim_set:N = \l__circledtext_cross_linewidth_dim ,
    crosslinewidth .initial:n = 0.3pt ,

    % 霎ｹ譯�ｺｿ鬚懆牡
    boxcolor  .code:n = { \tl_set:Nx \l_tmpa_tl {
                          #1 ! \int_use:N \l__circledtext_cross_color_ratio_int }
                          \__circledtext_color_select:nn { circledtextcharboxcolor } {#1}
                          \__circledtext_color_select:nx { circledtextcrosscolor }
                                                         { \l_tmpa_tl }
                        } ,
    boxcolor  .initial:n = black ,
    boxcolor* .code:n = { \tl_set:Nx \l_tmpa_tl {
                          #1 ! \int_use:N \l__circledtext_cross_color_ratio_int }
                          \__circledtext_color_select:nnn { circledtextcharboxcolor } #1
                          \__circledtext_color_select:nnx { circledtextcrosscolor }
                                                          \l_tmpa_tl
                        } ,
    % 蜊∝ｭ礼ｺｿ鬚懆牡轤ｹ霎ｹ譯�｢懆牡逧�ｯ比ｾ�(蠢�｡ｻ蝨ｨboxcolor蜷�)
    crosscolorratio  .code:n = { \int_set:Nn \l__circledtext_cross_color_ratio_int { #1 }
                                 \__circledtext_color_select:nn { circledtextcrosscolor }
                                   { circledtextcharboxcolor ! #1 }
                               },
    crosscolorratio  .initial:n = 30,

    % 蟄礼ｬｦ鬚懆牡
    charcolor  .code:n = { \__circledtext_color_select:nn { circledtextcharcolor } {#1}
                           \tl_if_eq:nnT { #1 } { black }
                             {
                               \__circledtext_color_select:nn { circledtextboxfill }
                                                          { white }
                               \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                  { \color_fill:n { white } }
                             }
                         } ,
    charcolor  .initial:n = black ,
    charcolor* .code:n = { \__circledtext_color_select:nnn { circledtextcharcolor } #1 } ,
    color  .meta:n = { boxcolor = #1, crosscolor = #1,  charcolor = #1 } ,
    color* .meta:n = { boxcolor* = #1, crosscolor = #1,  charcolor* = #1 } ,
    % 蟄礼ｬｦ逶貞ｭ占レ譎ｯ蝪ｫ蜈�｢懆牡
    boxfill  .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
                           {
                             \__circledtext_color_select:nn { circledtextboxfill }
                                                        { white }
                             \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                { \color_fill:n { white } }
                           }{ \__circledtext_color_select:nn { circledtextboxfill } {#1}
                              \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                { \color_fill:n {#1} }
                           }
                        } ,
    boxfill  .initial:n = {} ,
    boxfill* .code:n = { \__circledtext_color_select:nnn { circledtextboxfill } #1
                           \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                             { \color_fill:nn #1 }
                         } ,

    % 譌�蜿崎牡譌ｶ蠎募ｱら將蟄占レ譎ｯ蝪ｫ蜈�｢懆牡
    lowerbgcolor  .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
                                {
                                  \__circledtext_color_select:nn { lowerbgboxfill }
                                    { yellow!70!red }
                                  \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                    { \color_fill:n { yellow!70!red } }
                                }{ \__circledtext_color_select:nn { lowerbgboxfill } { #1 }
                                  \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                    { \color_fill:n { #1 } }
                                }
                            } ,
    lowerbgcolor  .initial:n = {} ,

    % 譌�蜿崎牡譌ｶ荳雁ｱら將蟄占レ譎ｯ蝪ｫ蜈�｢懆牡
    upperbgcolor  .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
                                {
                                  \__circledtext_color_select:nn { upperbgboxfill }
                                    { yellow!80!black }
                                  \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                    { \color_fill:n { yellow!80!black } }
                                }{ \__circledtext_color_select:nn { upperbgboxfill } { #1 }
                                  \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                    { \color_fill:n { #1 } }
                                }
                            } ,
    upperbgcolor  .initial:n = {} ,

    % 逶貞ｭ宣亢蠖ｱ蝪ｫ蜈�｢懆牡
    shadowcolor  .code:n = { \exp_args:Nx \tl_if_empty:nTF {#1}
                               {
                                 \__circledtext_color_select:nn { shadowboxfill }
                                   { black!35!white }
                                 \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                   { \color_fill:n { black!35!white } }
                               }{ \__circledtext_color_select:nn { shadowboxfill } { #1 }
                                 \cs_set_nopar:Npn \__circledtext_aux_color_boxfill:
                                   { \color_fill:n { #1 } }
                               }
                            } ,
    shadowcolor  .initial:n = {} ,

    % 隨皮判蜿よ焚
    charstroke .choice:,
    charstroke .value_required:n = true,
    charstroke .choices:nn =
      { none, solid, dashed, invisible }
      { \int_set_eq:NN \l__circledtext_charstroke_type_int \l_keys_choice_int },
    charstroke .initial:n = none,
    % 陌夂ｺｿ譬ｷ蠑�
    dashpattern .tl_set:N = \l__circledtext_dash_pattern_tl ,
    dashpattern .initial:n = { } ,

    % 蟄礼ｬｦ閾ｪ霄ｫ郛ｩ謾ｾ豈比ｾ�
    charshrink  .fp_set:N  = \l__circledtext_char_shrink_fp ,
    charshrink  .initial:n = 0.75,

    unknown .code:n = { \msg_error:nn { circledtext } { unknown-option } }
  }
\msg_new:nnn { circledtext } { unknown-option }
  { package~ option~ "\l_keys_key_tl"~ is~ unknown. }

% 譬ｹ謐ｮ郛冶ｯ大ｼ墓梼隶ｾ鄂ｮ蝓ｺ蟄礼ｬｦ
\sys_if_engine_xetex:TF
  {
    \keys_set:nn { circledtext }
      {
        basechar = 螂ｽ,
      }
  }{
    \sys_if_engine_luatex:TF
      {
        \keys_set:nn { circledtext }
          {
            basechar = 螂ｽ,
          }
      }{
        \keys_set:nn { circledtext }
          {
            basechar = x,
          }
      }
  }

\keys_set:nn { circledtext }
  {
    charf    = \normalsize,
    boxtype  = o,
    resize   = none,
  }

% 騾蛾｡ｹ隶ｾ鄂ｮ逕ｨ謌ｷ謗･蜿｣
\NewDocumentCommand \circledtextset { m }
  {
    \keys_set:nn { circledtext } {#1}
  }

% 譫�ｻｺ蟄礼ｬｦ逶貞ｭ撰ｼ悟ｦょｭ礼ｬｦ荳ｺ遨ｺ�悟�逕ｨ蝓ｺ蟄礼ｬｦ譫��
% #1 髴隕∝､�炊逧�ｭ礼ｬｦ(荳ｲ)
\cs_new:Npn \__circledtext_single_char_construct:N #1
  {
    \tl_if_empty:NTF #1
      {
        \hcoffin_set:Nn \l__circledtext_char_coffin
          {
            \__circledtext_single_handle:N \c__circledtext_basechar_tl
          }
      }{
        \hcoffin_set:Nn \l__circledtext_char_coffin
          {
            \__circledtext_single_handle:N #1
          }
      }
  }

% 譫�ｻｺ蟶ｦ蝨域枚蟄怜�驛ｨ蜃ｽ謨ｰ
% #1 騾蛾｡ｹ蜀�ｮｹ
% #2 髴隕∝､�炊逧�ｭ礼ｬｦ(荳ｲ)
\cs_new:Npn \__circledtext_handle:nn #1#2
  {
    \group_begin:
      % 騾蛾｡ｹ隶ｾ鄂ｮ
      \keys_set:nn { circledtext } { #1 }

      % 隶ｾ鄂ｮ蟄礼ｬｦ荳ｲ
      \tl_gset:Nx \l__circledtext_chars_tl {#2}

      % 譫��逶貞ｭ�
      \__circledtext_single_char_construct:N \l__circledtext_chars_tl

      % 螟榊宛逶貞ｭ仙㊥螟�ｼｩ謾ｾ荳手ｾ灘�
      \coffin_set_eq:NN \l__circledtext_box_coffin \l__circledtext_char_coffin

      % 豬矩㍼逶貞ｭ仙ｮｹ蝎ｨ諤ｻ鬮伜ｺｦ(逕ｨ蜀��蝨��荳埼怙隕�)
      \dim_set:Nn \l_tmpa_dim
        { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
      % 郛ｩ謾ｾ蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ蛻ｰ蟄礼ｬｦ螟ｧ蟆�
      \coffin_scale:Nnn \l__circledtext_box_coffin
        {
          \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
        }
        {
          \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
        }

      % 譬ｹ謐ｮ謖�ｮ夂噪譁ｹ蠑冗ｼｩ謾ｾ逶貞ｭ�
      \__circledtext_resize_c:n { \l__circledtext_resize_method_tl }

      % 荳区ｲ芽ｷ晉ｦｻ=蟄礼ｬｦ豺ｱ蠎ｦ+螟匁｡�ｺｿ螳ｽ
      \dim_add:Nn \l__circledtext_char_dp_dim { \l__circledtext_box_linewidth_dim }

      % 霎灘�逶貞ｭ�(荳区ｲ画ｷｱ蠎ｦ霍晉ｦｻ)
      \coffin_typeset:Nnnnn \l__circledtext_box_coffin
        { l } { b } { 0pt } { -\l__circledtext_char_dp_dim }
    \group_end:
  }

% 蟄礼ｬｦ螟�炊蜿･譟��謨ｰ
% #1 髴隕∝､�炊逧�ｭ礼ｬｦ(荳ｲ)蜿倬㍼
\cs_new:Npn \__circledtext_single_handle:N #1
  {
    \group_begin:
      \tl_set:Nf \l__circledtext_curr_char_tl {#1}
      \__circledtext_single_construct:N \l__circledtext_curr_char_tl
    \group_end:
  }

% 譫��蟶ｦ蝨亥ｭ礼ｬｦ
% #1 髴隕∝､�炊逧�ｭ礼ｬｦ(荳ｲ)蜿倬㍼
\cs_new:Npn \__circledtext_single_construct:N #1
  {
    % 謖画欠螳夂噪譬ｼ蠑丞柱蜀�ｮｹ譫��荳荳ｪ蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ
    \hcoffin_set:Nn \l__circledtext_box_coffin
      {
        \bool_if:NTF \l__circledtext_negative_bool
          {
            \color_select:n { circledtextboxfill   }
          }{
            \color_select:n { circledtextcharcolor }
          }
        \tl_use:N \l__circledtext_character_format_tl
        \__circledtext_chars_stroke_construct:n { #1 }
      }

    % 譫��蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ霎ｹ譯�
    \__circledtext_single_box_construct:
  }

% 蟄礼ｬｦ逶貞ｭ仙所霎ｹ譯�ｻ�粋逶貞ｭ仙ｮｹ蝎ｨ譫��蜃ｽ謨ｰ
\cs_new:Npn \__circledtext_single_box_construct:
  {
    % 譬ｹ謐ｮ譁�ｭ怜�螳ｹ隶｡邂礼ｼｩ謾ｾ豈比ｾ�
    \dim_set:Nn \l_tmpa_dim
      { \coffin_wd:N \l__circledtext_box_coffin }
    \dim_set:Nn \l_tmpb_dim
      { \__circledtext_coffin_ht_plus_dp:N \l__circledtext_box_coffin }
    \dim_compare:nNnF \l_tmpa_dim &gt; \l_tmpb_dim
      {
        \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim
      }

    % 郛ｩ謾ｾ蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ
    \coffin_scale:Nnn \l__circledtext_box_coffin
      {
        \dim_ratio:nn { \charboxwd } { \l_tmpa_dim }
      }
      {
        \dim_ratio:nn { \charboxht } { \l_tmpa_dim }
      }

    % 謖画欠螳夂ｼｩ謾ｾ邉ｻ謨ｰ蟇ｹ蟄礼ｬｦ逶貞ｭ仙ｮｹ蝎ｨ霑幄｡檎ｼｩ謾ｾ
    \coffin_scale:Nnn \l__circledtext_box_coffin
      { \l__circledtext_char_shrink_fp }
      { \l__circledtext_char_shrink_fp }

    % 扈伜宛螟匁｡�ｹｶ諡ｼ陬�ｻ捺棡
    \draw_begin:
      \draw_set_linewidth:n { \l__circledtext_box_linewidth_dim }

      \draw_path_scope_begin:
        \__circledtext_char_box_type_c:n { \l__circledtext_char_box_type_tl }
          { 0 } { 0 } { \charboxwd } { \charboxht } { 1.0 } { 1.0 }
        \draw_transform_shift:n {\charboxwd / 2.0, \charboxht / 2.0 }
        \draw_coffin_use:Nnn \l__circledtext_box_coffin { hc } { vc }
      \draw_path_scope_end:
    \draw_end:
  }

\endinput
</pre></body></html>