<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%     Copyright (C) 2020-2022 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}{2024-09-09}{v1.1.1}
  {Typeset circled text with l3draw}

\RequirePackage { xtemplate, l3keys2e, l3draw, xparse }

% ä¿è¯TeXLiveçš„å‘ä¸‹å…¼å®¹
\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 æ&nbsp;¼å¼é€‰é¡¹
% #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:
  }

% æ˜¯å¦åç™½æ&nbsp;‡å¿—
\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
% å­—ç¬¦(ä¸²)æ·±åº¦(å¸¦æ&nbsp;¼å¼)
\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
% å­—ç¬¦(ä¸²)æŽ’ç‰ˆæ&nbsp;¼å¼
\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å®žçŽ°ï¼Œ
% è®¾è®¡æ€è·¯å’Œéƒ¨åˆ†æºç&nbsp;æ¥è‡ª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:
  {
    % è®¾ç½®åŸºå­—ç¬¦æ&nbsp;¼å¼çš„åŸºå­—ç¬¦ç›’å­
    \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 }
          }
      }
  }

% å­—ç¬¦ç›’å­æž„é€&nbsp;ç±»åž‹å‡½æ•°åç§°ç”Ÿæˆå‡½æ•°
% åç§°ä¸­6ä¸ªå‚æ•°åˆ†åˆ«è¡¨ç¤ºï¼š
% #1 å·¦ä¸‹è§’xåæ&nbsp;‡
% #2 å·¦ä¸‹è§’yåæ&nbsp;‡
% #3 å³ä¸Šè§’xåæ&nbsp;‡
% #4 å³ä¸Šè§’yåæ&nbsp;‡
% #5 xæ–¹å‘ç¼©æ”¾æ¯”ä¾‹(æ‰©å±•ä¿ç•™å‚æ•°)
% #6 yæ–¹å‘ç¼©æ”¾æ¯”ä¾‹(æ‰©å±•ä¿ç•™å‚æ•°)
\cs_new_nopar:Npn \__circledtext_char_box_type:n #1
  {
    __circledtext_char_box_construct_type_ #1 :nnnnnn
  }
% å­—ç¬¦ç›’å­æž„é€&nbsp;ç±»åž‹å‡½æ•°åç§°å‘½ä»¤ç”Ÿæˆå‡½æ•°
% åç§°å‘½ä»¤ä¸­6ä¸ªå‚æ•°åˆ†åˆ«è¡¨ç¤ºï¼š
% #1 å·¦ä¸‹è§’xåæ&nbsp;‡
% #2 å·¦ä¸‹è§’yåæ&nbsp;‡
% #3 å³ä¸Šè§’xåæ&nbsp;‡
% #4 å³ä¸Šè§’yåæ&nbsp;‡
% #5 xæ–¹å‘ç¼©æ”¾æ¯”ä¾‹(æ‰©å±•ä¿ç•™å‚æ•°)
% #6 yæ–¹å‘ç¼©æ”¾æ¯”ä¾‹(æ‰©å±•ä¿ç•™å‚æ•°)
\cs_new_nopar:Npn \__circledtext_char_box_type_c:n #1
  {
    \use:c
      {
        __circledtext_char_box_construct_type_ #1 :nnnnnn
      }
  }

% å­—ç¬¦ç›’å­æž„é€&nbsp;ç±»åž‹å‡½æ•°ç”Ÿæˆå™¨å‡½æ•°
% #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 }

% å®šä¹‰å­—ç¬¦è¾¹æ¡†ç›’å­ç±»åž‹

% æ—&nbsp;è¾¹æ¡†
\__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:
      }
  }

% æ—&nbsp;åè‰²åº•å±‚å¡«å……æ­£æ–¹å½¢
\__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:
  }

% æ—&nbsp;åè‰²ä¸Šå±‚å¡«å……æ­£æ–¹å½¢
\__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:
  }

% æ—&nbsp;åè‰²é˜´å½±å¡«å……æ­£æ–¹å½¢
\__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:
  }

% æ—&nbsp;åè‰²åº•å±‚å¡«å……å†…åˆ‡åœ†
\__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:
  }

% æ—&nbsp;åè‰²ä¸Šå±‚å¡«å……å†…åˆ‡åœ†
\__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:
  }

