Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support chinese? #213

Closed
greister opened this issue Mar 4, 2020 · 12 comments
Closed

Does not support chinese? #213

greister opened this issue Mar 4, 2020 · 12 comments
Labels
question Further information is requested text

Comments

@greister
Copy link

greister commented Mar 4, 2020

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

@hecrj
Copy link
Member

hecrj commented Mar 4, 2020

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

@hecrj hecrj added the question Further information is requested label Mar 4, 2020
@cossonleo
Copy link
Contributor

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

@usagi
Copy link

usagi commented Mar 10, 2020

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()
  })
}

@hecrj
Copy link
Member

hecrj commented Mar 10, 2020

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

@usagi
Copy link

usagi commented Mar 10, 2020

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

@Folyd
Copy link
Contributor

Folyd commented Mar 17, 2020

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

@usagi
Copy link

usagi commented Mar 17, 2020

@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.

@hecrj
Copy link
Member

hecrj commented Mar 17, 2020

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

@aisq2008
Copy link

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字体设置

@balthild
Copy link

balthild commented Aug 15, 2020

@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.

@aisq2008
Copy link

@balthild i got it,thank you!

@AAlieZZ
Copy link

AAlieZZ commented Oct 9, 2023

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字体设置

此方法在新版本中似乎不适用了

error[E0308]: mismatched types
  --> src/main.rs:14:22
   |
14 | ...fault_font:Some(include_bytes!("../fonts/PingFang-Bold.ttf")),  //设置中文的.ttf字   ...
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Font`, found `Option<&...>`
   |
   = note: expected struct `Font`
                found enum `Option<&[u8; 10923212]>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested text
Projects
None yet
Development

No branches or pull requests

8 participants