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 class LookupList {
14: private Lookup[] lookups;
15: private int lookupCount;
16:
17: public LookupList() {
18: lookups = new Lookup[10];
19: lookupCount = 0;
20: }
21:
22: public int addLookup(Lookup lookup) {
23: if (lookupCount >= lookups.length) {
24: Lookup[] newLookups = new Lookup[lookups.length + 5];
25:
26: System.arraycopy(lookups, 0, newLookups, 0, lookups.length);
27: lookups = newLookups;
28: }
29:
30: lookups[lookupCount] = lookup;
31:
32: return lookupCount++;
33: }
34:
35: public void writeLookupList(OpenTypeTableWriter writer) {
36: System.out.println("writing lookup list...");
37:
38: int lookupListBase = writer.getOutputIndex();
39:
40: writer.writeData(lookupCount);
41:
42: int lookupOffset = writer.getOutputIndex();
43:
44: for (int i = 0; i < lookupCount; i += 1) {
45: writer.writeData(0); // Offset to lookup (fixed later);
46: }
47:
48: for (int i = 0; i < lookupCount; i += 1) {
49: writer.fixOffset(lookupOffset++, lookupListBase);
50: lookups[i].writeLookup(writer);
51: }
52: }
53: }
|