[ 
https://issues.apache.org/jira/browse/ODFTOOLKIT-421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Svante Schubert resolved ODFTOOLKIT-421.
----------------------------------------
    Resolution: Works for Me
      Assignee: Svante Schubert

Hello Jerry,

if you take a look into the test file 
simple/src/test/java/org/odftoolkit/simple/text/ParagraphStyleHandlerTest.java
on the test case 
testGetFont()
you will see that you need to get a StyleHandler to add an Asian Font.
I tested it positive by extending the test case using your example to:

@Test
public void testGetFont() {
    try {
        TextDocument doc = TextDocument.newTextDocument();
        Paragraph paragraph = doc.addParagraph("paragraphTest");
        ParagraphStyleHandler paragraphHandler = paragraph.getStyleHandler();

        Font fontBase = new Font("Arial", FontStyle.ITALIC, 10, Color.BLACK, 
TextLinePosition.THROUGH);
        paragraphHandler.setFont(fontBase);
        //validate
        Font font = paragraphHandler.getFont(Document.ScriptType.WESTERN);
        Assert.assertEquals(fontBase, font);

        paragraphHandler.setFont(fontBase, Locale.CHINESE);
        //validate
        Font font1 = paragraphHandler.getFont(Document.ScriptType.WESTERN);
        Assert.assertEquals(fontBase, font1);

        Paragraph p1= doc.addParagraph("English");
        ParagraphStyleHandler p1Handler = p1.getStyleHandler();

        Font kaiu = new Font("標楷體", FontStyle.BOLD, 14, Color.BLUE);
        //p1Handler.setFont(kaiu);
        p1Handler.setFont(kaiu, Locale.CHINESE);

        Paragraph p11= doc.addParagraph("中文字");
        ParagraphStyleHandler p11Handler = p11.getStyleHandler();
        p11Handler.setFont(kaiu, Locale.CHINESE);

        //save
        
doc.save(ResourceUtilities.newTestOutputFile("testParagraphStyleHandlerChinese.odt"));
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        Assert.fail(e.getMessage());
    }
}

You might still want to provide a patch to improve the API if you like...

> Chinese Word Can't set font
> ---------------------------
>
>                 Key: ODFTOOLKIT-421
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-421
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>         Environment: win7,Jdk 1.6, simple-odf-0.8.1-incubating.jar
>            Reporter: JerrySieHsiung
>            Assignee: Svante Schubert
>            Priority: Minor
>
> I use two Paragraph , set the word "English" and "中文字", and set their font.
> the fontFamilyName,simpleFontStyle,fontSize of "中文字" is no use
> [code]
> Font kaiu = new Font("標楷體", FontStyle.BOLD, 14, Color.BLUE);
> Paragraph p1= doc.addParagraph("English");
> p1.setFont(kaiu);
> Paragraph p11= doc.addParagraph("中文字");
> p11.setFont(kaiu);
> [/code]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to