CN1FontBox load "msyh.ttf" IOException

32 views
Skip to first unread message

lang wul

unread,
Aug 12, 2014, 1:41:34 AM8/12/14
to codenameone...@googlegroups.com
Hi,

I try using CN1FontBox  ;and load  "msyh.ttf" (Microsoft provide the font for Chinese),    then throw "java.io.IOException: Invalid Characters codes";

My code like,

         FontBoxFontProvider fontProvider = FontBoxFontProvider.getDefaultProvider();
           
        InputStream is = Display.getInstance().getResourceAsStream(null, "/msyh.ttf");
       
        fontProvider.loadTTF("msyh", is);//throw  Exception

can anyone give me some  suggestions? Very thanks.

Steve Hannah

unread,
Aug 12, 2014, 4:39:54 AM8/12/14
to codenameone...@googlegroups.com

Can you post the full stack trace?

Steve

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/b414c43d-adb8-434f-bcc9-766f24f15d2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lang wul

unread,
Aug 12, 2014, 9:02:01 PM8/12/14
to codenameone...@googlegroups.com
Hi,thanks

java.io.IOException: Invalid Characters codes
at org.apache.fontbox.ttf.CMAPEncodingEntry.processSubtype12(CMAPEncodingEntry.java:243)
at org.apache.fontbox.ttf.CMAPEncodingEntry.initSubtable(CMAPEncodingEntry.java:111)
at org.apache.fontbox.ttf.CMAPTable.initData(CMAPTable.java:100)
at org.apache.fontbox.ttf.AbstractTTFParser.parseTables(AbstractTTFParser.java:156)
at org.apache.fontbox.ttf.TTFParser.parseTables(TTFParser.java:46)
at org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:82)
at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:27)
at org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:57)
at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:27)
at ca.weblite.codename1.fontbox.FontBoxFontProvider.loadTTF(FontBoxFontProvider.java:66)
at hcit.mobile.natives.codename.FontUtil.showWords(FontUtil.java:38)
at com.myapp.MyApplication.init(MyApplication.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.codename1.impl.javase.Executor$1.run(Executor.java:70)
at com.codename1.ui.Display.processSerialCalls(Display.java:1080)
at com.codename1.ui.Display.mainEDTLoop(Display.java:902)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Shai Almog

unread,
Aug 13, 2014, 1:29:44 AM8/13/14
to codenameone...@googlegroups.com
Hi,
does the font include that character?

lang wul

unread,
Aug 13, 2014, 2:19:51 AM8/13/14
to codenameone...@googlegroups.com
Hi ,Shai
   Sorry,I didn't get your means,
    I had try two ways using the ".ttf" ,one is CN1FontBox  code like the above,another is 'com.codename1.ui.Font'
    code like 

        Label l = new Label();
        Font font = Font.createTrueTypeFont("微软雅黑", "MSYH.ttf");

        l.getStyle().setFont(font.derive(10, 5));
        l.setText("中文");

       and this shows well;But use the way from cn1lib of CN1FontBox  it throw the exception.So I think it's not the matter of "MSYH.ttf";I'm not sure  if you can get my  expression easily,thanks.

Shai Almog

unread,
Aug 13, 2014, 10:36:27 AM8/13/14
to codenameone...@googlegroups.com
Hi,
no idea in that case.

Steve Hannah

unread,
Aug 13, 2014, 11:05:19 AM8/13/14
to codenameone...@googlegroups.com

It is possible that the fontbox library doesn't support Chinese characters.  I'll look into the error more closely today and see what's going on.

On Aug 13, 2014 7:36 AM, "Shai Almog" <shai....@gmail.com> wrote:
Hi,
no idea in that case.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.

lang wul

unread,
Aug 13, 2014, 11:31:14 PM8/13/14
to codenameone...@googlegroups.com
Hi,
   I get a new problem  today. I  put "msyh.ttf"(whose size is almost 14M) in my project and run well in simulator .But when  I send android built  ,I run the app in device ,it showed the error dialog said "At internal application error occurred: 
java.lang.RuntimeException:native typeface cannot be made"

  what may be the reason of that?


  
Reply all
Reply to author
Forward
0 new messages