如何将AAT上下文连字添加到TTF字体?

时间:2014-08-14 05:43:27

标签: true-type-fonts

我正在为Sgaw Karen开发字体,这种语言要求根据上下文对字符(和连字)进行整形。我的字体工作得很好,但是,我希望在Mac上添加一个AAT MORX表以获得更好的支持。

但是,我很难理解AAT字体功能的语法。特别是上下文类型。我已经阅读了Apple参考和教程文档,并看到了here列出的示例。

基本上,我有两个字符,假设X和Y需要替换为连字,如果后跟一组特定字符,比如说N和M.对于FontLab Studio中的OpenType特性,我只想说:

sub X' Y' [N M] by X_Y.alt;

它工作得很漂亮。我如何在AAT中做同样的事情?

这是我的完整OT代码:

feature clig {

script mymr;
@needSpaceOnTop = [uni102B uni1032 uni102D uni102E];

sub uni1000' uni103C' @needSpaceOnTop by uni1000_uni103C.alt;
sub uni1003' uni103C' @needSpaceOnTop by uni1003_uni103C.alt;
sub uni1006' uni103C' @needSpaceOnTop by uni1006_uni103C.alt;
sub uni1010' uni103C' @needSpaceOnTop by uni1010_uni103C.alt;
sub uni1011' uni103C' @needSpaceOnTop by uni1011_uni103C.alt;
sub uni1018' uni103C' @needSpaceOnTop by uni1018_uni103C.alt;
sub uni101C' uni103C' @needSpaceOnTop by uni101C_uni103C.alt;
sub uni101E' uni103C' @needSpaceOnTop by uni101E_uni103C.alt;
sub uni101F' uni103C' @needSpaceOnTop by uni101F_uni103C.alt;
sub uni1001' uni103C' @needSpaceOnTop by uni1001_uni103C.alt;
sub uni1002' uni103C' @needSpaceOnTop by uni1002_uni103C.alt;
sub uni100E' uni103C' @needSpaceOnTop by uni100E_uni103C.alt;
sub uni1004' uni103C' @needSpaceOnTop by uni1004_uni103C.alt;
sub uni1005' uni103C' @needSpaceOnTop by uni1005_uni103C.alt;
sub uni1007' uni103C' @needSpaceOnTop by uni1007_uni103C.alt;
sub uni1012' uni103C' @needSpaceOnTop by uni1012_uni103C.alt;
sub uni1015' uni103C' @needSpaceOnTop by uni1015_uni103C.alt;
sub uni1016' uni103C' @needSpaceOnTop by uni1016_uni103C.alt;
sub uni1019' uni103C' @needSpaceOnTop by uni1019_uni103C.alt;
sub uni101D' uni103C' @needSpaceOnTop by uni101D_uni103C.alt;
sub uni1065' uni103C' @needSpaceOnTop by uni1065_uni103C.alt;

} clig;

以下是OS X字体工具文档的上下文示例:

------------------------------------------------------------------
//  Turn medial s into long s
------------------------------------------------------------------
Type        Contextual
Name        Smart Swashes
Namecode    8
Setting     Medial Long-s
Settingcode 8
Default     no
Orientation H
Forward     yes
Exclusive   no

Ess     s
Lower   a b c d e f g h i j k l m n o p q r t u v w x y z

            EOT OOB DEL EOL Ess Lower
StartText   1   1   1   1   2   1
StartLine   1   1   1   1   2   1
SawS        1   1   1   1   3   4
SawSS       1   1   1   1   3   4

    GoTo        Mark?   Advance?    SubstMark   SubstCurrent
1   StartText   no      yes         none        none
2   SawS        yes     yes         none        none
3   SawSS       yes     yes         ToLongS     none
4   StartText   no      yes         ToLongS     none

ToLongS
    s   slong

1 个答案:

答案 0 :(得分:2)

好的,我已经把它弄清楚了。 AAT不直接支持上下文连字。但你可以通过使用两个传递来实现它,如下:

如果后跟N或M,则将X Y更改为X_Y:

//====================================================
//  Step 1: change Y to an arbitrary high glyph number
//  if it is preceded by X and followed by N or M  
//====================================================

Type Contextual
Name NULL
Namecode 7
Setting NULL
Settingcode 0
Default yes
Orientation HV
Forward yes
Exclusive no

// Define some classes
X X
Y Y
NM N M

// Define what action to take for state/action
            EOT     OOB     DEL     EOL   X     Y    NM
StartText   1       1       1       1     2     1    1
StartLine   1       1       1       1     2     1    1
SawX        1       1       1       1     1     3    1
SawY        1       1       1       1     1     1    4

// The state machine starts off in the StartText or StartLine state.
// If it sees an X in one of those states, it changes to the SawX
// state. If it's in the SawX state and sees a Y, then it changes to
// the SawY state and marks that character (the Y) for possible
// future processing. Then if it sees an N or M in the SawY state,
// it runs the DoSub on the marked Y, and returns to the StartText state.

// Actions - the Goto column tells what state to take for
// the next round.

  GoTo      Mark? Advance?    SubstMark   SubstCurrent
1 StartText no    yes         none        none
2 SawX      no    yes         none        none
3 SawY      yes   yes         none        none
4 StartText no    yes         DoSub       none

// Subs Y by 5999
DoSub
      Y 5999

//====================================================
// Step 2: Change the X 5999 to X_Y
//====================================================

Type          LigatureList
Name          NULL
Namecode      7
Setting       NULL
Settingcode   0
Default       yes
Orientation   HV
Forward       yes
Exclusive     no

// Replace X 5999 by X_Y
List
    X_Y X 5999

当然,要使其正常工作,5999必须不是以前存在的字形ID。