【问题标题】:How do I add AAT contextual ligatures to TTF fonts?如何将 AAT 上下文连字添加到 TTF 字体?
【发布时间】:2014-08-21 13:57:56
【问题描述】:

我正在为 Sgaw Karen 开发字体,这是一种需要根据上下文来塑造字符(和连字)的语言。我的字体运行良好,但是,我希望添加一个 AAT MORX 表格以便在 Mac 上获得更好的支持。

但是,我很难理解 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

【问题讨论】:

    标签: truetype


    【解决方案1】:

    好的,我自己想通了。 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。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-24
    • 2020-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-24
    • 2015-03-13
    • 1970-01-01
    相关资源
    最近更新 更多