% æ—&nbsp;åè‰²é˜´å½±å¡«å……å†…åˆ‡åœ†
\__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:
  }

% æ—&nbsp;åè‰²åº•å±‚å¡«å……å¤–æŽ¥åœ†
\__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:
  }

% æ—&nbsp;åè‰²ä¸Šå±‚å¡«å……å¤–æŽ¥åœ†
\__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:
  }

% æ—&nbsp;åè‰²é˜´å½±å¡«å……å¤–æŽ¥åœ†
\__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_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_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_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_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_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_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_dash_pattern:nn { \l__circledtext_dash_pattern_tl } { 0pt }
        }
      \draw_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:
  }

% å¡«å……å†…åˆ‡åœ†å&nbsp;åŠ&nbsp;å†…åˆ‡åœ†è¾¹æ¡†
\__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}
  }

% å¡«å……å†…åˆ‡åœ†å&nbsp;åŠ&nbsp;æ­£æ–¹å½¢æ­£åå­—çº¿ä¸Žå†…åˆ‡åœ†è¾¹æ¡†
\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}
      }
  }

% å¡«å……å†…åˆ‡åœ†å&nbsp;åŠ&nbsp;å†…åˆ‡åœ†æ–œåå­—çº¿ä¸Žå†…åˆ‡åœ†è¾¹æ¡†
\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}
      }
  }

% å¡«å……å†…åˆ‡åœ†å&nbsp;åŠ&nbsp;å†…åˆ‡åœ†æ­£æ–œåå­—çº¿ä¸Žå†…åˆ‡åœ†è¾¹æ¡†
\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}
      }
  }

% å†…åˆ‡åœ†æ–œåå­—çº¿å&nbsp;åŠ&nbsp;æ­£åå­—çº¿
\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}
      }
  }

% å¡«å……æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;æ­£æ–¹å½¢è¾¹æ¡†
\__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}
  }

% å¡«å……æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;æ­£æ–¹å½¢æ­£åå­—çº¿ä¸Žæ­£æ–¹å½¢è¾¹æ¡†
\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}
      }
  }

% å¡«å……æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;æ­£æ–¹å½¢æ–œåå­—çº¿ä¸Žæ­£æ–¹å½¢è¾¹æ¡†
\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}
      }
  }

% å¡«å……æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;æ­£æ–¹å½¢æ–œæ­£åå­—çº¿ä¸Žæ­£æ–¹å½¢è¾¹æ¡†
\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}
      }
  }

% æ­£æ–¹å½¢æ–œåå­—çº¿å&nbsp;åŠ&nbsp;æ­£åå­—çº¿
\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}
      }
  }

% å†…åˆ‡åœ†å&nbsp;åŠ&nbsp;åŒå¿ƒ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}
  }

% åè‰²æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;å†…åˆ‡å¡«å……åœ†
\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}
      }
  }

% æ­£æ–¹å½¢å&nbsp;åŠ&nbsp;åŒå¿ƒ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åŒå¿ƒåœ†å&nbsp;åŠ&nbsp;(ç±»ä¼¼ä¸­å›½è±¡æ£‹æ£‹å­å½¢çŠ¶)
\__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åŒå¿ƒæ­£æ–¹å½¢å&nbsp;åŠ&nbsp;
\__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
      }
  }

% ç¼©æ”¾ä»£ç&nbsp;ç”Ÿæˆå‡½æ•°
% #1 dimé•¿åº¦å˜é‡1
% #2 dimé•¿åº¦å˜é‡2
% #3 ç¼©æ”¾ä»£ç&nbsp;1
% #4 ç¼©æ”¾ä»£ç&nbsp;2
% #5 ç¼©æ”¾ä»£ç&nbsp;3
% å¦‚æžœ #1 &gt; 0           ï¼Œå–#3ä»£ç&nbsp;
% å¦‚æžœ #1 &lt;= 0 ä¸”#2 &gt; 0 ï¼Œå–#4ä»£ç&nbsp;
% å¦‚æžœ #1 &lt;= 0 ä¸”#2 &lt;= 0ï¼Œå–#5ä»£ç&nbsp;
\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 }
      }
  }

