macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

Loading fonts causes panic

Open hasikill opened this issue 2 years ago • 6 comments

I encountered a panic while loading "Microsoft YaHei.ttf"

thread 'main' panicked at 'Vertical fonts are not supported', C:\Users\pc\.cargo\registry\src\index.crates.io-6f17d22bba15001f\macroquad-0.3.26\src\text.rs:92:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

hasikill avatar Jul 19 '23 07:07 hasikill

just tested this and the mentioned font seems to load and work with no problems when the panic on text.rs:83, is commented out, even with chinese characters.

@not-fl3 any reasons this panic should be kept? any other vertical fonts that don't work?

whouishere avatar Jul 24 '23 03:07 whouishere

just tested this and the mentioned font seems to load and work with no problems when the panic on text.rs:83, is commented out, even with chinese characters.

I do not not enough about vertical fonts, but I assume that they should be rendered vertically (draw_text should draw a label with each symbol above/beyound each other, not left to right).

So I would keep this panic on until the correct vertical rendering would be fixed.

not-fl3 avatar Jul 24 '23 05:07 not-fl3

I don't know enough about fonts to say too much about this, but my guess is that advance_height being non-zero doesn't mean the font is "vertical", it just means that it has the potential to be rendered vertically. Chinese characters are quite commonly used in both horizontal and vertical writing, so it makes sense that a font would try to support both styles. So I think ignoring it, or maybe logging a warning or something, is preferable to panicking here (a lot of chinese/japanese fonts have advance_height set, so it's pretty much impossible to render even just horizontal text in those languages using macroquad right now without forking)

TrolledWoods avatar Apr 20 '24 07:04 TrolledWoods

I'm running into this issue trying to load an ordinary Noto Sans CJK font from my system's font path - trying to open the .ttc file at all causes this panic, even though I want to render fonts horizontally.

neunenak avatar Mar 04 '25 00:03 neunenak

Bit annoying to have to vendor and invasively modify the source code just to be able to use NotoSansJP on here. There's no reason to panic this if the API only supports left-to-right (horizontal layout) writing to begin with, which said fonts will work fine with anyway.

https://freetype.org/freetype2/docs/glyphs/glyphs-3.html

djtuBIG-MaliceX avatar Mar 07 '25 16:03 djtuBIG-MaliceX

I have raised #913 to address at least my current use case for vertical font rotation.

djtuBIG-MaliceX avatar Mar 09 '25 12:03 djtuBIG-MaliceX