lineMeasurer.setPosition(paragraphStart);\r
\r
// Get lines until the entire paragraph has been displayed.\r
- // boolean noAscent = true;\r
- while (lineMeasurer.getPosition() < paragraphEnd) {\r
+ int next, limit, charat, position = 0;\r
+ while ((position = lineMeasurer.getPosition()) < paragraphEnd) {\r
+\r
+ // Find possible line break and set it as a limit to the next layout\r
+ next = lineMeasurer.nextOffset(breakWidth);\r
+ limit = next;\r
+ charat = text.indexOf(System.getProperty("line.separator"),position+1);\r
+ if(charat < next && charat != -1){\r
+ limit = charat;\r
+ }\r
\r
// Retrieve next layout. A cleverer program would also cache\r
// these layouts until the component is re-sized.\r
- TextLayout layout = lineMeasurer.nextLayout(breakWidth);\r
+ TextLayout layout = lineMeasurer.nextLayout(breakWidth, limit, false);\r
\r
// Compute pen x position. If the paragraph is right-to-left we\r
// will align the TextLayouts to the right edge of the panel.\r