Bug 47594 - TextShape.resizeToFitText() height too small
Summary: TextShape.resizeToFitText() height too small
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-28 05:27 UTC by f_bullitt
Modified: 2015-07-07 20:03 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description f_bullitt 2009-07-28 05:27:37 UTC
The method TextShape.resizeToFitText() calculates a height that is too small for the TextShape if the text contains many lines.
I tried poi-versions from 3.1 to 3.5 and java-versions from 1.4 to 1.6


Sample Code:

SlideShow ppt = new SlideShow();
Slide slide = ppt.createSlide();
TextBox txtBox = new TextBox();
slide.addShape(txtBox);
txtBox.setLineColor(Color.BLACK);
txtBox.setText("Line One\nLine Two\nThree\nFour\nFive\nSix\nSeven\Eight");
txtBox.resizeToFitText();
    
FileOutputStream out = new FileOutputStream("test.ppt");
ppt.write(out);
out.close();
Comment 1 Nick Burch 2009-07-28 05:54:50 UTC
There's code in TextShape.resizeToFitText() that appears to handle the height stuff in a way I'd expect to work.

Could it be a font issue? Can you confirm that the font that your text is using really is present (and available to java!) on the machine where you're running your poi code? Also, if you try changing the font, does the height mismatch change, or is at say always out by ~10%?
Comment 2 f_bullitt 2009-07-28 06:35:29 UTC
The font I use is arial.ttf and it is present and available to Java.

But as you said, I tested two other fonts (times.ttf and kartika.ttf) and with these two fonts, the height seems to be calculated correctly.
Unfortunately I have to use arial in the PPT.
Comment 3 f_bullitt 2009-07-28 06:54:36 UTC
By the way, in the RichTextRun I set setBold(true).
I tried the Windows-Font arialbd.ttf and now the calculation of height works correctly!
Maybe the normal arial.ttf does not really work with bold.

So I don't know if this is still a bug.

Thank you.
Comment 4 Dominik Stadler 2015-07-07 20:03:59 UTC
No progress and discussion indicates that it likely is related to the actual font that is used and the font-file that is installed on the machine. There hopefully were some fixes in newer versions of Java which make this work better, so I am resolving this for now as there is likely not much we can do here unless someone comes up with a patch.