ASF Bugzilla – Attachment 22081 Details for
Bug 45140
TextShape.resizeToFitText() Not Properly Sizing TextShape
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for resizeToFitText
TextShape.txt (text/plain), 2.08 KB, created by
Nathan Mische
on 2008-06-05 07:42:59 UTC
(
hide
)
Description:
Patch for resizeToFitText
Filename:
MIME Type:
Creator:
Nathan Mische
Created:
2008-06-05 07:42:59 UTC
Size:
2.08 KB
patch
obsolete
>Index: C:/Users/nmische/Workspace/POI/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java >=================================================================== >--- C:/Users/nmische/Workspace/POI/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (revision 663587) >+++ C:/Users/nmische/Workspace/POI/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (working copy) >@@ -224,27 +224,25 @@ > String fntname = rt.getFontName(); > Font font = new Font(fntname, style, size); > >- float width = 0, height = 0; >- String[] lines = txt.split("\r"); >+ float width = 0, height = 0, leading = 0; >+ String[] lines = txt.split("\n"); > for (int i = 0; i < lines.length; i++) { > if(lines[i].length() == 0) continue; >- >+ > TextLayout layout = new TextLayout(lines[i], font, _frc); >- >+ >+ leading = Math.max(leading, layout.getLeading()); > width = Math.max(width, layout.getAdvance()); >+ height = Math.max(height, (height + (layout.getDescent() + layout.getAscent()))); >+ } >+ >+ // add one character to width >+ Rectangle2D charBounds = font.getMaxCharBounds(_frc); >+ width += getMarginLeft() + getMarginRight() + charBounds.getWidth(); >+ >+ // add leading to height >+ height += getMarginTop() + getMarginBottom() + leading; > >- /** >- * Even if top and bottom margins are set to 0 PowerPoint >- * always sets extra space between the text and its bounding box. >- * >- * The approximation height = ascent*2 works good enough in most cases >- */ >- height = Math.max(height, 2*layout.getAscent()); >- } >- >- width += getMarginLeft() + getMarginRight(); >- height += getMarginTop() + getMarginBottom(); >- > Rectangle2D anchor = getAnchor2D(); > anchor.setRect(anchor.getX(), anchor.getY(), width, height); > setAnchor(anchor);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45140
: 22081 |
35038