原文地址 https://freetype.org/freetype2/docs/glyphs/glyphs-1.html
- 字型檔案,格式以及資訊 (Font files, format and information)
- 字元圖形和對映 Character images and mappings
- 字元和字型指標 Character and font metrics
字型檔案,格式以及資訊 (Font files, format and information)
A font is a collection of various character images that can be used to display or print text.
字型是多個字元圖形的集合,能被用於展示或者列印文字。
The images in a single font share some common properties, including look, style, serifs, etc
一個字型中的字元共享一些屬性,包括外形,樣式,襯線等等。
Typographically speaking, one has to distinguish between a font family and its multiple font faces, which usually differ in style though coming from the same template.
從印刷的角度說,我們需要區分字型族(font family)和它的多個字型(font faces),這些字型經常在樣式上有所區別。
For example, ‘Palatino Regular’ and ‘Palatino Italic’ are two distinct faces from the same family, called ‘Palatino’ itself.
比如,Palatino Regular和Palatino Italic是兩個不同的字型,但它們來自相同的字型族Palatino.
A digital font is thus a data file that may contain one or more font faces.
電腦中的字型檔案可能包含一個或者多個字型(font faces)。
For each of these, it contains character images, character metrics, as well as other kind of information important to the layout of text and the processing of specific character encodings.
對於每個字型,檔案會包含字元圖形,字元指標,以及其他用於文字佈局相關和特定字元編碼的重要的資訊。
In some formats, like Adobe's Type 1, a single font face is described through several files (i.e., one contains the character images, another one the character metrics). We will ignore this implementation issue in most parts of this document and consider digital fonts as single files, though FreeType 2 is able to support multiple-files fonts correctly.
對於一些格式,一個字型會被儲存在多個檔案中。我們暫時無視這個問題。
As a convenience, a font file containing more than one face is called a font collection.
為了更加便利,一個字型檔案會包含多個字型,這被稱做字型集合。
This case is rather rare but can be seen in many Asian fonts, which contain images for two or more representation forms of a given script (usually for horizontal and vertical layout).
這種情況非常少見,但是在亞洲字型中可以看到。
字元圖形和對映 Character images and mappings
The character images are called glyphs.
字元圖形被稱為Glyphs。
A single character can have several distinct images, i.e., several glyphs, depending on script, usage or context.
一個字元由於書體,用法以及上下文可以有多個圖形。
Several characters can also take a single glyph (good examples are Roman ligatures like ‘fi’ and ‘fl’ which can be represented by a single glyph).
多個字元也可以使用同一個圖形。
The relationship between characters and glyphs can be very complex but won't be discussed in this document.
字元和圖形之間的關係可以是非常複雜,但本文件不會討論。
Moreover, some formats use more or less complicated schemes to store and access glyphs. For the sake of clarity, we only retain the following notions when working with FreeType:
並且,一些格式使用了或多或少複雜的方案來儲存字元圖形。為了保持簡單,我們只使用下面這些概念:
-
A font file contains a set of glyphs; each one can be stored as a bitmap, a vector representation, or any other scheme (most scalable formats use a combination of mathematical representation and control data/programs). These glyphs can be stored in any order in the font file, and are typically accessed through a simple glyph index.
字型檔案包含一組字元圖形;每個圖形可以被儲存為點陣圖,向量形式,或者其他方案。這些字元圖形可以以任何順序被儲存在字型檔案中,然後透過簡單的圖形索引訪問。 -
The font file contains one or more tables, called character maps (also called ‘charmaps’ or ‘cmaps’ for short), which are used to convert character codes for a given encoding (e.g., ASCII, Unicode, Big5, ShiftJIS, etc.) into glyph indices relative to the font file. A single font face may contain several charmaps. For example, many OpenType fonts contain an Apple-specific charmap as well as a Unicode charmap, which makes them usable on both Mac and Windows platforms.
字型檔案包含一個或多個表格,被稱為字元對映,用於將字元編碼轉化為圖形索引。一個字型可能包含多個字元對映。比如OpenType字型包含一個Apple公司的字元對映以及Unicode的字元對映,這樣字型就可以工作在Mac和Windows上。
字元和字型指標 Character and font metrics
Each glyph image is associated with various metrics which describe how to place and manage it when rendering text; see section III for more.
每個字元圖形會有多個指標(metrics)來描述在渲染文字時如何放置和管理圖形。詳情見Section 3.
Metrics relate to glyph placement, cursor advances, as well as text layout. They are extremely important to compute the flow of text when rendering a string of text.
圖形放置,cursor advances 以及 文字佈局相關的指標 對於計算一串字串的整個文字佈局很重要。
Each scalable format also contains some global metrics, expressed in notional (i.e. font) units, to describe some properties of all glyphs in the same face.
每個可縮放的格式也會包含全域性的指標,它們以某種單位形式表達,來描述該字型裡所有圖形的屬性。
Examples for global metrics are the maximum glyph bounding box, the ascender, descender, and text height of the font.
全域性指標的例子有最大圖形包圍盒,the ascender, descender,以及字型的文字高度。
Non-scalable formats contain metrics also. However, they only apply to a set of given character dimensions and resolutions, and are usually expressed in pixels then.
不可縮放的格式也會包含這樣的指標。雖然它們只會應用於一些給定的字元的大小,並且經常是畫素為單位。