Home | History | Annotate | Download | only in layout
      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) 2002-2004, International Business Machines Corporation and    *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 
     10 package com.ibm.icu.dev.tool.layout;
     11 
     12 
     13 class Feature extends TaggedRecord
     14 {
     15     private int[] lookupIndices;
     16     private int lookupCount;
     17     private int featureIndex;
     18 
     19     public Feature(String theFeatureTag)
     20     {
     21         super(theFeatureTag);
     22 
     23         lookupIndices = new int[10];
     24         lookupCount = 0;
     25         featureIndex = -1;
     26     }
     27 
     28     public void addLookup(int theLookupIndex)
     29     {
     30         if (lookupCount >= lookupIndices.length) {
     31             int[] newLookupIndices = new int[lookupIndices.length + 5];
     32 
     33             System.arraycopy(lookupIndices, 0, newLookupIndices, 0, lookupIndices.length);
     34             lookupIndices = newLookupIndices;
     35         }
     36 
     37         lookupIndices[lookupCount] = theLookupIndex;
     38         lookupCount += 1;
     39     }
     40 
     41     public void writeFeature(OpenTypeTableWriter writer)
     42     {
     43         writer.writeData(0);      // featureParams (must be NULL)
     44 
     45         writer.writeData(lookupCount);
     46 
     47         for (int i = 0; i < lookupCount; i += 1) {
     48             writer.writeData(lookupIndices[i]);
     49         }
     50     }
     51 
     52     public int getFeatureIndex()
     53     {
     54         return featureIndex;
     55     }
     56 
     57     public void setFeatureIndex(int index)
     58     {
     59         featureIndex = index;
     60     }
     61 }