EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.74k stars 136 forks source link

Font support for unicode characters? #678

Open riimi opened 5 years ago

riimi commented 5 years ago

Hi! I am new to engo, into it these days. I have been trying to draw a string containing unicode characters: Korean, Chinese, Japanese. Do I have to implement a new shader for this? Thanks in advance!

Noofbiz commented 5 years ago

The font shader should be able to handle it, but right now it's limited to the first 200 glyphs from the font here. This is so that generating a font atlas happens quickly and gets everything you need, but also because I've never taken the time to use fonts containing those characters. I think the easiest fix would be to allow users to set the number of Glyphs used, and have it default to 200 if they don't.

riimi commented 5 years ago

I solved the problem by increasing UnicodeCap according to your advice. But, the solution seems inefficient way because the font makes the big font atlas starting from index 0. I think I will have to find more efficient way to support multiple languages.

Noofbiz commented 5 years ago

Yeah I'm thinking of adding to fonts a []int that will let you decide which code points are used. If empty it'll do 0-200 for backwards compatibility. I think this is best because then if you only need 8 characters it'll only make 8 characters and not waste memory on the other ones.