texlive[44067] Master/texmf-dist: typoaid (26apr17)

commits+karl at tug.org commits+karl at tug.org
Thu Apr 27 00:46:09 CEST 2017


Revision: 44067
          http://tug.org/svn/texlive?view=revision&revision=44067
Author:   karl
Date:     2017-04-27 00:46:08 +0200 (Thu, 27 Apr 2017)
Log Message:
-----------
typoaid (26apr17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf
    trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.tex
    trunk/Master/texmf-dist/tex/latex/typoaid/typoaid.sty

Modified: trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.tex	2017-04-26 22:45:55 UTC (rev 44066)
+++ trunk/Master/texmf-dist/doc/latex/typoaid/typoaid.tex	2017-04-26 22:46:08 UTC (rev 44067)
@@ -1,42 +1,184 @@
-\documentclass[a4paper]{article}
+\documentclass{article}
 \usepackage[utf8]{inputenc}
 \usepackage[english]{babel}
 \usepackage{lmodern}
-\usepackage{dtk-logos}
+\usepackage{metalogo}
+\usepackage[makeindex]{imakeidx}
 \usepackage{microtype}
+\usepackage{varioref}
 \usepackage{hyperref}
 \usepackage{url}
 \author{Daniele Ratti}
-\title{The Typo Aid Package (v.0.0.7)}
+\makeindex[intoc]
+\title{The Typo Aid Package (v.0.3.8)}
+\makeatletter
+\let\@@oldmpar\marginpar
+\renewcommand{\marginpar}[1]{\@@oldmpar{\small#1}}
+\makeatother
 \begin{document}
 \maketitle
 
 \begin{abstract}
-The typo aid package provides some useful tools in order to provide useful informations regarding the used fonts.
+The typo aid package provides some useful tools in order to provide data regarding the used fonts, and some hints about typesetting them. This manual is divided in two parts, the first mainly concerned with the end-user commands and usage, the second is a collection of notes regarding future development and code
 \end{abstract}
-\section{Commands}
-Four commands are provided:
-\begin{enumerate}
-\item \texttt{typrintalph} prints the alphabet length
-\item \texttt{typrintex} prints the ex-height
-\item\texttt{typrintem} prints the em-width.
-\end{enumerate}
+\tableofcontents
+\part{User manual}
+\section{Introduction}
+Since \texttt{typoaid} comes as a set of diagnostic tools to decide on how to set the type area,  in a manner that can hopefully be typographically pleasant and equilibrate, and that takes in consideration the typographic tradition.
 
-\noindent The commands follow the same schema, regarding the output:
+The set of macros, though, are not meant to give a single \emph{directive} on how big should be the measure of the text, or something like that: the tools only give tips and give common used guidelines to decide upon the correct measure for a given font.
+
+Each one of the package commands comes with:
 \begin{itemize}
-\item the normal, unstarred version of the command outputs to the typeset page
-\item the starred version outputs to the terminal
-\item both versions output to the log file, in addition to their normal output.
+\item an \emph{unstarred} version (e.g.)  \verb|\tychperwidth{}|, which types out the calculations to the page
+\item a \emph{starred} vesion (e.g.) \verb!\tychperwidth*{}!, which outputs the calculation \emph{to the terminal}
+\item a copy of the output data \emph{to the log file} (both starred and unstarred commands do log)
+\item the possibility to accept, a series of  one or more\emph{font switches}, such as \verb|\bfseries\itshape|, in order to provide calculation for the specific switch or combination. Please note that \emph{also font-family switches from} \texttt{fontspec} \emph{are supported.}
 \end{itemize}
-All of the commands can accept, as their single arguments, a font switch (e.g. \texttt{\textbackslash itshape, \textbackslash bfseries,\dots}). This will make them print the features of the selected switch.
-\subsection{Compatibility and Remarks}
+\subsection{Compatibility}
 The package is compatible with pdf{}\LaTeX, Lua\LaTeX and \XeLaTeX, and will accept a font family switch defined via the \texttt{fontspec} package.
+\section{Simple commands}\label{simpleforem}
+
+The\marginpar{\texttt{\textbackslash typrintalph}} \verb|\typrintalph| \index{\textbackslash typrintalph}\index{Alphabet} is used to calculate the alphabet length, given the font switches. The length is computed \emph{without kerning,} that is: using the pure letter widths.
+
+The \marginpar{\texttt{\textbackslash typrintex}} \verb!\typrintex!\index{\textbackslash typrintex} command is used to calculate the ex-height\index{Ex-height} of the font, given the switches. 
+
+The\marginpar{\texttt{\textbackslash typrintem}}  \verb!\typrintem!\index{\textbackslash typrintem} command, computes the em-width\index{Em-width} of the current font. Namely this is the same as the font body size, but may yield different results for different font switches, especially with \texttt{T1} fonts, where each family could have its em-width; this is proven not to be the case for OpenType fonts.
+
+ The\marginpar{\texttt{\textbackslash tyallsimple}} \verb!\tyallsimple!\index{\textbackslash tyallsimple} command simply calls internally the aforementioned commands, and returns their outputs. Its starred version calls the starred version of the same commands.
+
+\section{Char per width commands}
+The package provides two commands that calculate the \emph{char per width} and \emph{width given a number of characters} desired in a line. The calculations are based on the algorithm in section~\vref{calc}. Please note that the calculations are bound to be approximated estimates only, and do not imply that the result will produce \emph{exactly} what it’s asked of it (being it the char per width, or the width for a given number of chars); again, refer to section~\vref{calc} to have further information.
+
+\subsection{Characters fitting a given width}\label{chperwidth}
+The \marginpar{\texttt{\textbackslash tychperwidth}} \verb!\tychperwidth!\index{\textbackslash tychperwidth} command syntax extends the \emph{standard} \verb|\typoaid| syntax, since this commands accepts an optional parameter which should be a dimension. If given the calculation will be performed on that length, otherwise they will be performed on the \verb|\columnwidth|. 
+\subparagraph{Note:} the number of char is given as a rounded integer, so it’s bound to be an approximate number.
+\paragraph{Examples} here are two examples on how to use the command:
+\begin{verbatim}
+\tychperwidth*[17pc]{}
+\end{verbatim}
+Will produce:
+\begin{itemize}
+\item an output to the terminal (since the starred version is used) and the log
+\item a calculation on the current font with no extra switches (since the mandatory argument is empty)
+\item a calculation on how many characters will fit into \verb|17pc|
+\end{itemize}
+
+\begin{verbatim}
+\tychperwidth{\itshape}
+\end{verbatim}
+Will instead:
+\begin{itemize}
+\item an output to the page and the log (unstarred version)
+\item a calculation on the italic alphabet of the current font family
+\item a calculation on how many characters of the aforementioned alphabet will fit into the current \verb|\columnwidth|
+\end{itemize}
+
+\subsection{Width for a given number of characters}\label{widthgivenchar}
+Conversely on what is discussed in section~\vref{chperwidth}, it may be desirable to obtain the length of a column that will accommodate a specific number of characters. This is done using the\marginpar{\textbackslash tywidthgivchar}\verb|\tywidthgivchar|\index{\textbackslash tywidthgivchar} command.
+
+The command usage is somewhat different from the other commands of the package, since the font switches are accepted \emph{as an optional argument,} while the mandatory argument is the number of characters for the calculations.
+\paragraph{Examples} here are two examples of the command usages:
+\begin{verbatim}
+\tywidthgivchar*{68}
+\end{verbatim}
+will output in terminal (starred version) and log the width to typeset 68 characters with the current font.
+
+\begin{verbatim}
+\tywidthgivchar[\bfseries]{35}
+\end{verbatim}
+Will instead output -- in the page and the log -- the width of the column that will accommodate 35 characters of the bold version of the current font.
+\section{Tabular data}
+The package provides two diagnostic commands, which will output tables when used in the unstarred version -- they will output a list of things in the terminal for the starred version; and also for the log in any ``version’’.
+\subsection{Font tables}
+The \marginpar{\textbackslash tyfonttable} \verb|\tyfonttable|\index{\textbackslash tyfonttable} typesets a table containing
+\begin{itemize}
+\item alphabet length
+\item ex-height
+\item em-width
+\end{itemize}
+for the following font-shapes:
+\begin{itemize}
+\item roman
+\item bold
+\item italic
+\item small case
+\item slanted
+\item sans-serif
+\end{itemize}
+
+The command, nevertheless accepts a switch, which is conceived to printout the data for a font family defined by the \texttt{fontspec} package, via \verb|\newfontfamily|; but any font-family changing command that behaves the same way is just as suitable.
+
+\subsection{Width tables}\label{widthtables}
+The main purpose of the package is the use of the \marginpar{\textbackslash tywidthtable}\verb!\tywidthtable!\index{\textbackslash tywidthtable} command, which will output some suggested widths, which are commonly used \cite{bib:bringhurst,bib:felici} in the professional typesetting world. The starred version, as usual, prints a long list into the terminal.
+
+There are a few remarks:
+\begin{itemize}
+\item where no name is given in parenthesis, the calculation are either provided for reference, or are the author’s personal estimates of useful lengths;
+\item the name in parenthesis refers to methods or calculations given in \cite{bib:bringhurst,bib:felici};
+\item all of the calculations are done on the \emph{em width,} instead of the font \emph{body size,} since they’re almost always the same (see section~\vref{simpleforem}), and when they’re not, I think it would lead to better results
+\item \emph{multicol} means that a setting is most suited for multiple columns 
+\item the number of characters for width is the result of a rounding (as most quantities here reported are) so all of the numbers are to be taken as approximates.
+\end{itemize}
+\part{Notes, details, licensing}
+\section{Calculations}\label{calc}
+The calculations performed by this package are only indicative. The calculations are based on two concepts:
+\begin{description}
+\item[Alphabet length:] this is calculated by measuring the sum of the whole letters without considering specific kernings.
+\item[Mean character width:] this calculation is tricky. In fact using the typefitting table in \cite{bib:bringhurst}, I messed around with the data and found out that the mean char width used there is $\approx 1/(26.5+1\%\cdot \alpha)$ where $\alpha$ is the alphabet length. 
+\item[Use of em:] as it is said before, every calculation uses the \emph{em width} (where applicable) instead of the \emph{character size.}
+\end{description}
+Regarding the mean char width, I don’t know whether the calculation are correct for all languages or just for English. I just found out that since the calculations cannot be other than approximations, these give consistent results, even in Italian.
+\section{Known issues}
+The code works hopefully, and should do fine. Despite that it needs to be worked on, both from the functionality and code prettyness. I will go on and work on these issues. Please mark that I already know them, so don’t be scared by the code
+
+\paragraph{Some dirty tricks} The code has many issues, it seems a garbled mass of somewhat working stuff, but I know there’s space to improve it, starting, for example, by making internal utility functions.
+
+\paragraph{Let’s go global} Also I struggled a bit with the sense of \emph{local} and \emph{global} in \texttt{expl3} language. The code has all the variables set to be global. This is highly undesirable and an urgent step will be to refactor these in order to make them global only if needed.
+
+\paragraph{Command instantiation} The creation of the functions is somewhat suspicious and I need to reinspect that.
+
+\paragraph{Outputs} The way that the output is generated (mainly for the terminal and log) is somewhat dissatisfying. I need to rework that in order to make it more generic.
+
+\paragraph{Required packages} I don’t like depending upon too many packages. Currently I depend on table typesetting packages such as \texttt{array, booktabs}. Since the package could possibly be used without any typeset output, I will consider to introduce a package-wide option to enable the aforementioned packages and functionalities.
+
+\paragraph{No comment} Yes, the code is uncommented, for the most part. I will get onto that too.
+
+\section{Future implementations and roadmap}
+As seen in the previous section, the package is far from complete. I set up a little roadmap:
+\begin{enumerate}
+\item Reworking the code and make it good 
+\item Adding vertical commands (i.e. to calculate textheight)
+\item Rework and make good outputs in log and terminal
+\item Introduce Lua\TeX{} specific commands and functionalities 
+\end{enumerate}
+\section{Changelog}
+This is a stub and will be until version 1.0 will be released, since the package is still in continuous development. The minor revisions indicate a refactoring or a new functionalities. Subminor revision track tests and tunings
+\begin{description}
+\item[v0.0.7] First release
+\item[v0.1.0]  Completed the \emph{simple commands}
+\item[v0.2.0] Introduced the \emph{fonts table}
+\item[v0.3.0] Introduced the \emph{width table}
+\item[v0.3.8] Fixed various issues, second release
+\end{description}
 \section{Acknowledgements}
-I would like to thank: \TeX nician, Christian Hupfer, Enrico Gregorio, Joseph Wright, David Carlisle and Barbara Beeton for their support and kind remarks. Please mark that they know nothing about the code inside the package, but provided many useful tips and tools for me to develop this. They cannot be blamed for anything that can be wrong in this package.
+Special thanks to Enrico Gregorio, which, apart from helping me -- especially for the Lua\TeX{} safe no-kerning code -- also tried to teach me \texttt{expl3} and some of its nuisances. I’m a bit ashamed to be such an awful student.
+I would also like to thank very much: \TeX nician, Joseph Wright, David Carlisle and Barbara Beeton for their support and kind remarks. 
+\textbf{Please mark that none of the people mentioned above have any idea on how I chose to implement (and typeset) the code inside the package, but they nevertheless provided many useful tips and tools for me to develop this. They cannot be blamed for anything that can be wrong in this package.}
 \section{License and contacts}
-This package is released under the \emph{\LaTeX{} Project Public License,} version 1.3c or later. See \url{http://www.latex-project.org/lppl.txt}.
+This package is released under the \emph{\LaTeX{} Project Public License,} version 1.3c or later. See \url{http://www.latex-project.org/lppl.txt}.\smallskip
 
 The package is maintained by \textsc{Daniele Ratti.} 
 
 Email: \texttt{ilfuria+tya at gmail dot com}
+
+Repository: \url{https://github.com/ilFuria/typoaid/tree/master}
+
+\begin{thebibliography}{9}
+\addcontentsline{toc}{section}{\bibname}
+\bibitem{bib:bringhurst} R.~Bringhurst, \emph{The elements of typographic style}, version~4.1, 2015.
+\bibitem{bib:felici} J.~Felici, \emph{The complete manual of typography}, second edition, 2012.
+\end{thebibliography}
+
+\printindex
 \end{document}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/typoaid/typoaid.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/typoaid/typoaid.sty	2017-04-26 22:45:55 UTC (rev 44066)
+++ trunk/Master/texmf-dist/tex/latex/typoaid/typoaid.sty	2017-04-26 22:46:08 UTC (rev 44067)
@@ -4,104 +4,204 @@
 %% E-mail: ilfuria+tya at 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}\\
@@ -108,5 +208,210 @@
 	}
 }
 
+\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



More information about the tex-live-commits mailing list