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

Chinese font rendering is blurring. #28

Open
AllenDang opened this issue Dec 19, 2019 · 8 comments
Open

Chinese font rendering is blurring. #28

AllenDang opened this issue Dec 19, 2019 · 8 comments

Comments

@AllenDang
Copy link

截屏2019-12-19下午5 13 16

English font rendering is pretty good. But Chinese character rendering is blurring.

I tried to set the oversimple other than 1, I got black squares.

截屏2019-12-19下午5 15 39

@dumblob
Copy link
Member

dumblob commented Dec 19, 2019

As mentioned in Credits in Readme.md, by default Nuklear embeds stb_truetype for basic font rendering, but you're free to use e.g. freetype (there might be some examples in this repo IIRC).

On the other hand, it seems stb_truetype wasn't updated for quite long in Nuklear and upstream has a new version where chances are, that the blurring will be less significant.

@AllenDang
Copy link
Author

@dumblob Thanks for your reply. I checked those two codes, is there any utils to generate from stb_truetype? So far as I see, the code is hand write line by line, not just embed directly. It seems to update is not an easy work. Am I correct?

@dumblob
Copy link
Member

dumblob commented Dec 19, 2019

@AllenDang yeah, you're right - feel free to make a PR and separate stb_truetype completely (we use the Python packing script in the same folder through paq.sh/paq.bat - see also minor changes to this "amalgamation" which we didn't have time yet to finally review and merge).

@kiwidoggie
Copy link

@AllenDang how are you rendering the Chinese font's. I'm having an issue from wchar_t to char conversion using the nk_label's.

@AllenDang
Copy link
Author

@kiwidoggie I'm using Golang binding so I guess I cannot help you one this...

@AllenDang
Copy link
Author

AllenDang commented Dec 24, 2019

@dumblob I'm trying to update stb_truetype embeded in nuklear_font.h and I find out that I need to do a lot of function and struct naming replacement there.
I'm wondering how do you do it at first place? All hand-writing or there is a script which does the "search-and-replace" work?

@ghost
Copy link

ghost commented Feb 5, 2020

I have had issues with blurry fonts as well.
What fixed it for me is finding the correct scaling value. For whatever reason, in my testing each font has a scaling value, where the font is sharp. These sharp scaling values come in steps of integers.
One font always remains sharp in steps of 4, size 24, 28, 32 etc... whilst one font only remains sharp in steps of 6, size 19, 25, 31 etc... All other values make stb_truetype produce blurry results.
All of this with oversample_v = 1, oversample_h = 1 and pixel_snap = 1.

Cranking up oversampling only helps a teeny tiny bit whilst costing a bunch of memory. If you have Window's OpenGL software fallback, then you are limited to max 1024 size textures. Oversampling easily shoots past that and you get black squares.

I tied the font scale to a slider + bake loop and tried out different fonts and sizes in real time. This is the way I found out about it and the right values. So maybe try the same.

Hope this will be fixed with the new exellent PR #53 (Although stb_truetype still does not support font hinting...)

@dumblob
Copy link
Member

dumblob commented Mar 10, 2020

@AllenDang could you retest if the update of stb_truetype (see PR #53 ) solved your problem?

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

No branches or pull requests

3 participants