OpenType烹飪手冊(2)Foundation Concepts 基礎概念

http://opentypecookbook.com/foundation-concepts/

Foundation Concepts 基礎概念


Before we start writing any code, let’s first look at what the code will actually do. If you are reading this cookbook just to find out how to do something simple like write a small caps feature, you may skip this section and jump ahead to the?code snippets. But, if you want to develop complex, nuanced, amazing features, you really should read this section. Understanding the underlying mechanics of how features work will allow you to carry your vision all the way from how the glyphs?look?to how they?behave.

在我們開始編寫任何代碼之前,讓我們先看看代碼實際上能做什么。如果你讀這本書只是為了了解如何做一些簡單的事情,比如寫一個小型大寫的特性,你可以跳過這一部分,直接跳到代碼片段。但是,如果你想開發復雜的、細致入微的、令人驚嘆的特性,你真的應該閱讀這一部分。了解特征如何工作的基本機制將允許您將您的愿景從字形看起來如何到它們的行為如何一路推進。

Ready? Alright, let’s get into some heavy stuff.

準備好了嗎? 好,讓我們來看看重要的東西。

Structures 結構

In OpenType we can define behaviors that we want to happen upon request from users. For example, the user may decide that text should be displayed with small caps. You, the type designer, can define which glyphs should be changed when this request is made by the user. These behaviors are defined in?features. Features can do two things: they can?substitute glyphs?and they can?adjust the positions of glyphs.

在 OpenType 中,我們可以定義希望在用戶請求時發生的行為。例如,用戶可能決定文本應該用小型大寫顯示。您,字體設計師,可以定義當用戶發出此請求時應該替換哪些字形。這些行為是在特性中定義的。OT特性可以做兩件事情:?1、可以替換字形,2、可以調整字形的顯示位置。

The actual behavior within the features are defined with?rules. Following the small caps example above, you can define a rule that states that the?a?glyph should be replaced with?A.sc.

特性中的實際行為是用規則(rules)定義的。按照上面的小型大寫示例,您可以定義一個規則,規定 a?字形應該替換為 A.sc。

Within a feature, it is often necessary to group a set of rules together. This group of rules is called a?lookup.

在一個特性(feature )中,通常需要將一組規則組合在一起。這樣一組規則稱為查找lookup)。

Visually, you can think of features, lookups and rules like this:

在視覺上,你可以這樣理解特性查找規則:

(Note: In these illustrations if you see a jagged line cutting something off, it means “There is a bunch of the same kind of stuff so we’ll cut it off to avoid too much repetition.”)

(注意: 在這些插圖中,如果你看到一條鋸齒狀的線條把什么東西切掉了,這意味著“有一大堆同樣的東西,所以我們會把它切掉,以避免太多的重復。”)

Processing 處理

When text is processed, the features that the user wants applied are gathered into two groups: substitution features and positioning features. The substitution features are processed first and then the positioning features are processed. The order in which you have defined the features, lookups and rules is the order in which they will be applied to the text. This order is?very?important.

當處理文本時,用戶想要應用的特征被集中到兩組: 替換特性定位特性。首先處理替換特征,然后處理定位特征。定義特性、查找和規則的順序是它們應用于文本的順序。這個順序很重要。

Features process sequences of glyphs. These glyph runs may represent a complete line of text or a sub-section of a line of text.

特性處理一個序列的字形。一個字形序列可以表示一行完整的文本或一行文本的子部分。

For example, let’s assume that you have the following features, lookups and rules:

例如,假設你有以下特性,查找和規則:

Let’s also assume that the user wants to apply small caps and ligatures to a glyph run that displays?Hello.

我們還假設用戶希望對顯示 Hello 的字形運行應用小寫和連字。

A glyph run is processed one feature at a time. So, here is what?Hello?will look like as it enters and exists each feature:

字形運行一次處理一個特征。下面是 Hello 進入和存在每個特性時的樣子:

Within each feature, the glyph run is processed one lookup at a time. Here is what our example looks like as it moves through the small caps feature:

在每個特性中,每次處理一個字形運行查找。下面是我們的例子在小寫字母功能中的運行情況:

Within each lookup, things are a little different. The glyph run is passed one glyph at a time from beginning to end over each rule within the lookup. If a rule replaces the current glyph, the following rules are skipped for the current glyph. The next glyph is then current through the lookup. That’s complex, so let’s look at it with our example:

在每個查找中,內容都有一點不同。字形運行每次從頭到尾通過查找內的每個規則傳遞一個字形。如果規則替換當前字形,則跳過當前標志符號的下列規則。然后通過查找當前的下一個字形。這很復雜,所以讓我們用我們的例子來看一下:

The process is the same for positioning features, except that instead of rule evaluation stopping when a glyph is replaced, the evaluation is stopped when a glyph’s position is changed.

對于定位特征,這個過程是相同的,除了當一個字形被替換時規則計算停止,而當一個字形的位置被改變時計算停止。

That’s how processing works and it is the most complex part of OpenType features that you will need to understand. Got it? Great!

這就是處理的工作原理,也是 OpenType 特性中您需要理解的最復雜的部分。都明白了嗎?太棒了!

Next: Syntax Introduction?下一步: 語法介紹

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。