FreeType Glyph Conventions 翻译(4) ——Kerning 字间距调整

原文地址 https://freetype.org/freetype2/docs/glyphs/glyphs-4.html

The term kerning refers to specific information used to adjust the relative positions of successive glyphs in a string of text. This section describes several types of kerning information, as well as the way to process them when performing text layout.
术语 字间距调整(kerning)是指用特定信息调整文本字符串中连续字形的相对位置。本节介绍几种类型的字间距调整信息,以及在文本布局时处理它们的方法。

字间距调整对子 Kerning pairs

Kerning consists of modifying the spacing between two successive glyphs according to their outlines. For example, a ‘T’ and a ‘y’ can be easily moved closer, as the top of the ‘y’ fits nicely under the upper right bar of the ‘T’.
字间距调整就是根据字形的轮廓线修改它们之间的间距。例如,“T”和“y”可以很容易地移得更近,因为“y”的顶部可以很好地位于“T”的右上栏下方。

When laying out text with only their standard widths, some consecutive glyphs seem a bit too close or too distant. For example, the space between the ‘A’ and the ‘V’ in the following word seems a little wider than needed.
当只使用标准宽度排版文本时,一些连续的字形看起来有点太近或太远。例如,下面单词中“A”和“V”之间的间距似乎比需要的要宽一些。

Compare this to the same word, where the distance between these two letters has been slightly reduced:
将其与同一个单词进行比较,其中这两个字母之间的距离略有减小:

As you can see, this adjustment can make a great difference. Some font faces thus include a table containing kerning distances for a set of given glyph pairs for text layout.
正如你所看到的,这种调整可以产生很大的影响。因此,一些字体会包括一个kerning表,该表包含用于文本布局的一组给定字形对的调整距离。

我看中文字体好像一般没这个kerning数据

  • The pairs are ordered, i.e., the space for pair ‘(A,V)’ isn't necessarily the space for pair ‘(V,A)’. They also use glyph indices, not character codes.
    对是有序的,即对“(A,V)”的空间不一定是对“(V,A)”的空格。它们也使用字形索引,而不是字符代码。

  • Kerning distances can be expressed in horizontal or vertical directions, depending on the layout and/or the script. For example, some horizontal layouts like Arabic can make use of vertical kerning adjustments between successive glyphs. A vertical script can have vertical kerning distances.
    调整距离可以用水平或垂直方向表示,具体取决于布局和/或脚本。例如,一些水平布局(如阿拉伯语)可以利用连续字形之间的垂直紧排调整。垂直脚本可以具有垂直紧排距离。

  • Kerning distances are expressed in grid units. They are usually oriented in the X axis, which means that a negative value indicates that two glyphs must be set closer in a horizontal layout.
    调整距离以网格单位表示。它们通常在X轴上定向,这意味着负值表示在水平布局中必须将两个字形设置得更近。

Note that OpenType fonts (OTF) provide two distinct mechanisms for kerning, using the ‘kern’ and ‘GPOS’ tables, respectively, which are part of the OTF files. Older fonts only contain the former, while recent fonts contain both tables or even ‘GPOS’ data only. FreeType only supports kerning via the (rather simple) ‘kern’ table. For the interpretation of kerning data in the (highly sophisticated) ‘GPOS’ table you need a higher-level library like ICU or HarfBuzz since it can be context dependent (this is, the kerning may vary depending on the position within a text string, for example).
请注意,OpenType字体(OTF)提供了两种不同的间距调整机制,分别使用“kern”和“GPOS”表,这两个表是OTF文件的一部分。较旧的字体只包含前者,而最近的字体同时包含两个表,甚至只包含“GPOS”数据。FreeType仅支持通过(相当简单的)“kern”表进行紧排。为了解释(高度复杂的)“GPOS”表中的紧排数据,您需要一个更高级别的库,如ICU或HarfBuzz,因为它可能与上下文相关(例如,紧排可能因文本字符串中的位置而异)。

应用字间距调整 Applying kerning

Applying kerning when rendering text is a rather easy process. It merely consists of adding the scaled kern distance to the pen position before rendering the next glyph. However, the typographically correct renderer must take a few more details in consideration.
在渲染文本时字间距调整是一个相当容易的过程。它只需要在渲染下一个字形之前将字间距调整距离加到笔位置上。但如果想渲染得更好,必须考虑更多的细节。

The ‘sliding dot’ problem is a good example: Many font faces include a kerning distance between capital letters like ‘T’ or ‘F’ and a following dot (‘.’), in order to slide the latter glyph just right to their main leg.
“滑动点”问题就是一个很好的例子:许多字体的正面都包括大写字母(如“T”或“F”)和后面的点(“.”)之间的紧排距离,以便将后面的字形正好滑动到它们的主脚。

This sometimes requires additional adjustments between the dot and the letter following it, depending on the shapes of the enclosing letters. When applying ‘standard’ kerning adjustments, the previous sentence would become
这有时需要在点和后面的字母之间进行额外的调整,具体取决于两个字母的形状。当应用“标准”字间距调整时,之前的例子将变为

This is clearly too contracted. The solution here, as exhibited in the first example, is to only slide the dots if the conditions fit. Of course, this requires a certain knowledge of the text's meaning, and this is exactly what ‘GPOS’ kerning is good for: Depending on the context, different kerning values can be applied to get a typographically correct result.
这显然过于紧凑。这里的解决方案是,如第一个例子所示,只调整点和它之前字母的间距。当然,这需要对文本的含义有一定的了解,而这正是“GPOS”紧排的好处:根据上下文的不同,可以应用不同的紧排值来获得印刷正确的结果。

posted @ 2024-03-29 01:16  dewxin  阅读(73)  评论(0编辑  收藏  举报