Exemple #1
0
  /**
   * This function merges the glyph groups from <tt>wi<tt/> into the glyph groups that are already
   * on this line. It does no fit checking, just adds them in the proper place in the
   * <tt>newGGIS</tt> data member.
   */
  protected void mergeGlyphGroups(WordInfo wi) {
    int numGG = wi.getNumGlyphGroups();
    newSize = 0;
    if (ggis == null) {
      // first glyph group on line just add them.
      newSize = numGG;
      newGGIS = new GlyphGroupInfo[numGG];
      for (int i = 0; i < numGG; i++) newGGIS[i] = wi.getGlyphGroup(i);
    } else {
      // We need to merge the new glyph groups with the
      // existing glyph Groups.
      int s = 0;
      int i = 0;
      GlyphGroupInfo nggi = wi.getGlyphGroup(i);
      int nStart = nggi.getStart();

      GlyphGroupInfo oggi = ggis[size - 1];
      int oStart = oggi.getStart();

      newGGIS = assureSize(newGGIS, size + numGG);
      if (nStart < oStart) {
        oggi = ggis[s];
        oStart = oggi.getStart();
        while ((s < size) && (i < numGG)) {
          if (nStart < oStart) {
            newGGIS[newSize++] = nggi;
            i++;
            if (i < numGG) {
              nggi = wi.getGlyphGroup(i);
              nStart = nggi.getStart();
            }
          } else {
            newGGIS[newSize++] = oggi;
            s++;
            if (s < size) {
              oggi = ggis[s];
              oStart = oggi.getStart();
            }
          }
        }
      }
      while (s < size) {
        newGGIS[newSize++] = ggis[s++];
      }
      while (i < numGG) {
        newGGIS[newSize++] = wi.getGlyphGroup(i++);
      }
    }
    // for (int i=0; i<newSize; i++) {
    //     System.err.println("GGIS["+i+"]: " + newGGIS[i].start + " -> " +
    //                        newGGIS[i].end);
    // }
  }