/** Hyphenates a word and returns the first part of it. To get * the second part of the hyphenated word call <CODE>getHyphenatedWordPost()</CODE>. * @param word the word to hyphenate * @param font the font used by this word * @param fontSize the font size used by this word * @param remainingWidth the width available to fit this word in * @return the first part of the hyphenated word including * the hyphen symbol, if any */ public String getHyphenatedWordPre(String word, BaseFont font, float fontSize, float remainingWidth) { post = word; String hyphen = getHyphenSymbol(); float hyphenWidth = font.getWidthPoint(hyphen, fontSize); if (hyphenWidth > remainingWidth) return ""; Hyphenation hyphenation = hyphenator.hyphenate(word); if (hyphenation == null) { return ""; } int len = hyphenation.length(); int k; for (k = 0; k < len; ++k) { if (font.getWidthPoint(hyphenation.getPreHyphenText(k), fontSize) + hyphenWidth > remainingWidth) break; } --k; if (k < 0) return ""; post = hyphenation.getPostHyphenText(k); return hyphenation.getPreHyphenText(k) + hyphen; }