1 // 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html#License 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 public class LookupList 16 { 17 private Lookup[] lookups; 18 private int lookupCount; 19 20 public LookupList() 21 { 22 lookups = new Lookup[10]; 23 lookupCount = 0; 24 } 25 26 public int addLookup(Lookup lookup) 27 { 28 if (lookupCount >= lookups.length) { 29 Lookup[] newLookups = new Lookup[lookups.length + 5]; 30 31 System.arraycopy(lookups, 0, newLookups, 0, lookups.length); 32 lookups = newLookups; 33 } 34 35 lookups[lookupCount] = lookup; 36 37 return lookupCount++; 38 } 39 40 public void writeLookupList(OpenTypeTableWriter writer) 41 { 42 System.out.println("writing lookup list..."); 43 44 int lookupListBase = writer.getOutputIndex(); 45 46 writer.writeData(lookupCount); 47 48 int lookupOffset = writer.getOutputIndex(); 49 50 for (int i = 0; i < lookupCount; i += 1) { 51 writer.writeData(0); // Offset to lookup (fixed later); 52 } 53 54 for (int i = 0; i < lookupCount; i += 1) { 55 writer.fixOffset(lookupOffset++, lookupListBase); 56 lookups[i].writeLookup(writer); 57 } 58 } 59 }