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 FeatureList {
14:
15: private Feature[] features;
16: private int featureCount;
17:
18: public FeatureList() {
19: features = new Feature[10];
20: featureCount = 0;
21: }
22:
23: public void addFeature(Feature feature) {
24: if (featureCount >= features.length) {
25: Feature[] newFeatures = new Feature[features.length + 5];
26:
27: System.arraycopy(features, 0, newFeatures, 0,
28: features.length);
29: features = newFeatures;
30: }
31:
32: features[featureCount++] = feature;
33: }
34:
35: public void finalizeFeatureList() {
36: TaggedRecord.sort(features, featureCount);
37:
38: for (int i = 0; i < featureCount; i += 1) {
39: features[i].setFeatureIndex(i);
40: }
41: }
42:
43: public void writeFeaturetList(OpenTypeTableWriter writer) {
44: System.out.print("writing feature list...");
45:
46: int featureListBase = writer.getOutputIndex();
47:
48: writer.writeData(featureCount);
49:
50: int featureRecordOffset = writer.getOutputIndex();
51:
52: for (int i = 0; i < featureCount; i += 1) {
53: String tag = features[i].getTag();
54:
55: System.out.print(" '" + tag + "'");
56: writer.writeTag(tag);
57: writer.writeData(0);
58: }
59:
60: for (int i = 0; i < featureCount; i += 1) {
61: // fix the offset in the featureRecordArray.
62: // The "+2" skips over the tag and the "+3"
63: // skips to the next featureRecord entry
64: writer.fixOffset(featureRecordOffset + 2, featureListBase);
65: featureRecordOffset += 3;
66:
67: features[i].writeFeature(writer);
68: }
69:
70: System.out.println();
71: }
72: }
|