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