StarArawn / kayak_ui

Other
469 stars 50 forks source link

Is there a way to import Chinese fonts? #268

Open king0952 opened 1 year ago

king0952 commented 1 year ago

I've tried to use msdf-atlas-gen.exe to generate somefont.png and somefont.kayak_font files, but neither font_mapping.set_default(asset_server.load("somefont.kayak_font")); nor font_mapping.set_default(asset_server.load("somefont.kttf")); worked for me. The terminal throws an error:

ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error`
Caused by:
    In CommandEncoder::copy_texture_to_texture
    Copy error
    copy of Z 500..501 would end up overrunning the bounds of the Destination texture of Z size 500

And I found pub const MAX_CHARACTERS: u32 = 500; in src/bevy/renderer/font_texture_cache.rs. The Chinese character set is much larger than [0x20] - [0x7f], so is there a way to use a character set which is more than 500 characters?

StarArawn commented 1 year ago

I've tried to use msdf-atlas-gen.exe to generate somefont.png and somefont.kayak_font files, but neither font_mapping.set_default(asset_server.load("somefont.kayak_font")); nor font_mapping.set_default(asset_server.load("somefont.kttf")); worked for me. The terminal throws an error:

ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default thread 'Compute Task Pool (1)' panicked at 'wgpu error: Validation Error`
Caused by:
    In CommandEncoder::copy_texture_to_texture
    Copy error
    copy of Z 500..501 would end up overrunning the bounds of the Destination texture of Z size 500

And I found pub const MAX_CHARACTERS: u32 = 500; in src/bevy/renderer/font_texture_cache.rs. The Chinese character set is much larger than [0x20] - [0x7f], so is there a way to use a character set which is more than 500 characters?

We can problem bump the character limit here to 2000. Feel free to open a PR. 👍