summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/typoaid/README.md (renamed from Master/texmf-dist/doc/latex/typoaid/README)0
-rw-r--r--Master/texmf-dist/doc/latex/typoaid/typoaid.pdfbin333438 -> 327263 bytes
-rw-r--r--Master/texmf-dist/doc/latex/typoaid/typoaid.tex83
-rw-r--r--Master/texmf-dist/tex/latex/typoaid/typoaid.sty1005
4 files changed, 851 insertions, 237 deletions
diff --git a/Master/texmf-dist/doc/latex/typoaid/README b/Master/texmf-dist/doc/latex/typoaid/README.md
index cd45aca141c..cd45aca141c 100644
--- a/Master/texmf-dist/doc/latex/typoaid/README
+++ b/Master/texmf-dist/doc/latex/typoaid/README.md
diff --git a/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf b/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf
index 80f72ba68f3..68158fe6d08 100644
--- a/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf
+++ b/Master/texmf-dist/doc/latex/typoaid/typoaid.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/typoaid/typoaid.tex b/Master/texmf-dist/doc/latex/typoaid/typoaid.tex
index bcecc17156c..6faf9859d4c 100644
--- a/Master/texmf-dist/doc/latex/typoaid/typoaid.tex
+++ b/Master/texmf-dist/doc/latex/typoaid/typoaid.tex
@@ -1,16 +1,19 @@
\documentclass{article}
+\usepackage[marginparwidth=80pt]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
+\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{metalogo}
\usepackage[makeindex]{imakeidx}
\usepackage{microtype}
\usepackage{varioref}
\usepackage{hyperref}
+\usepackage{typoaid}
\usepackage{url}
\author{Daniele Ratti}
\makeindex[intoc]
-\title{The Typo Aid Package (v.0.3.8)}
+\title{The Typo Aid Package (v.0.4.7)}
\makeatletter
\let\@@oldmpar\marginpar
\renewcommand{\marginpar}[1]{\@@oldmpar{\small#1}}
@@ -19,7 +22,7 @@
\maketitle
\begin{abstract}
-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
+The typoaid 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}
\tableofcontents
\part{User manual}
@@ -88,6 +91,45 @@ will output in terminal (starred version) and log the width to typeset 68 charac
\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{Height commands}
+To determine the height of a given text, usually \cite{bib:bringhurst} one can determine a \emph{form factor} to which its text will comply, and then will tweak it in order to accommodate an \emph{integer number of lines.}
+
+The \marginpar{\texttt{\textbackslash tyheight}} \verb!\tyheight!\index{\textbackslash tyheight} command gives an hint to the user, outputting the number of lines. The command comes with the two usual \texttt{typoaid} starred scheme, but its parameters are a bit more complex since:
+\begin{itemize}
+\item it accepts a first optional parameter (in square brackets) which indicates a font switch
+\item it accepts two ``mandatory’’ (i.e. curly braces-delimited) arguments, indicating resp:
+\begin{enumerate}
+\item the height to be used (if no parameter is given, the current value of \texttt{textheight} is used)
+\item the baseline skip to be used (if no parameter is given, the current value of \texttt{baselineskip} is used
+\end{enumerate}
+\item accepts also a trailing optional parameter (square brackets) which has the optional
+\end{itemize}
+
+\paragraph{Examples}
+The command syntax may appear complex, but it’s actually modeled around what I think it would be its more common usage. Anyway here are some examples:
+\begin{verbatim}
+\tyheight{}{}
+\end{verbatim}
+gives the height and number of lines for current data.
+
+\begin{verbatim}
+\tyheight{538pt}{13pt}
+\end{verbatim}
+gives the number of rows in $538$pt using a $13$pt baselineskip.
+
+\begin{verbatim}
+\tyheight[\bfseries]{}{13pt}
+\end{verbatim}
+will output the number of lines in \texttt{bfseries} with $13$ pt baselineskip and current height
+
+\begin{verbatim}
+\tyheight[\itshape]{540pt}{13.6pt}[11pt]
+\end{verbatim}
+will add the condition of the $11$ pt size. Of course one can use other values and data.
+
+\subparagraph{Note:} The other width command currently included are tabular ones, thus given in section~\vref{heighttables}.
+
\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}
@@ -120,6 +162,29 @@ There are a few remarks:
\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}
+
+\subsection{Height tables}\label{heighttables}
+The \marginpar{\textbackslash tyformfactorheight} \verb|\tyformfactorheight|\index{\textbackslash tyformfactorheight} is the main \emph{vertical} command and is used to have a guideline on how tall the text should be.
+
+In common practice (at least the author’s), the design tends to have a specific \emph{form factor,} i.e., a given ratio between text height and width. This will have to be matched with the need to have an integer number of lines in the text height.
+
+The command, then, will come in two flavours (starred and unstarred) and will always accept the following parameters, given in order:
+\begin{itemize}
+\item an optional font family switch (in square brackets)
+\item a mandatory dimension for the text height, in curly braces; if not given the package will assume \texttt{columnwidth}
+\item a mandatory \emph{form factor} parameter which \emph{cannot be empty}
+\item an optional square bracketed parameter, to specify the baseline skip to be used, defaulting to the current one.
+\end{itemize}
+
+Upon executing, the command will output (either in the page or the terminal, plus log) three rows containing the height, the number of lines and the form factor; these will be:
+\begin{enumerate}
+\item the \emph{strict} result obtained multiplying the width by the form factor. Could result in non-integer number of lines per height
+\item the \emph{truncated number of lines} resulted from the previous calculation, with the updated form factor and height.
+\item the \emph{up rounded number of lines} resulted from the first calculation, with the updated form factor and height
+\end{enumerate}
+
+This way the user can specify some form-factor guidelines, and see which form factors are the nearest which accommodate an integer number of lines.
+
\part{Notes, details, licensing}
\section{Calculations}\label{calc}
The calculations performed by this package are only indicative. The calculations are based on two concepts:
@@ -132,23 +197,14 @@ Regarding the mean char width, I don’t know whether the calculation are correc
\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{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. Unfortunately the problem became more and more apparent from v.0.4.0, but I’m not capable of doing it any other way
\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}
@@ -160,8 +216,9 @@ This is a stub and will be until version 1.0 will be released, since the package
\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
+\item[v0.4.7] Fixed and prettied all the code, introduced vertical commands
\end{description}
-\section{Acknowledgements}
+\section{Acknowledgments}
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.}
diff --git a/Master/texmf-dist/tex/latex/typoaid/typoaid.sty b/Master/texmf-dist/tex/latex/typoaid/typoaid.sty
index 759c3b5bb6a..16bb289b99a 100644
--- a/Master/texmf-dist/tex/latex/typoaid/typoaid.sty
+++ b/Master/texmf-dist/tex/latex/typoaid/typoaid.sty
@@ -11,11 +11,16 @@
%% 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
+%% 0.4.0 massive code refactoring, presetting tables
+%% 0.4.1 tables and variables fine tuning
+%% 0.4.2 using the kernel provided tmpa and tmpb; starting on vertical data
+%% 0.4.3 finishing vertical table
+%% 0.4.5 updated vertical table and starred commands
+%% 0.4.7 finished vertical tst
%% ---------------------------------------------------------------
\RequirePackage{expl3}
-\ProvidesExplPackage{typoaid}{2017/04/25}{0.3.8} {Typographic Aid}
-\RequirePackage{xparse}
+\ProvidesExplPackage{typoaid}{2017/05/07}{0.4.7} {Typographic Aid}
\RequirePackage{array}
\RequirePackage{booktabs}
\RequirePackage{siunitx}
@@ -34,9 +39,9 @@
\int_new:N\g__typoAid_CharPerRow_int
-\dim_new:N\g__typoAid_dummy_dim
+\dim_new:N\g__typoAid_SwitchedFontSize_dim
-\fp_new:N\g__typoAid_alphDivider_fp
+\dim_new:N\l__typoAid_local_dim
\tl_const:Nn \c__typoAid_lc_alphabet_tl {abcdefghijklmnopqrstuvwxyz}
@@ -44,7 +49,7 @@
\str_const:Nn\c__typoAid_name_string{TypoAid}
-\str_const:Nx\c__typoAid_typeout_string{TypoAid\iow_newline: *~Font~switch~given:~}
+\str_const:Nx\c__typoAid_typeout_string{TypoAid\iow_newline:*~ Font~switch~given:~}
%% END CONSTANTS AND VARIABLES
@@ -72,346 +77,898 @@
}
}
+ % A function to calculate the alphabet length and
+ % mean char width
\cs_new_protected:Npn\__typoAid_calcAlph:n #1
{
- \__typoAid_typoAlphabet:n{#1}
+ % Typesets the alphabet
+ \__typoAid_typoAlphabet:n{#1}
+
+ % Globally sets the alphabet dimension as the width of the alphabet box
\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}}
+
+ % sets the local coefficient that determines the
+ % mean char width as 26.5+ 1% alph length
+ \fp_set:Nn\l_tmpa_fp
+ {
+ 26.5+1/100*\dim_to_decimal:n{\g__typoAid_Alphabet_dim}
+ }
+
+ % globally sets the mean char width as alphabet/coefficient
+ \dim_gset:Nn\g__typoAid_MeanChar_dim
+ {
+ \fp_to_dim:n
+ {
+ \dim_to_decimal:n
+ {
+ \g__typoAid_Alphabet_dim
+ }/\fp_use:N\l_tmpa_fp
+ }
+ }
}
-\cs_new_protected:Npn\__typoAid_calcEx:n #1{%
+%% A function to calculate the ex width for a given font switch
+\cs_new_protected:Npn\__typoAid_calcEx:n #1
+{
\__typoAid_smuggle:nn { #1 }
{
\dim_gset:Nn \g__typoAid_ExHeight_dim { \dim_eval:n { 1ex } }
}
}
-\cs_new_protected:Npn\__typoAid_calcEm:n#1{
+%% A function that calculates the current em width for the font switch
+\cs_new_protected:Npn\__typoAid_calcEm:n#1
+{
\__typoAid_smuggle:nn { #1 }
{
\dim_gset:Nn \g__typoAid_EmWidth_dim { \dim_eval:n { 1em } }
}
}
+%% A function to store the font size for a specific switch
+\cs_new_protected:Npn\__typoAid_calcFsize:n#1
+{
+ \__typoAid_smuggle:nn{ #1 }
+ {
+ \dim_gset:Nn\g__typoAid_SwitchedFontSize_dim{\fp_to_dim:n{\f@size}}
+ }
+}
+
+%% Calculates the numer of characters that can be set in
+%% a column of a given width (parameter)
\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}}}}
+ % the char per row are a global variable, thus globally set
+ \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}
+ }
+ }
+ }
}
+%% Calculates all the basic things, including char per width
\cs_new_protected:Npn\__typoAid_calcAll:nn#1#2
{
\__typoAid_calcAll:n{#1}
\__typoAid_calcCharPW:n{#2}
}
+%% Calculates the alphabet, the ex height and em width
\cs_new_protected:Npn\__typoAid_calcAll:n#1
{
\__typoAid_calcAlph:n{#1}
\__typoAid_calcEx:n{#1}
\__typoAid_calcEm:n{#1}
+ \__typoAid_calcFsize:n{#1}
+}
+
+%% Calculates the number of rows in a selected height
+%% Params
+%% 1-> font switch (for body size purposes)
+%% 2-> baseline skip
+%% 3-> height
+\cs_new_protected:Npn\__typoAid_nrRows:nnn#1#2#3
+{
+ % calculates the font size
+ \__typoAid_calcFsize:n{#1}
+
+ % sets the local variables
+ \dim_set:Nn\l_tmpa_dim{\dim_eval:n{#2}}
+ \dim_set:Nn\l_tmpb_dim{\dim_eval:n{#3}}
+ \msg_term:n{\dim_eval:n{#2}~\dim_eval:n{#3}}
+ % subtracts the curent font size from the height
+ \dim_sub:Nn\l_tmpb_dim{\dim_use:N\g__typoAid_SwitchedFontSize_dim}
+
+ %performs the calculations
+ \fp_gset:Nn\g_tmpa_fp
+ {
+ 1+\dim_ratio:nn
+ {\l_tmpb_dim}
+ {\l_tmpa_dim}
+ }
+
+
}
+%% Calculates the height for a given number of rows
+%% Params
+%% 1-> font switch for size
+%% 2-> number of desired rows (int!!)
+%% 3-> baselineskip
+\cs_new_protected:Npn\__typoAid_HeightForRows:nnn#1#2#3
+{
+ % calculates the font size
+ \__typoAid_calcFsize:n{#1}
+
+ % sets the local variables
+ \dim_set:Nn\l_tmpa_dim{\dim_eval:n{#3}*(\int_eval:n{#2}-1)}
+
+ \dim_add:Nn\l_tmpa_dim{\g__typoAid_SwitchedFontSize_dim}
+
+ \dim_gset:Nn\g_tmpa_dim{\dim_use:N\l_tmpa_dim}
+
+}
%% END CALCULATIONS
%% LOGS AND STRINGS
-\cs_set_protected:Npn\__typoAid_log:nn #1#2
+
+%% A function that logs a specific string, with "Typoaid as a header"
+\cs_new:Npn\__typoAid_log:nn #1#2
{
- \msg_log:n{\c__typoAid_typeout_string~#2 \iow_newline:.~#1}
+ \msg_log:n{\c__typoAid_typeout_string~#2 \\ #1}
}
-\cs_set_protected:Npn\__typoAid_column_string:n#1
+%% New function that typesets the char per width
+%% using the current column width to fit them in
+%% it also typesets the switch given
+\cs_new: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}
+ \__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}
+%% Typesets the alphabet length
+\cs_new:Nn\__typoAid_Alphabet_string:
+{
+ Alphabet~length:~\dim_use:N\g__typoAid_Alphabet_dim
+}
-\cs_new:Nn\__typoAid_ExHeight_string:{%
+%% Typesets the ex height
+\cs_new:Nn\__typoAid_ExHeight_string:
+{
Ex~height:~\dim_use:N\g__typoAid_ExHeight_dim
}
-\cs_new:Nn\__typoAid_EmWidth_string:{%
+%% typesets the em width
+\cs_new:Nn\__typoAid_EmWidth_string:
+{
Em~width:~\dim_use:N\g__typoAid_EmWidth_dim
}
-\cs_new:Npn\__typoAid_logWidth:nn#1#2
+%% Logs a column width and char per row
+\cs_new:Npn\__typoAid_logWidthData:nn#1#2
+{
+ \c__typoAid_name_string;~data~with~font~mod:~\tl_to_str:n{#2}\\
+ column:~\dim_to_decimal_in_unit:nn{#1}{1pt}~pt~or~\dim_to_decimal_in_unit:nn{#1}{1pc}~pc\\
+ \int_use:N\g__typoAid_CharPerRow_int~char~per~row
+}
+
+%% Logs the data regarding a specific fontshape
+\cs_new:Npn\__typoAid_logFontshapeData: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%
+ \c__typoAid_name_string.~Font~modifier: \tl_to_str:n{#1}\\
+ ~Switch:~#2\\
+ ~Alphabet:~\dim_use:N\g__typoAid_Alphabet_dim\\
+ ~Ex~height:~\dim_use:N\g__typoAid_ExHeight_dim\\
+ ~Em~width:~\dim_use:N\g__typoAid_EmWidth_dim
}
-\cs_new:Npn\__typoAid_logGeneral:nn#1#2
+%%Saves the tokenlist for the font table
+\cs_new:Npn\__typoAid_PrepareFontshapeRow: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~
+ %resets the tokenlist
+ \tl_gclear:N\g_tmpa_tl
+
+ % % calculates the font metrics
+ \__typoAid_calcAll:n{#1#2}
+
+ %log
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#1}{#2}}
+
+ %saves the row
+ \tl_gset:Nn\g_tmpa_tl
+ {
+ \texttt{\tl_to_str:n{#2}}&
+ \dim_use:N\g__typoAid_Alphabet_dim&
+ \dim_use:N\g__typoAid_ExHeight_dim&
+ \dim_use:N\g__typoAid_EmWidth_dim
+ }
+}
+
+%% Calculates the data for the typeseting of the width table
+%% Parameters
+%% 1-> multiplier
+%% 2-> dimension
+\cs_new:Npn\__typoAid_CalculateWidthTableData:nn#1#2
+{
+
+ % Saves the local value of the desired dimension
+ \dim_gset:Nn\g_tmpa_dim
+ {
+ \fp_to_dim:n
+ {
+ \fp_eval:n{#1}*\dim_eval:n{#2}
+ }
+ }
+ % Calculates the char fitting in the dimension
+ \__typoAid_calcCharPW:n{\g_tmpa_dim}
+}
+
+%% Saves a row for the width table
+%% Params
+%% 1 -> multiplier
+%% 2 -> dimension
+%% 3 -> font switch
+%% 4 -> first row text
+\cs_new:Npn\__typoAid_prepareWidthTableRow:nnnn#1#2#3#4
+{
+
+ \__typoAid_CalculateWidthTableData:nn{#1}{#2}
+
+ % logs
+ \msg_log:n{\__typoAid_logWidthData:nn{\g_tmpa_dim}{#3}}
+ %clears and sets the token list
+ \tl_gclear:N\g_tmpa_tl
+
+ \tl_gset:Nn\g_tmpa_tl
+ {
+ \tl_to_str:n{#4}&
+ \dim_to_decimal_in_unit:nn{\g_tmpa_dim}{1pt}&
+ \dim_to_decimal_in_unit:nn{\g_tmpa_dim}{1pc}&
+ \int_use:N\g__typoAid_CharPerRow_int
+ }
+}
+
+%% Saves a row for the widthTable
+%% Params
+%% 1->form factor
+%% 2-> number of lines
+%% 3-> string
+%% 4-> height
+\cs_new:Nn\__typoAid_PrepareHeightTableRow_tl:nnnn
+{
+ \tl_gclear:N\g_tmpa_tl
+ \tl_gset:Nn\g_tmpa_tl
+ {
+ #3&
+ \dim_to_decimal_in_unit:nn{#4}{1pt}&
+ \dim_to_decimal_in_unit:nn{#4}{1pc}&
+ \fp_eval:n{#2}&
+ \fp_eval:n{#1}
+ }
+}
+
+%% Prepares the log and terminal for starred table version
+%% PArams
+%% 1-> multiplier
+%% 2-> dimension
+%% 3 -> switch
+\cs_new:Npn\__typoAid_WidthTableLog:nnn#1#2#3
+{
+ % Performs the calculation
+ \__typoAid_CalculateWidthTableData:nn{#1}{#2}
+
+ \msg_term:n{\__typoAid_logWidthData:nn{\g_tmpa_dim}{#3}}
+ \msg_log:n{\__typoAid_logWidthData:nn{\g_tmpa_dim}{#3}}
+}
+
+%% Logs the data for the form factor table
+%% Params
+%% 1->width
+%% 2->switch
+%% 3->form factor
+%% 4 ->rows p height
+\cs_new:Nn\__typoAid_formfactor_log:nnnn
+{
+ \msg_log:n
+ {
+ \c__typoAid_name_string\iow_newline:.~
+ Form~factor: \fp_eval:n{#3}~for~switch:\tl_to_str:n{#2}\iow_newline:.~
+ Width:~\dim_to_decimal_in_unit:nn{#1}{1pt}~pt~(\dim_to_decimal_in_unit:nn{#1}{1pc}~pc)\iow_newline:~.
+ Rows~per~height:~\fp_eval:n{#4}
+ }
+
}
%% END LOGS AND STRINGS
-%% PUBLIC
+%% PUBLIC INTERFACE
+%% Public command to print the alphabet in log term and page
\NewDocumentCommand{\typrintalph}{ s m }
{
+ % First perform the calculation
\__typoAid_calcAlph:n{#2}
- \IfBooleanTF{#1}{%
- \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~\iow_newline:*~\__typoAid_Alphabet_string:}%
- }{%
- \__typoAid_Alphabet_string:%
- }%
+
+ % Determines whether it has to output to the term or page
+ \IfBooleanTF{#1}
+ {
+ \msg_term:n
+ {
+ \c__typoAid_typeout_string \tl_to_str:n{#2}\\
+ \__typoAid_Alphabet_string:
+ }
+ }{
+ \__typoAid_Alphabet_string:
+ }
+
+ % Always types out in the log
\__typoAid_log:nn{\__typoAid_Alphabet_string:}{#2}
}
-\NewDocumentCommand{\typrintex}{ s m }{%
+%% Public command to printout the ex height
+\NewDocumentCommand{\typrintex}{ s m }
+{
+ % Calculates the height
\__typoAid_calcEx:n{#2}
- \IfBooleanTF{#1}{%
- \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~ \iow_newline:*~ \__typoAid_ExHeight_string:}%
- }{%
- \__typoAid_ExHeight_string:%
- }%
- \__typoAid_log:nn{\__typoAid_ExHeight_string:}{ #2}
+
+ % decides term vs page
+ \IfBooleanTF{#1}
+ {
+ \msg_term:n
+ {
+ \c__typoAid_typeout_string \tl_to_str:n{#2}\\
+ \__typoAid_ExHeight_string:
+ }
+ }{
+ \__typoAid_ExHeight_string:
+ }
+
+ % log
+ \__typoAid_log:nn{\__typoAid_ExHeight_string:}{#2}
}
-\NewDocumentCommand{\typrintem}{s m}{%
+%% Public command to printout the em width
+\NewDocumentCommand{\typrintem}{s m}
+{
+ %Performs the calculation
\__typoAid_calcEm:n{#2}
- \IfBooleanTF{#1}{%
- \msg_term:n{\c__typoAid_typeout_string\exp_not:N#2~ \iow_newline:*~ \__typoAid_EmWidth_string:}%
- }{%
+
+ % Selects the main output
+ \IfBooleanTF{#1}
+ {
+ \msg_term:n
+ {
+ \c__typoAid_typeout_string\tl_to_str:n{#2}\\
+ \__typoAid_EmWidth_string:
+ }
+ }{
\__typoAid_EmWidth_string:
- }%
+ }
+
+ %log
\__typoAid_log:nn{\__typoAid_EmWidth_string:}{ #2}
}
-
+%% Typesets all the simple commands
\NewDocumentCommand{\tyallsimple}{ s m}
{
- \IfBooleanTF{#1}
- {
- \typrintalph*{#2}\\
- \typrintex*{#2}\\
- \typrintem*{#2}\\
- }{
- \typrintalph{#2}\\
- \typrintex{#2}\\
- \typrintem{#2}\\
+ % Just propagates the arguments
+ \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\\
+%% Public command to typeset the font shapes table
+\NewDocumentCommand{\tyfonttable}{ s m }
+{
+
+ % Determine the main output
+ \IfBooleanTF{#1}
+ {
+ % Calculate everything
+ \__typoAid_calcAll:n{#2}
+
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{upshape}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{upshape}}
+ % redo the calculation for bfseries
\__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\\
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{bfseries}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{bfseries}}
- \__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\\
+ % redo the calculation for itshape
+ \__typoAid_calcAll:n{\itshape#2}
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{itshape}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{itshape}}
- \__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\\
-
+ % redo the calculation for small caps
+ \__typoAid_calcAll:n{\scshape#2}
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{scshape}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{scshape}}
+
+ % redo the calculation for slanted
+ \__typoAid_calcAll:n{\slshape#2}
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{slshape}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{slshape}}
+
+ % redo the calculation for sans serif
\__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}
+ %output
+ \msg_log:n{\__typoAid_logFontshapeData:nn{#2}{sffamily}}
+ \msg_term:n{\__typoAid_logFontshapeData:nn{#2}{sffamily}}
+ }{
+ % creates a table, centered
+ \begin{table}\centering
+ % the strut is for separating a bit the caption from the table
+ \caption{\strut Font~metrics~for~switch:~\tl_to_str:n{#2}}
+
+ % the siuntix columns are useful for the points, but need to be reconsidered, possibly
+ \begin{tabular}{lSSS}
+ \toprule
+ % Header row; note that multicolumn is used due to the siunitx columns
+ Font~switch &
+ \multicolumn{1}{r}{Alphabet~length} &
+ \multicolumn{1}{r}{Ex~height} &
+ \multicolumn{1}{r}{Em~width}\\
+
+ \midrule
+
+ % Calculates and typesets for each row type
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\upshape}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\bfseries}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\itshape}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\scshape}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\slshape}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_PrepareFontshapeRow:nn{#2}{\sffamily}
+ \tl_use:N\g_tmpa_tl\\
+
+ \bottomrule
+ \end{tabular}
\end{table}
}
}
+%% Calculates and typesets the width data
\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}}
+ \__typoAid_calcAll:nn{#2}{\columnwidth}
+ \IfBooleanTF{#1}
+ {
+
+ \msg_term:n{\__typoAid_logWidthData:nn{\columnwidth}{#2}}
+ \msg_log:n{\__typoAid_logWidthData:nn{\columnwidth}{#2}}
- }{%
-
+
+ \__typoAid_WidthTableLog:nnn{1.5}{\g__typoAid_Alphabet_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{2}{\g__typoAid_Alphabet_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{2.5}{\g__typoAid_Alphabet_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{24}{\g__typoAid_EmWidth_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{30}{\g__typoAid_EmWidth_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{66}{\g__typoAid_MeanChar_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{30}{\g__typoAid_MeanChar_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{44}{\g__typoAid_MeanChar_dim}{#2}
+ \__typoAid_WidthTableLog:nnn{50}{\g__typoAid_MeanChar_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\\
+ \toprule
+ Description&
+ \multicolumn{1}{c}{Value(pt)}&
+ \multicolumn{1}{c}{Value(pc)}&
+ \multicolumn{1}{c}{Char~per~row}\\
+ \midrule
+ \msg_log:n{\__typoAid_logWidthData: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\\
+
+ % Prepares the row
+ \__typoAid_prepareWidthTableRow:nnnn
+ {1.5}
+ {\g__typoAid_Alphabet_dim}
+ {#2}
+ {1.5~alphabet~times~(Felici)}
+ % typesets it
+ \tl_use:N\g_tmpa_tl \\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {2}
+ {\g__typoAid_Alphabet_dim}
+ {#2}
+ {2~alphabet~times~(Felici)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {2.5}
+ {\g__typoAid_Alphabet_dim}
+ {#2}
+ {2.5~alphabet~times}
+ \tl_use:N\g_tmpa_tl\\
- \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
+ \__typoAid_prepareWidthTableRow:nnnn
+ {24}
+ {\g__typoAid_EmWidth_dim}
+ {#2}
+ {2~em~in~pica~(Felici)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {30}
+ {\g__typoAid_EmWidth_dim}
+ {#2}
+ {2.5~em~in~pica~(Felici)}
+ \tl_use:N\g_tmpa_tl\\
+ \__typoAid_prepareWidthTableRow:nnnn
+ {66}
+ {\g__typoAid_MeanChar_dim}
+ {#2}
+ {66~char~per~row~(Bringhurst)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {30}
+ {\g__typoAid_MeanChar_dim}
+ {#2}
+ {30~char~per~row~multicol~(Bringhurst)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {44}
+ {\g__typoAid_MeanChar_dim}
+ {#2}
+ {44~char~per~row~multicol~(Bringhurst)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \__typoAid_prepareWidthTableRow:nnnn
+ {50}
+ {\g__typoAid_MeanChar_dim}
+ {#2}
+ {50~char~per~row~multicol~(Bringhurst)}
+ \tl_use:N\g_tmpa_tl\\
+
+ \bottomrule
\end{tabular}
\end{table}
}
}
-\NewDocumentCommand{\tychperwidth}{som}{%
+%% Calculates the number of character fitting in a row of given width
+%% Parameters
+%% 1-> star
+%% 2-> (optional) width
+%% 3 -> switch
+\NewDocumentCommand{\tychperwidth}{s o m}
+{
+ % Performs the calculations of the given switch
\__typoAid_calcAll:n{#3}
+
+ % If no optional parameter is given, sets the width to the column
\IfNoValueTF{#2}
{
- \dim_gset:Nn\g__typoAid_dummy_dim{\columnwidth}
+ \dim_set:Nn\l_tmpa_dim{\columnwidth}
}
{
- \dim_gset:Nn\g__typoAid_dummy_dim{#2}
+ \dim_set:Nn\l_tmpa_dim{#2}
}
- \__typoAid_calcCharPW:n{\g__typoAid_dummy_dim}
+ % Calculates the carh per width
+ \__typoAid_calcCharPW:n{\l_tmpa_dim}
+ %% determines the output
\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}}
+ \msg_term:n
+ {
+ \c__typoAid_name_string;~Calculated:~\int_eval:n{\g__typoAid_CharPerRow_int}~chars~in~width:~
+ \dim_use:N\l_tmpa_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}
+ \dim_eval:n{\l_tmpa_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}}
+ \msg_log:n
+ {
+ \c__typoAid_name_string;~Calculated:~\int_eval:n{\g__typoAid_CharPerRow_int}~chars~in~width:~
+ \dim_eval:n{\l_tmpa_dim}~and~switch~\tl_to_str:n{#3}
+ }
}
-\NewDocumentCommand{\tywidthgivchar}{sO{}m}{%
+%% Gives the width to obtain the given char number
+%% Parameters
+%% 1-> star
+%% 2-> (optional) switch
+%% 3-> char number
+\NewDocumentCommand{\tywidthgivchar}{sO{}m}
+{
+ % Performs the calculations
\__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)
+ \dim_set:Nn\l_tmpa_dim
+ {
+ \fp_to_dim:n
+ {
+ \dim_to_fp:n{\g__typoAid_MeanChar_dim}*\int_eval:n{#3}
+ }
+ }
+
+ %Determines the output
+ \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{\l_tmpa_dim}~(\dim_to_decimal_in_unit:nn{\l_tmpa_dim}{1pc}~pc)}
+ }{
+ In~order~to~obtain~the~required~\int_eval:n{#3}~characters~per~column,~
+ the~column~should~have~a~width~of~
+ \dim_eval:n{\l_tmpa_dim}~(\dim_to_decimal_in_unit:nn{\l_tmpa_dim}{1pc}~pc)
}
+ %log
\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)}
+ colwidth:~\dim_eval:n{\l_tmpa_dim}~(\dim_to_decimal_in_unit:nn{\l_tmpa_dim}{1pc}~pc)}
+}
+
+%% Command to evaluate the number of rows in a specific height
+%% Parameters
+%% 1-> star
+%% 2-> optional font family switch
+%% 3-> height
+%% 4-> baseline skip
+%% 5-> optional font height
+\NewDocumentCommand{\tyheight}{sO{}mmo}
+{
+ \tl_if_blank:nTF{#3}
+ {
+
+ \dim_set:Nn\l_tmpa_dim{\dim_use:N\textheight}
+ }{
+
+ \dim_set:Nn\l_tmpa_dim{\dim_eval:n{#3}}
+ }
+
+ \tl_if_blank:nTF{#4}
+ {
+ \dim_set:Nn\l_tmpb_dim{\dim_use:N\baselineskip}
+ }{
+ \dim_set:Nn\l_tmpb_dim{\dim_eval:n{#4}}
+ }
+
+ \__typoAid_calcFsize:n{#2}
+
+ \IfNoValueTF{#5}
+ {
+ \dim_gsub:Nn\l_tmpa_dim{\dim_use:N\g__typoAid_SwitchedFontSize_dim}
+ }{
+ \dim_gsub:Nn\l_tmpa_dim{\dim_eval:n{#5}}
+ }
+
+ \fp_set:Nn\l_tmpa_fp
+ {
+ \dim_ratio:nn{\l_tmpa_dim}{\l_tmpb_dim}+1
+ }
+
+ \IfBooleanTF{#1}
+ {
+ \msg_term:n{\c__typoAid_name_string;\iow_newline:*~The~height~of~\dim_eval:n{
+ \tl_if_blank:nTF{#3}{\dim_use:N\textheight}{\dim_eval:n{#3}}}
+ ~could~contain~\fp_eval:n{\l_tmpa_fp}~lines~of~text~with~switch~\tl_to_str:n{#2}}
+ }{
+ The~height~of~\dim_eval:n
+ {
+ \tl_if_blank:nTF{#3}{\dim_use:N\textheight}{\dim_eval:n{#3}}
+ }~could~contain~\fp_eval:n{\l_tmpa_fp}~lines~of~text~with~switch~\tl_to_str:n{#2}
+ }
+
+ \msg_log:n{\c__typoAid_name_string;\iow_newline:*~The~height~of~\dim_eval:n
+ {
+ \tl_if_blank:nTF{#3}{\dim_use:N\textheight}{\dim_eval:n{#3}}
+ }~could~contain~\fp_eval:n{\l_tmpa_fp}~lines~of~text~with~switch~\tl_to_str:n{#2}}
+}
+
+%% Command to evaluate the number of rows in a specific height
+%% Parameters
+%% 1-> star
+%% 2-> optional font family switch
+%% 3-> width
+%% 4-> form factor
+%% 5-> optional baselineskip
+\NewDocumentCommand{\tyformfactorheight}{ s O{} m m O{\baselineskip}}
+{
+ \__typoAid_calcFsize:n{#2}
+
+ \dim_set:Nn\l__typoAid_local_dim{\dim_eval:n{#5}}
+
+ \tl_if_blank:nTF{#3}
+ {
+ \dim_set:Nn\l_tmpa_dim{\dim_use:N\columnwidth}
+ }{
+ \dim_set:Nn\l_tmpa_dim{#3}
+ }
+
+ \IfBooleanTF{#1}
+ {
+ % FIRST ROW
+ \dim_gset:Nn\g_tmpb_dim
+ {
+ \fp_to_dim:n
+ {
+ \fp_eval:n{#4}*\dim_eval:n{\l_tmpa_dim}
+ }
+ }
+
+ \__typoAid_nrRows:nnn{#2}{\l__typoAid_local_dim}{\g_tmpb_dim}
+
+ \msg_term:n
+ {
+ \c__typoAid_name_string\iow_newline:*~
+ Form~factor: \fp_eval:n{#4}~for~switch:\tl_to_str:n{#2}\iow_newline:*~
+ Width:~ \dim_to_decimal_in_unit:nn
+ {\g_tmpb_dim}{1pt}~pt~
+ (\dim_to_decimal_in_unit:nn
+ {\g_tmpb_dim}{1pc}~pc)\iow_newline:*~
+ Rows~per~height:~\fp_eval:n{round(\g_tmpa_fp,3)}
+
+ }
+ \__typoAid_formfactor_log:nnnn{\g_tmpb_dim}{#2}{\fp_eval:n{round(\g_tmpa_fp,3)}}{#4}
+
+ %% SECOND ROW
+ \fp_set:Nn\l_tmpa_fp{\fp_eval:n{\g_tmpa_fp}}
+
+ \int_gset:Nn\g_tmpa_int{\fp_eval:n{trunc (\g_tmpa_fp)}}
+
+ \__typoAid_HeightForRows:nnn{#1}{\g_tmpa_int}{\l__typoAid_local_dim}
+
+ \msg_term:n
+ {
+ \c__typoAid_name_string\iow_newline:*~
+ Form~factor: \fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }~
+ ~for~switch:\tl_to_str:n{#2}\iow_newline:*~
+ Width:~ \dim_to_decimal_in_unit:nn
+ {\g_tmpa_dim}{1pt}~pt~
+ (\dim_to_decimal_in_unit:nn
+ {\g_tmpa_dim}{1pc}~pc)\iow_newline:*~
+ Rows~per~height:~\int_eval:n{\g_tmpa_int}
+ }
+ \__typoAid_formfactor_log:nnnn
+ {\g_tmpa_dim}
+ {#2}
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }}
+ {\g_tmpa_int}
+ %third row
+ \fp_set:Nn\l_tmpa_fp{\fp_eval:n{\g_tmpa_fp}}
+
+ \int_gset:Nn\g_tmpa_int{\fp_eval:n{trunc \g_tmpa_fp}+1}
+
+ \__typoAid_HeightForRows:nnn{#1}{\g_tmpa_int}{\l__typoAid_local_dim}
+
+ \msg_term:n
+ {
+ \c__typoAid_name_string\iow_newline:*~
+ Form~factor: \fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }~
+ ~for~switch:\tl_to_str:n{#2}\iow_newline:*~
+ Width:~ \dim_to_decimal_in_unit:nn
+ {\g_tmpa_dim}{1pt}~pt~
+ (\dim_to_decimal_in_unit:nn
+ {\g_tmpa_dim}{1pc}~pc)\iow_newline:*~
+ Rows~per~height:~\int_eval:n{\g_tmpa_int}
+ }
+ \__typoAid_formfactor_log:nnnn
+ {\g_tmpa_dim}
+ {#2}
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }}
+ {\g_tmpa_int}
+ }{
+ \begin{table}
+ \centering
+ \caption{Height~data~for~switch~\tl_to_str:n{#2};~width:~\tl_to_str:n{#3},~skip:~\dim_eval:n{#5}}
+ \begin{tabular}{lSSSS}
+ \toprule
+ \multicolumn{1}{l}{Description}&
+ \multicolumn{1}{r}{Height~(pt)}&
+ \multicolumn{1}{r}{Height~(pc)}&
+ \multicolumn{1}{r}{Lines~per~height}&
+ \multicolumn{1}{r}{Form~factor}\\
+ \midrule
+%%%%%%%%%%FIRST ROW: DATA AS BEEN REQUESTED
+ \dim_gset:Nn\g_tmpb_dim
+ {
+ \fp_to_dim:n
+ {
+ \fp_eval:n{#4}*\dim_eval:n{\l_tmpa_dim}
+ }
+ }
+
+ \__typoAid_nrRows:nnn{#2}{\l__typoAid_local_dim}{\g_tmpb_dim}
+ \fp_gset:Nn\g_tmpb_fp{\fp_eval:n{round(\g_tmpa_fp,3)}}
+ \__typoAid_PrepareHeightTableRow_tl:nnnn
+ {#4}
+ {\fp_eval:n{round(\g_tmpa_fp,3)}}
+ {Requested}
+ {\g_tmpb_dim}
+ \__typoAid_formfactor_log:nnnn{\g_tmpb_dim}{#2}{#4}{\g_tmpb_fp}
+ \tl_use:N\g_tmpa_tl\\
+
+%%%%%%%%%%SECOND ROW: TRUNC
+ \fp_set:Nn\l_tmpa_fp{\fp_eval:n{\g_tmpa_fp}}
+
+ \int_gset:Nn\g_tmpa_int{\fp_eval:n{trunc (\g_tmpa_fp)}}
+
+ \__typoAid_HeightForRows:nnn{#1}{\g_tmpa_int}{\l__typoAid_local_dim}
+
+ \__typoAid_PrepareHeightTableRow_tl:nnnn
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }}
+ {\g_tmpa_int}
+ {Floor~rounding}
+ {\g_tmpa_dim}
+ \__typoAid_formfactor_log:nnnn
+ {\g_tmpa_dim}
+ {#2}
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3) }}
+ {\g_tmpa_int}
+ \tl_use:N\g_tmpa_tl\\
+
+%%%%%%%%%THIRD ROW: +1
+ \fp_set:Nn\l_tmpa_fp{\fp_eval:n{\g_tmpa_fp}}
+
+ \int_gset:Nn\g_tmpa_int{\fp_eval:n{trunc \g_tmpa_fp}+1}
+
+ \__typoAid_HeightForRows:nnn{#1}{\g_tmpa_int}{\l__typoAid_local_dim}
+
+ \__typoAid_PrepareHeightTableRow_tl:nnnn
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3)}}
+ {\g_tmpa_int}
+ {\relax Ceil~rounding}
+ {\g_tmpa_dim}
+ \__typoAid_formfactor_log:nnnn
+ {\g_tmpa_dim}
+ {#2}
+ {\fp_eval:n{round(\dim_ratio:nn{\g_tmpa_dim}{\l_tmpa_dim},3)}}
+ {\g_tmpa_int}
+ \tl_use:N\g_tmpa_tl\\
+
+ \bottomrule
+ \end{tabular}
+ \end{table}
+
+ }
}
-%%\ExplSyntaxOff \ No newline at end of file