• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4  *******************************************************************************
5  * Copyright (C) 1998-2004, International Business Machines Corporation and    *
6  * others. All Rights Reserved.                                                *
7  *******************************************************************************
8  *
9  * Created on Dec 3, 2003
10  *
11  *******************************************************************************
12  */
13 package com.ibm.icu.dev.tool.layout;
14 
15 
16 public /*abstract*/ class Lookup
17 {
18     private int lookupType;
19     private int lookupFlags;
20     private LookupSubtable[] subtables;
21     private int subtableCount;
22 
23     // Lookup flags
24     public final static int LF_ReservedBit          = 0x0001;
25     public final static int LF_IgnoreBaseGlyphs     = 0x0002;
26     public final static int LF_IgnoreLigatures      = 0x0004;
27     public final static int LF_IgnoreMarks          = 0x0008;
28     public final static int LF_ReservedMask         = 0x00F0;
29     public final static int LF_MarkAttachTypeMask   = 0xFF00;
30     public final static int LF_MarkAttachTypeShift  = 8;
31 
32     // GSUB lookup types
33     public final static int GSST_Single          = 1;
34     public final static int GSST_Multiple        = 2;
35     public final static int GSST_Alternate       = 3;
36     public final static int GSST_Ligature        = 4;
37     public final static int GSST_Context         = 5;
38     public final static int GSST_ChainingContext = 6;
39 
40     // GPOS lookup types
41     public final static int GPST_Single          = 1;
42     public final static int GPST_Pair            = 2;
43     public final static int GPST_Cursive         = 3;
44     public final static int GPST_MarkToBase      = 4;
45     public final static int GPST_MarkToLigature  = 5;
46     public final static int GPST_MarkToMark      = 6;
47     public final static int GPST_Context         = 7;
48     public final static int GPST_ChainingContext = 8;
49 
Lookup(int theLookupType, int theLookupFlags)50     public Lookup(int theLookupType, int theLookupFlags)
51     {
52         lookupType = theLookupType;
53         lookupFlags = theLookupFlags;
54 
55         subtables = new LookupSubtable[10];
56         subtableCount = 0;
57     }
58 
addSubtable(LookupSubtable subtable)59     public void addSubtable(LookupSubtable subtable)
60     {
61         if (subtableCount >= subtables.length) {
62             LookupSubtable[] newSubtables = new LookupSubtable[subtables.length + 5];
63 
64             System.arraycopy(subtables, 0, newSubtables, 0, subtables.length);
65             subtables = newSubtables;
66         }
67 
68         subtables[subtableCount] = subtable;
69         subtableCount += 1;
70     }
71 
writeLookup(OpenTypeTableWriter writer)72     public void writeLookup(OpenTypeTableWriter writer)
73     {
74         int lookupBase = writer.getOutputIndex();
75 
76         writer.writeData(lookupType);
77         writer.writeData(lookupFlags);
78         writer.writeData(subtableCount);
79 
80         int subtableOffset = writer.getOutputIndex();
81 
82         for (int i = 0; i < subtableCount; i += 1) {
83             writer.writeData(0);
84         }
85 
86         for (int i = 0; i < subtableCount; i += 1) {
87             writer.fixOffset(subtableOffset++, lookupBase);
88             subtables[i].writeLookupSubtable(writer);
89         }
90     }
91 }
92