% ç¼©æ”¾ä»£ç&nbsp;ç”Ÿæˆå‡½æ•°
% #1 dimé•¿åº¦å˜é‡1
% #2 dimé•¿åº¦å˜é‡2
% #3 ç¼©æ”¾ä»£ç&nbsp;1
% #4 ç¼©æ”¾ä»£ç&nbsp;2
% #5 ç¼©æ”¾ä»£ç&nbsp;3
% #6 ç¼©æ”¾ä»£ç&nbsp;4
% å¦‚æžœ #1 &gt; 0  ä¸” #2 &gt; 0 ï¼Œå–#3ä»£ç&nbsp;
% å¦‚æžœ #1 &gt; 0  ä¸” #2 &lt;= 0ï¼Œå–#4ä»£ç&nbsp;
% å¦‚æžœ #1 &lt;= 0 ä¸” #2 &gt; 0 ï¼Œå–#5ä»£ç&nbsp;
% å¦‚æžœ #1 &lt;= 0 ä¸” #2 &lt;= 0ï¼Œå–#6ä»£ç&nbsp;
\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 }
      }
  }

% ç¼©æ”¾ä»£ç&nbsp;ç”Ÿæˆå‡½æ•°(åˆ†åˆ«æŒ‰é«˜åº¦ã€å®½åº¦æˆ–å®žé™…å°ºå¯¸ç¼©æ”¾)
\cs_new:Npn \__circledtext_force_size_dispatch:nnn % height, width, none
  {
    \__circledtext_dim_gezero_dispatch:NNnnn \l__circledtext_height_dim
      \l__circledtext_width_dim
  }

% ç¼©æ”¾ä»£ç&nbsp;ç”Ÿæˆå‡½æ•°(åˆ†åˆ«æŒ‰é«˜å®½ã€é«˜åº¦ã€å®½åº¦æˆ–å®žé™…å°ºå¯¸ç¼©æ”¾)
\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
  }

% æž„é€&nbsp;ç¼©æ”¾ç±»åž‹
\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} }
  }

% æ—&nbsp;ç¼©æ”¾
\__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 }
  }
% ç¬”ç”»æž„é€&nbsp;å‡½æ•°
\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:
                        },
    % å­—ç¬¦æ&nbsp;¼å¼
    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 }
                         } ,

    % æ—&nbsp;åè‰²æ—¶åº•å±‚ç›’å­èƒŒæ™¯å¡«å……é¢œè‰²
    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 = {} ,

    % æ—&nbsp;åè‰²æ—¶ä¸Šå±‚ç›’å­èƒŒæ™¯å¡«å……é¢œè‰²
    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,
    % è™šçº¿æ&nbsp;·å¼
    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. }

% æ&nbsp;¹æ®ç¼–è¯‘å¼•æ“Žè®¾ç½®åŸºå­—ç¬¦
\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}
  }

% æž„å»ºå­—ç¬¦ç›’å­ï¼Œå¦‚å­—ç¬¦ä¸ºç©ºï¼Œåˆ™ç”¨åŸºå­—ç¬¦æž„é€&nbsp;
% #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}

      % æž„é€&nbsp;ç›’å­
      \__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 }
        }

      % æ&nbsp;¹æ®æŒ‡å®šçš„æ–¹å¼ç¼©æ”¾ç›’å­
      \__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:
  }

% æž„é€&nbsp;å¸¦åœˆå­—ç¬¦
% #1 éœ€è¦å¤„ç†çš„å­—ç¬¦(ä¸²)å˜é‡
\cs_new:Npn \__circledtext_single_construct:N #1
  {
    % æŒ‰æŒ‡å®šçš„æ&nbsp;¼å¼å’Œå†…å®¹æž„é€&nbsp;ä¸€ä¸ªå­—ç¬¦ç›’å­å®¹å™¨
    \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 }
      }

    % æž„é€&nbsp;å­—ç¬¦ç›’å­å®¹å™¨è¾¹æ¡†
    \__circledtext_single_box_construct:
  }

% å­—ç¬¦ç›’å­åŠè¾¹æ¡†ç»„åˆç›’å­å®¹å™¨æž„é€&nbsp;å‡½æ•°
\cs_new:Npn \__circledtext_single_box_construct:
  {
    % æ&nbsp;¹æ®æ–‡å­—å†…å®¹è®¡ç®—ç¼©æ”¾æ¯”ä¾‹
    \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_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>