From 6d09fe61bacbbb087b3b3c9e8d77a8d338620395 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 26 Apr 2017 22:46:08 +0000 Subject: typoaid (26apr17) git-svn-id: svn://tug.org/texlive/trunk@44067 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/typoaid/typoaid.sty | 413 ++++++++++++++++++++---- 1 file changed, 359 insertions(+), 54 deletions(-) (limited to 'Master/texmf-dist/tex/latex/typoaid') diff --git a/Master/texmf-dist/tex/latex/typoaid/typoaid.sty b/Master/texmf-dist/tex/latex/typoaid/typoaid.sty index aa507d7ab7b..759c3b5bb6a 100644 --- a/Master/texmf-dist/tex/latex/typoaid/typoaid.sty +++ b/Master/texmf-dist/tex/latex/typoaid/typoaid.sty @@ -4,109 +4,414 @@ %% E-mail: ilfuria+tya@gmail.com %% Released under the LaTeX Project Public License v1.3c or later %% See http://www.latex-project.org/lppl.txt +%% Changelog: +%% 0.0.7 first release +%% 0.1.0 completed the simple-command interface +%% 0.1.5 tested and fine tuned the simple command interface +%% 0.2.0 through 0.2.7 introduced the font table and tuned it +%% 0.3.0 through 0.3.7 introduced the width table and tuned it +%% 0.3.8 special code refactoring for luatex %% --------------------------------------------------------------- \RequirePackage{expl3} -\ProvidesExplPackage{typoaid}{2017/04/21}{0.0.7} {Typographical Aid} +\ProvidesExplPackage{typoaid}{2017/04/25}{0.3.8} {Typographic Aid} \RequirePackage{xparse} +\RequirePackage{array} +\RequirePackage{booktabs} +\RequirePackage{siunitx} -%%\ExplSyntaxOn -%%\newlength{\typ@@id} +%% CONSTANTS AND VARIABLES -\dim_new:N \l__typoAid_Alphabet_dim +\dim_new:N \g__typoAid_Alphabet_dim -\dim_new:N\l__typoAid_ExHeight_dim +\dim_new:N\g__typoAid_ExHeight_dim -\dim_new:N\l__typoAid_EmWidth_dim +\dim_new:N\g__typoAid_EmWidth_dim -\box_new:N\l__typoAid_Alphabet_box +\dim_new:N\g__typoAid_MeanChar_dim -\str_const:Nx\l__typoAid_typeout_string{TypoAid\iow_newline: *~Font~switch~given:~} +\box_new:N\g__typoAid_Alphabet_box -%% abcdefghijklmnopqrstuvwxyz -%%{a{}b{}c{}d{}e{}f{}g{}h{}i{}j{}k{}l{}m{}n{}o{}p{}q{}r{}s{}t{}u{}v{}w{}x{}y{}z{}} +\int_new:N\g__typoAid_CharPerRow_int -\cs_set_nopar:Npn\_typoAid_typoAlphabet:n #1 {% - \box_gclear:N\l__typoAid_Alphabet_box - \hbox_set:Nn\l__typoAid_Alphabet_box{#1a{}b{}c{}d{}e{}f{}g{}h{}i{}j{}k{}l{}m{}n{}o{}p{}q{}r{}s{}t{}u{}v{}w{}x{}y{}z{}}} +\dim_new:N\g__typoAid_dummy_dim -\cs_set_nopar:Npn\_typoAid_incrCntr:n #1 {% - \_typoAid_typoAlphabet:n{#1} - \dim_set:Nn\l__typoAid_Alphabet_dim{\box_wd:N\l__typoAid_Alphabet_box} +\fp_new:N\g__typoAid_alphDivider_fp + +\tl_const:Nn \c__typoAid_lc_alphabet_tl {abcdefghijklmnopqrstuvwxyz} + +\tl_const:Nn \c__typoAid_uc_alphabet_tl {ABCDEFGHIJKLMNOPQRSTUVWXYZ} + +\str_const:Nn\c__typoAid_name_string{TypoAid} + +\str_const:Nx\c__typoAid_typeout_string{TypoAid\iow_newline: *~Font~switch~given:~} + +%% END CONSTANTS AND VARIABLES + + +%% CALCULATIONS +% A helper function to avoid global assignments. +% The second argument should consist of protected +% function and expandable ones +\cs_new_protected:Npn \__typoAid_smuggle:nn #1 #2 + { + \group_begin: + #1 + \use:x { \group_end: #2 } + } + +\cs_new_protected:Npn\__typoAid_typoAlphabet:n #1 +{ + \box_gclear:N \g__typoAid_Alphabet_box + \hbox_gset:Nn \g__typoAid_Alphabet_box + { + #1 + % LuaTeX ignores {} as far as kerning is concerned so + % we need to box each character + \tl_map_inline:Nn \c__typoAid_lc_alphabet_tl { \hbox:n { ##1 } } + } + } + +\cs_new_protected:Npn\__typoAid_calcAlph:n #1 +{ + \__typoAid_typoAlphabet:n{#1} + \dim_gset:Nn\g__typoAid_Alphabet_dim{\box_wd:N\g__typoAid_Alphabet_box} + \fp_set:Nn\g__typoAid_alphDivider_fp{26.5+1/100*\dim_to_decimal:n{\g__typoAid_Alphabet_dim}} \dim_gset:Nn\g__typoAid_MeanChar_dim{\fp_to_dim:n{\dim_to_decimal:n{\g__typoAid_Alphabet_dim}/\fp_use:N\g__typoAid_alphDivider_fp}} } -\cs_set_nopar:Npn\_typoAid_calcEx:n #1{% - \group_begin: - #1 - \dim_gset:Nn\l__typoAid_ExHeight_dim{\dim_eval:n{1ex}} - \group_end: +\cs_new_protected:Npn\__typoAid_calcEx:n #1{% + \__typoAid_smuggle:nn { #1 } + { + \dim_gset:Nn \g__typoAid_ExHeight_dim { \dim_eval:n { 1ex } } + } } -\cs_set_nopar:Npn\_typoAid_calcEm:n#1{ - \group_begin: - #1 - \dim_gset:Nn\l__typoAid_EmWidth_dim{\dim_eval:n{1em}} - \group_end: +\cs_new_protected:Npn\__typoAid_calcEm:n#1{ + \__typoAid_smuggle:nn { #1 } + { + \dim_gset:Nn \g__typoAid_EmWidth_dim { \dim_eval:n { 1em } } + } } -\cs_set:Npn\_typoAid_log:n#1#2{% - \msg_log:n{% - \l__typoAid_typeout_string~#2 \iow_newline:.~#1 - } +\cs_new_protected:Npn\__typoAid_calcCharPW:n#1 +{ +\int_gset:Nn\g__typoAid_CharPerRow_int{\int_eval:n{\fp_to_int:n{\dim_ratio:nn{\dim_eval:n{#1}}{\g__typoAid_MeanChar_dim}}}} + } -\cs_set_nopar:Nn\_typoAid_Alphabet_string:{Alphabet~length:~\dim_use:N\l__typoAid_Alphabet_dim} +\cs_new_protected:Npn\__typoAid_calcAll:nn#1#2 +{ + \__typoAid_calcAll:n{#1} + \__typoAid_calcCharPW:n{#2} +} -\cs_set_nopar:Nn\_typoAid_ExHeight_string:{% - Ex~height:~\dim_use:N\l__typoAid_ExHeight_dim +\cs_new_protected:Npn\__typoAid_calcAll:n#1 +{ + \__typoAid_calcAlph:n{#1} + \__typoAid_calcEx:n{#1} + \__typoAid_calcEm:n{#1} } -\cs_set_nopar:Npn\_typoAid_EmWidth_string:{% - Em~width:~\dim_use:N\l__typoAid_EmWidth_dim + +%% END CALCULATIONS + +%% LOGS AND STRINGS +\cs_set_protected:Npn\__typoAid_log:nn #1#2 +{ + \msg_log:n{\c__typoAid_typeout_string~#2 \iow_newline:.~#1} } -\ProvideDocumentCommand{\typrintalph}{ s m }% - {% - \_typoAid_incrCntr:n{#2} +\cs_set_protected:Npn\__typoAid_column_string:n#1 +{ + \__typoAid_calcCharPW:n{\dim_eval:n{\columnwidth}} + Current~column~width:~\dim_use:N\columnwidth.~ + Yields~\int_eval:n{\g__typoAid_CharPerRow_int}~ + ~characters~per~line,~with~the~selected~switch:~\tl_to_str:n{#1} +} + +\cs_new:Nn\__typoAid_Alphabet_string:{Alphabet~length:~\dim_use:N\g__typoAid_Alphabet_dim} + +\cs_new:Nn\__typoAid_ExHeight_string:{% + Ex~height:~\dim_use:N\g__typoAid_ExHeight_dim +} + +\cs_new:Nn\__typoAid_EmWidth_string:{% + Em~width:~\dim_use:N\g__typoAid_EmWidth_dim +} + +\cs_new:Npn\__typoAid_logWidth:nn#1#2 +{ +\c__typoAid_name_string;~data~with~font~mod:\tl_to_str:n{#2}\ ~ + \iow_newline:*~ column: + ~\dim_to_decimal_in_unit:nn{#1}{1pt}~pt~or~ + ~\dim_to_decimal_in_unit:nn{#1}{1pc}~pc + \iow_newline:*~\int_use:N\g__typoAid_CharPerRow_int~% + ~char~per~row% +} + +\cs_new:Npn\__typoAid_logGeneral:nn#1#2 +{ + \c__typoAid_name_string.~Font~modifier: \tl_to_str:n{#1}\ ~\iow_newline:*~ + ~Switch:~#2~\iow_newline:*~ + ~Alphabet:~\dim_use:N\g__typoAid_Alphabet_dim\iow_newline:*~ + ~Ex~height:~\dim_use:N\g__typoAid_ExHeight_dim\iow_newline:*~ + ~Em~width:~\dim_use:N\g__typoAid_EmWidth_dim~ +} + +%% END LOGS AND STRINGS + +%% PUBLIC + +\NewDocumentCommand{\typrintalph}{ s m } +{ + \__typoAid_calcAlph:n{#2} \IfBooleanTF{#1}{% - \msg_term:n{\l__typoAid_typeout_string#2\iow_newline:*~\_typoAid_Alphabet_string:}% + \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~\iow_newline:*~\__typoAid_Alphabet_string:}% }{% - \_typoAid_Alphabet_string:% + \__typoAid_Alphabet_string:% }% - \_typoAid_log:n{\_typoAid_Alphabet_string:}{ #2} + \__typoAid_log:nn{\__typoAid_Alphabet_string:}{#2} } -\ProvideDocumentCommand{\typrintex}{ s m }{% - \_typoAid_calcEx:n{#2} +\NewDocumentCommand{\typrintex}{ s m }{% + \__typoAid_calcEx:n{#2} \IfBooleanTF{#1}{% - \msg_term:n{\l__typoAid_typeout_string#2 \iow_newline:*~ \_typoAid_ExHeight_string:}% + \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~ \iow_newline:*~ \__typoAid_ExHeight_string:}% }{% - \_typoAid_ExHeight_string:% + \__typoAid_ExHeight_string:% }% - \_typoAid_log:n{\_typoAid_ExHeight_string:}{ #2} + \__typoAid_log:nn{\__typoAid_ExHeight_string:}{ #2} } -\ProvideDocumentCommand{\typrintem}{s m}{% - \_typoAid_calcEm:n{#2} +\NewDocumentCommand{\typrintem}{s m}{% + \__typoAid_calcEm:n{#2} \IfBooleanTF{#1}{% - \msg_term:n{\l__typoAid_typeout_string #2 \iow_newline:*~ \_typoAid_EmWidth_string:}% + \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~ \iow_newline:*~ \__typoAid_EmWidth_string:}% }{% - \_typoAid_EmWidth_string: + \__typoAid_EmWidth_string: }% - \_typoAid_log:n{\_typoAid_EmWidth_string:}{ #2} + \__typoAid_log:nn{\__typoAid_EmWidth_string:}{ #2} } -\ProvideDocumentCommand{\typrintall}{ s m}{% -\IfBooleanTF{#1}{% + +\NewDocumentCommand{\tyallsimple}{ s m} +{ + \IfBooleanTF{#1} + { \typrintalph*{#2}\\ \typrintex*{#2}\\ \typrintem*{#2}\\ - }{% + }{ \typrintalph{#2}\\ \typrintex{#2}\\ \typrintem{#2}\\ } } +\NewDocumentCommand{\tyfonttable}{sm}{% +\__typoAid_calcAll:n{#2} +\IfBooleanTF{#1}{ + \msg_log:n{\__typoAid_logGeneral:nn{#2}{upshape}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{upshape}} + \__typoAid_calcAll:n{\bfseries#2} + \msg_log:n{\__typoAid_logGeneral:nn{#2}{bfseries}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{bfseries}} + \__typoAid_calcAll:n{\itshape#2} + \msg_log:n{\__typoAid_logGeneral:nn{#2}{itshape}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{itshape}} + \__typoAid_calcAll:n{\scshape#2} + \msg_log:n{\__typoAid_logGeneral:nn{#2}{scshape}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{scshape}} + \__typoAid_calcAll:n{\slshape#2} + \msg_log:n{\__typoAid_logGeneral:nn{#2}{slshape}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{slshape}} + \__typoAid_calcAll:n{\sffamily#2} + \msg_log:n{\__typoAid_logGeneral:nn{#2}{sffamily}} + \msg_term:n{\__typoAid_logGeneral:nn{#2}{sffamily}} + }{% + \begin{table}\centering + \caption{\strut Font~metrics~for~switch:~\tl_to_str:n{#2} } + \begin{tabular}{lSSS} + \toprule + Font~switch &\multicolumn{1}{r}{Alphabet~length}&\multicolumn{1}{r}{Ex~height}&\multicolumn{1}{r}{Em~width}\\ + \midrule +\msg_log:n{\__typoAid_logGeneral:nn{#2}{upshape}} \texttt{upshape}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + + \__typoAid_calcAll:n{\bfseries#2} +\msg_log:n{\__typoAid_logGeneral:nn{#2}{bfseries}} \texttt{bfseries}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + + \__typoAid_calcAll:n{\itshape#2} +\msg_log:n{\__typoAid_logGeneral:nn{#2}{itshape}} \texttt{itshape}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + + \__typoAid_calcAll:n{\scshape#2} +\msg_log:n{\__typoAid_logGeneral:nn{#2}{scshape}} \texttt{scshape}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + + \__typoAid_calcAll:n{\slshape#2} +\msg_log:n{\__typoAid_logGeneral:nn{#2}{slshape}} \texttt{slshape}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + + \__typoAid_calcAll:n{\sffamily#2} +\msg_log:n{\__typoAid_logGeneral:nn{#2}{sffamily}} \texttt{sffamily}&\dim_use:N\g__typoAid_Alphabet_dim&\dim_use:N\g__typoAid_ExHeight_dim&\dim_use:N\g__typoAid_EmWidth_dim\\ + \bottomrule + \end{tabular} + \end{table} + } +} + +\NewDocumentCommand{\tywidthtable}{ s m } +{ + \__typoAid_calcAll:nn{#2}{\columnwidth} + \IfBooleanTF{#1}{% + \msg_term:n{\__typoAid_logWidth:nn{\columnwidth}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\columnwidth}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{1.5*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{2*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{2.5*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{12*2*\dim_use:N\g__typoAid_EmWidth_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{12*2.5*\dim_use:N\g__typoAid_EmWidth_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{66*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{30*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + +\dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{44*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} +\msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{50*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} +\msg_term:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + + }{% + + \begin{table}\centering + \caption{\strut Width~data~for~font~modificator~\tl_to_str:n{#2} } + \begin{tabular}{lSSS} + \toprule + Description&\multicolumn{1}{c}{Value(pt)}&\multicolumn{1}{c}{Value(pc)}&\multicolumn{1}{c}{Char~per~row}\\ + \midrule + \msg_log:n{\__typoAid_logWidth:nn{\columnwidth}{#2}} + Current~column& \dim_to_decimal_in_unit:nn{\columnwidth}{1pt} & \dim_to_decimal_in_unit:nn{\columnwidth}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{1.5*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 1.5~alphabet~times~(Felici)&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{2*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 2~alphabet~times~(Felici)&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{2.5*\dim_use:N\g__typoAid_Alphabet_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 2.5~alphabet~times &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{12*2*\dim_use:N\g__typoAid_EmWidth_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 2~em~in~pica~(Felici) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{12*2.5*\dim_use:N\g__typoAid_EmWidth_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 2.5~em~in~pica~(Felici/Bringhurst) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{66*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 66~char~per~row~(Bringhurst) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + +\dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{30*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 30~char~per~row~multicol~(Bringhurst) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + +\dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{44*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 44~char~per~row~multicol~(Bringhurst) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + + +\dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{50*\dim_use:N\g__typoAid_MeanChar_dim}} + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + \msg_log:n{\__typoAid_logWidth:nn{\g__typoAid_dummy_dim}{#2}} + 50~char~per~row~multicol~(Bringhurst) &\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pt}&\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}&\int_use:N\g__typoAid_CharPerRow_int\\ + +\bottomrule + + \end{tabular} + \end{table} + } +} + +\NewDocumentCommand{\tychperwidth}{som}{% + \__typoAid_calcAll:n{#3} + \IfNoValueTF{#2} + { + \dim_gset:Nn\g__typoAid_dummy_dim{\columnwidth} + } + { + \dim_gset:Nn\g__typoAid_dummy_dim{#2} + } + + \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim} + + \IfBooleanTF{#1} + { + \msg_term:n{\c__typoAid_name_string;~Calculated:~\int_eval:n{\g__typoAid_CharPerRow_int}~chars~in~width:~ + \dim_use:N\g__typoAid_dummy_dim~~ and~switch~\tl_to_str:n{#3}} + }{ + Calculated:~\int_eval:n{\g__typoAid_CharPerRow_int}~chars~in~width:~ + \dim_eval:n{\g__typoAid_dummy_dim}~and~switch~\tl_to_str:n{#3} + } + + \msg_log:n{\c__typoAid_name_string;~Calculated:~\int_eval:n{\g__typoAid_CharPerRow_int}~chars~in~width:~ + \dim_eval:n{\g__typoAid_dummy_dim}~and~switch~\tl_to_str:n{#3}} +} + +\NewDocumentCommand{\tywidthgivchar}{sO{}m}{% + \__typoAid_calcAll:n{#2} + \dim_gset:Nn\g__typoAid_dummy_dim{\fp_to_dim:n{\dim_to_fp:n{\g__typoAid_MeanChar_dim}*\int_eval:n{#3}}} + \IfBooleanTF{#1}{% + \msg_term:n{\c__typoAid_name_string;~for:\tl_to_str:n{#2}\ % + \iow_newline:*~for~\int_eval:n{#3}~char,\iow_newline:*~ % + colwidth:~\dim_eval:n{\g__typoAid_dummy_dim}~(\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}~pc)} + }{% + In~order~to~obtain~the~required~\int_eval:n{#3}~characters~per~column,~it~should~have~a~width~of~ + \dim_eval:n{\g__typoAid_dummy_dim}~(\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}~pc) + } + \msg_log:n{\c__typoAid_name_string;~for:\tl_to_str:n{#2}\ + \iow_newline:.~for \int_eval:n{#3}~char,\iow_newline:.~ + colwidth:~\dim_eval:n{\g__typoAid_dummy_dim}~(\dim_to_decimal_in_unit:nn{\g__typoAid_dummy_dim}{1pc}~pc)} +} %%\ExplSyntaxOff \ No newline at end of file -- cgit v1.2.3