From c5b8d627156f9960f5387c0d665e9cfbcb0036d8 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Sun, 30 May 2004 06:15:57 +0000 Subject: [PATCH] Set iPDimMin to the advance of the longest word in the text. Set bPDimMin = bPDimMax. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197662 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/LineArea.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index 73ea3fb3b..e3b7f081b 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -26,6 +26,7 @@ import java.awt.font.TextLayout; import java.awt.font.TextMeasurer; import java.text.AttributedCharacterIterator; import java.text.AttributedString; +import java.text.BreakIterator; import java.util.Map; import org.apache.fop.datastructs.Node; @@ -173,8 +174,21 @@ public class LineArea extends BlockArea { new Float(Math.max( layout.getLeading(), (layout.getAscent() + layout.getDescent()))); - // Find the shortest fragment of the text - // TODO work out Locale handling + // Find the longest fragment of the text + BreakIterator words = + BreakIterator.getWordInstance(generatedBy.getLocale()); + words.setText(text); + int begin = 0; + float maxWordWidth = 0; + int boundary = 0; + while ((boundary = words.next()) != BreakIterator.DONE) { + float width = measurer.getAdvanceBetween(begin, boundary); + maxWordWidth = Math.max(maxWordWidth, width); + begin = boundary; + } + iPDimMin = new Float(maxWordWidth); + // For now, set bPDimMin = bPDimMax. + bPDimMin = bPDimMax; } -- 2.39.5