Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem that getHeight() is smaller than the actual value #505

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

magnww
Copy link

@magnww magnww commented Aug 18, 2023

+ getLeading() was removed in this commit: 5a18307#diff-4cd687c3da36fff3b21d074a27f7bac176c2845b43d37eca3af37fb920baf32cL73 I can't find a reason for the removal.
Due to the lack of leading height, the height obtained by this method is much smaller than the actual height (Test with Chinese characters).

`+ getLeading()` was removed in this commit: apache@5a18307#diff-4cd687c3da36fff3b21d074a27f7bac176c2845b43d37eca3af37fb920baf32cL73
I can't find a reason for the removal.
Due to the lack of leading height, the height obtained by this method is much smaller than the actual height (Test with Chinese characters).
@pjfanning
Copy link
Contributor

pjfanning commented Sep 14, 2023

Can you provide a test or some proof that the existing code is wrong?

Can't you call getLeading() yourself and add that value to getHeight() in your own code if you need to?

@magnww
Copy link
Author

magnww commented Sep 15, 2023

Test code:

    @Test
    public void testResizeToFitText() throws IOException {
        XMLSlideShow slideShow = new XMLSlideShow();
        Slide slide = slideShow.createSlide();
        TextBox textBox = slide.createTextBox();
        textBox.setAnchor(new Rectangle(0, 0, 600, 100));
        TextRun textRun = textBox.appendText("测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试", false);
        textRun.setFontFamily("黑体");
        textRun.setFontSize(40.);
        textBox.resizeToFitText();

        Slide slide2 = slideShow.createSlide();
        TextBox textBox2 = slide2.createTextBox();
        textBox2.setAnchor(new Rectangle(0, 0, 600, 100));
        TextRun textRun2 = textBox2.appendText("latin character test latin character test latin character test latin character test latin character test latin character test latin character test latin test latin character test latin character test", false);
        textRun2.setFontFamily(HSSFFont.FONT_ARIAL);
        textRun2.setFontSize(40.);
        textBox2.resizeToFitText();

        try (FileOutputStream outputStream = new FileOutputStream("e:\\temp\\test.pptx")) {
            slideShow.write(outputStream);
        }
    }

The Textbox height set by the resizeToFitText method is smaller than the actual height.

图片

图片

After adding getLeading:

图片

图片

@pjfanning
Copy link
Contributor

added with fccf4a9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants