Skip to content

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
Member

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
Member

added with fccf4a9

@pjfanning pjfanning closed this Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants