Skip to content

Conversation

@lhz07
Copy link

@lhz07 lhz07 commented May 16, 2025

Description

Currently, the font is loaded using the following code:

p->font = LoadFontFromMemory(GetFileExtension(alegreya_path), data, data_size, FONT_SIZE, NULL, 0);

In this call, the codepointCount parameter is set to 0, which causes the function to fall back to the default value of 95. As a result, only the basic ASCII characters are displayed correctly, even if the loaded font supports a wider range of characters such as CJK.

This PR introduces a function to determine the actual number of glyphs in the font when possible. By passing the correct codepointCount to LoadFontFromMemory, we ensure that all supported characters — including those in CJK and other Unicode ranges — can be properly displayed, for example in file names.

Before and After (same font used in both cases)

Before (codepointCount = 0, fallback to 95)

image

After (actual glyph count)

image

@jmnuf
Copy link

jmnuf commented Jun 13, 2025

PR doesn't work for me in Windows. When I try to run this PR it still fails to properly render non-ASCII characters.
Original title is: ダイダイダイダイダイキライ - 初音ミク VS 重音テト .mp3
image

This might be caused from windows handling file names in UTF-16 instead of UTF-8, meaning that windows requires to transform the file names for this to work. This is speculation on my part though.

@lhz07
Copy link
Author

lhz07 commented Jun 13, 2025

@jmnuf That might be the case, but it looks like the program is still using the default font. The font is hardcoded into the program, and the default one doesn't support CJK characters.
A simple workaround is to take a .ttf font that supports CJK, rename it to Alegreya-Regular.ttf, and replace the file at musializer/resources/fonts/Alegreya-Regular.ttf with your new one.
After that, recompile the program and run it!

@jmnuf
Copy link

jmnuf commented Jun 13, 2025

@lhz07 Thanks for the speedy reply!
That fixes my problem, I completely forgot about the bundle step and I had only changed the file path within plug.c
Would prefer some other form of changing fonts but this is fine. Thank you ver much!

@lhz07
Copy link
Author

lhz07 commented Jun 13, 2025

@jmnuf Glad to hear it worked!
Font switching is still quite limited currently. Support for dynamic font loading and font fallbacks would definitely help, but that depends on tsoding —— as he’s currently not accepting PRs for new features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants