Bug 52516 - Wrong font displayed in ppt
Summary: Wrong font displayed in ppt
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-24 14:28 UTC by Stefan
Modified: 2014-12-29 23:23 UTC (History)
0 users



Attachments
sample file with accents (11.50 KB, application/vnd.ms-powerpoint)
2012-02-22 12:10 UTC, Yegor Kozlov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan 2012-01-24 14:28:49 UTC
Slide slide = slideShow.createSlide();
		TextBox shape = new TextBox();
		RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
		shape.setHorizontalAlignment(TextBox.AlignLeft);
		rt.setFontName("Times New Roman");
		shape.setText("testingöäåendtesting");
		rt.setFontSize(12);
		shape.setAnchor(new java.awt.Rectangle(495, 375, 210, 115));
		slide.addShape(shape);	

This adds a textbox in a powerpoint slide where"testing" and "endtesting" is in the font Times New Roman, but the string "öäå" is in the font Arial.
Comment 1 Yegor Kozlov 2012-02-07 10:11:19 UTC
At the moment we don't have an active developer working on HSLF. You will have to wait until the problem is fixed. 

Yegor
Comment 2 Yegor Kozlov 2012-02-22 12:09:55 UTC
I can't reproduce it. Here is my program based on your code snippet and I see "öäå" in the output, see attached. 


        SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();

        TextBox shape = new TextBox();
        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
        shape.setHorizontalAlignment(TextBox.AlignLeft);
        rt.setFontName("Times New Roman");
        shape.setText("testingöäåendtesting");
        rt.setFontSize(16);
        shape.setAnchor(new java.awt.Rectangle(495, 375, 210, 115));
        slide.addShape(shape);

        FileOutputStream out = new FileOutputStream("52516.ppt");
        ppt.write(out);
        out.close();

Please post full Java code that generates problematic output.

Yegor
Comment 3 Yegor Kozlov 2012-02-22 12:10:53 UTC
Created attachment 28361 [details]
sample file with accents
Comment 4 yangseungsoo 2014-04-10 02:58:26 UTC
hi i'm have to same problem 

SlideShow ppt = new SlideShow();
        Slide slide = ppt.createSlide();

        TextBox shape = new TextBox();
        RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
        shape.setHorizontalAlignment(TextBox.AlignLeft);
        rt.setFontName("맑은 고딕");
        shape.setText("test테스트123");
        rt.setFontSize(16);
        shape.setAnchor(new java.awt.Rectangle(495, 375, 210, 115));
        slide.addShape(shape);

        FileOutputStream out = new FileOutputStream("52516.ppt");
        ppt.write(out);
        out.close();

"test" and "123" is in the font 맑은 고딕  but the String "테스트" is "굴림"
Comment 5 Andreas Beeker 2014-12-29 23:23:55 UTC
I can't reproduce the error - please make sure to use escape sequences for chinese (or similar) symbols. In case your chosen font doesn't support the characters, there's also a fallback handling (see #55902 / TestFontRendering class) - something similar is used by Office and could happen when your source code contains umlauts and is not saved/processed in UTF-8.

This was my test code:

@Test
public void bug52516() throws Exception {
    SlideShow ppt = new SlideShow();
    Slide slide = ppt.createSlide();

    TextBox shape = new TextBox();
    RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
    shape.setHorizontalAlignment(TextBox.AlignLeft);
    rt.setFontName("MS PGothic");
    shape.setText("test\uD14C\uC2A4\uD2B8123");
    rt.setFontSize(16);
    shape.setAnchor(new java.awt.Rectangle(495, 375, 210, 115));
    slide.addShape(shape);

    shape = new TextBox();
    rt = shape.getTextRun().getRichTextRuns()[0];
    shape.setHorizontalAlignment(TextBox.AlignLeft);
    rt.setFontName("Times New Roman");
    shape.setText("testingöäåendtesting");
    rt.setFontSize(16);
    shape.setAnchor(new java.awt.Rectangle(10, 10, 210, 115));
    slide.addShape(shape);
    
    
    FileOutputStream out = new FileOutputStream("52516.ppt");
    ppt.write(out);
    out.close();        
}