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