public boolean addWord(WordInfo wi) { double nlh = wi.getLineHeight(); if (nlh <= lineHeight) return insertWord(wi); fr.newLineHeight(nlh); if (!updateRangeInfo()) { if (lineHeight > 0) // restore old LH fr.newLineHeight(lineHeight); return false; } if (!insertWord(wi)) { if (lineHeight > 0) // Failure, restore old line Height. setLineHeight(lineHeight); return false; } // Success, word fits on line. lineHeight = nlh; if (wi.getAscent() > ascent) ascent = wi.getAscent(); if (wi.getDescent() > descent) descent = wi.getDescent(); hLeading = (nlh - (ascent + descent)) / 2; baseline = (float) (fr.getCurrentY() + hLeading + ascent); return true; }
/** * 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); // } }