我正在开发一个预处理器来绘制方程的平方根(尝试提高 EQN 方程的美观性),其中涉及查找字符串的大小(宽度和高度)。我找到了返回字符串或字符宽度的请求/命令和寄存器\w'H'
,但我找不到返回高度的请求/命令。有什么方法可以找到高度吗?
太感谢了。
答案1
每次使用\w
转义序列时,几个寄存器都会填充有关您赋予它的参数的信息。
以下是来自其 Git 存储库的 groff Texinfo 手册的内容,稍作修改。
-- Escape sequence: \w'anything'
-- Register: \n[st]
-- Register: \n[sb]
-- Register: \n[rst]
-- Register: \n[rsb]
-- Register: \n[ct]
-- Register: \n[ssc]
-- Register: \n[skw]
Interpolate the width of ANYTHING in basic units. This escape
sequence allows several properties of formatted output to be
measured without writing it out.
The length of the string 'abc' is \w'abc'u.
=> The length of the string 'abc' is 72u.
ANYTHING is processed in a dummy environment: this means that font
and type size changes, for example, may occur within it without
affecting subsequent output.
After each use, '\w' sets several registers.
'st'
'sb'
The maximum vertical displacements of the text baseline above
and below, respectively. The sign convention is opposite that
of relative vertical motions; that is, depth below the
(original) baseline is negative. These registers are
incorrectly documented in the AT&T 'troff' manual as "the
highest and lowest extent of [the argument to '\w'] relative
to the baseline".
'rst'
'rsb'
Like 'st' and 'sb', but taking account of the heights and
depths of glyphs. In other words, these registers store the
highest and lowest vertical positions attained by ANYTHING,
doing what AT&T 'troff' documented 'st' and 'sb' as doing.
'ct'
Characterizes the geometry of glyphs occurring in ANYTHING.
0 only short glyphs, no descenders or tall glyphs
1 at least one descender
2 at least one tall glyph
3 at least one each of a descender and a tall glyph
'ssc'
The amount of horizontal space (possibly negative) that should
be added to the last glyph before a subscript.
'skw'
How far to right of the center of the last glyph in the '\w'
argument, the center of an accent from a roman font should be
placed over that glyph.
ct
我想补充一点,在终端设备上,也称为“nroff 模式”,无论输入是什么,寄存器的值通常为零。我认为这是因为 nroff 设备无论如何都无法进行精细的垂直运动。从历史上看,它们最多只能移动半线,而视频终端及其模拟器甚至无法做到这一点。
答案2
字体的磅值是以下各项的总和:
- 行距(字母上方所需的空间)
- 上升或大写高度(基线和最大字母顶部之间的空间)
- 下降(基线和最低字母底部之间的空间)
上升高度或大写字母高度是 x 高度(字母“x”和上升部分的高度)之和。
这些数字与字体相关。您可以打印出两行xhY
并测量它们(将它们打印得较大并将结果保留为磅值的百分比)
看https://www.onlineprinters.co.uk/magazine/font-sizes/和/或http://web.mit.edu/6.813/www/sp18/classes/16-typography/或者用谷歌搜索这些术语来获取图片。
除非你想把平方根符号粘在字母的顶部,否则你应该尊重领导者。如果你确信从来不存在任何上升者,你可能会选择不尊重上升者。下降部分低于基线,因此您可以选择忽略它们。
在 groff 中,情况仍然如此,但行距可能与.vs
(Register: \n[.v])有很大不同
对于 times roman,您可以使用大约:
- 下降=20%
- x 高度=42%
- 上升=75%
但这些只是粗略的近似值。