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 下一步: 语法介绍

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,012评论 4 359
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,589评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 106,819评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,652评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 51,954评论 3 285
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,381评论 1 210
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,687评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,404评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,082评论 1 238
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,355评论 2 241
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,880评论 1 255
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,249评论 2 250
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,864评论 3 232
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,007评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,760评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,394评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,281评论 2 259