Iced: Does not support chinese?

Created on 4 Mar 2020  ·  11Comments  ·  Source: hecrj/iced

I test the example/todus, found this example doesn't support chinese?
Or my config file wrong ?

question

Most helpful comment

@usagi We do not support font fallback yet either, but it's in the roadmap! See the issues I previously mentioned: #33 and #208.

All 11 comments

We do not support any form of complex text layout (i.e. shaping) yet. See #33 and #208.

One way, You can pass Appication run setting param with 'default_font' setted self font file bytes, like this:
图片

I have a similar issue too. And, @cossonleo 's method is not work for my testing.

The input text: てつさび(ja) 鐵鏽(tw) 铁锈(cn) 녹(ko) Σκουριά(el) ржавчина(ru) Médecine(fr) ยา(th)

The result:

image

Modified code (example/todos/main.rs):

pub fn main() {
  Todos::run(Settings {
    default_font: Some(include_bytes!(
      "C:/Users/usagi/tmp/NotoSansCJKjp-hinted/NotoSansCJKjp-Medium.otf"
    )),
    ..Settings::default()
  })
}

@usagi We do not support font fallback yet either, but it's in the roadmap! See the issues I previously mentioned: #33 and #208.

@hecrj Ah, "but it's in the roadmap!" that's good! Thank you. 👍👍

@usagi I don't know why the format ttf is works but others aren't. You can use .ttf instead .otf or .ttc.

@Folyd Hmm, you are right. I tried three file types.

  • ".otf" NG 🙅‍♀️
  • ".ttc" NG 🙅‍♀️
  • ".ttf" OK 🙆‍♀️

image

I don't know the details of font file types. However, it may be helpful that only the TTF type to fix the problem quickly in now.

Yes, we only support TrueType fonts for now. This is a known limitation of the renderer, which uses rusttype indirectly.

let setting = Settings {
    window: window::Settings  {
        size:(800,600),
        resizable: true,
        decorations: true,
    },
    flags:(),
    default_font:Some(include_bytes!("../fonts/fang_song.ttf")),  //设置中文的.ttf字体可以支持中文
    antialiasing:true
};

Counter::run(setting);

可以从C:\Windows\Fonts 中找宋体的ttf字体设置

@aisq2008

Be caution. The fonts shipped with Windows is copyrighted. Bundling them into your program leads to legal issues.

You can use free (free as freedom, not free beer) fonts such as WenQuanYi fonts instead, or load proprietary fonts from C:\Windows\Fonts at runtime without bundling them.

@balthild i got it,thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sumibi-yakitori picture sumibi-yakitori  ·  3Comments

Plecra picture Plecra  ·  4Comments

Newbytee picture Newbytee  ·  4Comments

CallistoM picture CallistoM  ·  3Comments

Shootertrex picture Shootertrex  ·  3Comments