My idea is to redefine the \strut
to be as short as possible.
It means the length of strut is the sum of the tallest letter length and the deepest letter length.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityMy idea is to redefine the \strut
to be as short as possible.
It means the length of strut is the sum of the tallest letter length and the deepest letter length.
One problem is that the font metrics do not include appropriate dimensions for this. The code below provides a short macro for displaying the font dimensions.
\documentclass[10pt]{article}
\usepackage{graphicx, booktabs, tabularx, scalefnt, xcolor}
\begin{document}
\def\displayfontmetrics#1{\medskip
\noindent
\begin{table}[htbp]
\begin{tabular}{lcl}
\toprule
Parameter & Description & Value\\
\midrule
fontdimen1 & slant & \the\fontdimen1\font\\
fontdimen2 &interword space & \the\fontdimen2\font\\
fontdimen3 &interword stretch & \the\fontdimen3\font\\
fontdimen4 & interword shrink & \the\fontdimen4\font\\
fontdimen5 & x-height & \the\fontdimen5\font\\
fontdimen6 & quad width & \the\fontdimen6\font\\
fontdimen7 & extra space & \the\fontdimen7\font\\
\bottomrule
\end{tabular}
\caption{Font metrics for font #1}
\end{table}
\medskip}
\scalebox{2}{ H\'AMB\"URG\'E\c F\'ON\c ST\'IV}
\scalebox{2}{ \lowercase{H\'AMB\"URG\'E\'ty\c F\'ON\c ST\'IV}}
\end{document}
One solution is to use a vphantom
which you can use as a strut.
\def\Z{\vphantom{y\vphantom{\'l}}}
\colorbox{yellow}{\Z abcdy}
\vphantom
and the 2 letters obtained by the query.
Dec 22, 2010 at 6:33
\vphantom
when defining \Z
? does it make a difference if I just use one?
Dec 22, 2010 at 7:29
y
rather than l
.
Dec 22, 2010 at 10:49
the strutbox is defined to exactly the height of \baselineskip
which is the smallest value including the interlinespace of a row. However, you have to redefine every time the strutbux when changing the fontsize. This is the reason why it makes no sense to have an own strut value. Use instead the \vphantom
macro:
\def\mystrut{\vphantom{Äg}}
Äg
produces the longest length? Or are there other combinations that produce the longest one?
Dec 22, 2010 at 6:36
\strutbox
appropriately? It should be an \hbox
containing a \vrule
with the appropriate height and depth and zero width.
The Luatex manual, section 4.4.5.1.2, Glyph items, documents the glyph array that exists for each font, which provides information on the bounding element of each rendered character:
On boundingbox: The boundingbox information for TrueType fonts and TrueType-based otf fonts is read directly from the font file. PostScript-based fonts do not have this information, so the boundingbox of traditional PostScript fonts is generated by interpreting the actual bezier curves to find the exact boundingbox. This can be a slow process, so starting from LuaTEX 0.45, the boundingboxes of Post- Script-based otf fonts (and raw cff fonts) are calculated using an approximation of the glyph shape based on the actual glyph points only, instead of taking the whole curve into account. This means that glyphs that have missing points at extrema will have a too-tight boundingbox, but the processing is so much faster that in our opinion the tradeoff is worth it.
This sounds like it is as good an approximation to what you want as you will get. Iterating over the glyphs in a font and computing the maximum altitude and depth of each should be fairly easy if you know Lua.
Ag
should usually be enough, perhaps with some safety margin.{
like in maths you should look-upmathstrut
.