latex How do I know what symbols/characters are available in a font package

% https://tex.stackexchange.com/questions/380775/font-table-for-opentype-truetype-fonts

\documentclass{article}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{longtable}
\usepackage{array}

\setlength\extrarowheight{3pt}

\ExplSyntaxOn
\NewDocumentCommand{\OTfonttable}{m}
 {
  \group_begin:
  #1
  \int_gset:Nn \g_fonttable_rows_int
   { \int_div_truncate:nn { \XeTeXlastfontchar \font + 15 } { 16 } }
  \int_gset:Nn \g_fonttable_chunks_int
   { \int_div_truncate:nn { \g_fonttable_rows_int + 31 } { 32 } }
  \group_end:
  \fonttable_make:n { #1 }
 }

\int_new:N \g_fonttable_rows_int
\int_new:N \g_fonttable_chunks_int
\seq_new:N \l_fonttable_rows_seq
\tl_new:N \l_fonttable_font_tl

\cs_new_protected:Nn \fonttable_make:n
 {
  \tl_set:Nn \l_fonttable_font_tl { #1 }
  \int_step_inline:nnnn { 0 } { 1 } { \g_fonttable_chunks_int - 1 }
   {
    \seq_clear:N \l_fonttable_rows_seq
    \int_step_inline:nnnn { 0 } { 1 } { 31 }
     {
      \seq_put_right:Nx \l_fonttable_rows_seq
       {
        \fonttable_setup: \int_to_Hex:n { ##1*32 + ####1 }x &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 0 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 1 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 2 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 3 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 4 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 5 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 6 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 7 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 8 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 9 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 10 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 11 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 12 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 13 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 14 } } &
        \fonttable_char:n { \int_eval:n { ##1*512 + ####1*16 + 15 } } 
       }
     }
    \begin{tabular}{|r|*{16}{c|}}
    \cline{2-17}
    \multicolumn{1}{c|}{} &
      \ttfamily 0 &
      \ttfamily 1 &
      \ttfamily 2 &
      \ttfamily 3 &
      \ttfamily 4 &
      \ttfamily 5 &
      \ttfamily 6 &
      \ttfamily 7 &
      \ttfamily 8 &
      \ttfamily 9 &
      \ttfamily A &
      \ttfamily B &
      \ttfamily C &
      \ttfamily D &
      \ttfamily E &
      \ttfamily F \\
    \hline
    \seq_use:Nn \l_fonttable_rows_seq { \\ \hline } \\
    \hline
    \end{tabular}\clearpage
   }
 }

\cs_new_protected:Nn \fonttable_setup: { \ttfamily $\vphantom{\big|}$ }

\cs_new_protected:Nn \fonttable_char:n
 {
  \tl_use:N \l_fonttable_font_tl
  \iffontchar\font #1 \symbol{#1} \fi
 }
\ExplSyntaxOff

% \newfontface{\test}{Old Standard}
\newfontfamily\test{sr2.ttf}
\setCJKmainfont{sr2.ttf}
\setCJKsansfont{sr2.ttf}
\setCJKmonofont{sr2.ttf}
\begin{document}

\OTfonttable{\test}

\end{document}
posted @ 2021-03-13 16:47  fndefbwefsowpvqfx  阅读(62)  评论(0编辑  收藏  举报