GarageGames / Torque2D

MIT Licensed Open Source version of Torque 2D game engine from GarageGames
MIT License
1.67k stars 1.56k forks source link

TextSprite and Rus text #350

Closed yurembo closed 8 years ago

yurembo commented 8 years ago

Does TextSprite support not latin text? I tried to make a symbol map with english and russian letters, english letters render well but russian letters are invisible

capnlove commented 8 years ago

From a quick research, the .fnt file is parsed in /source/bitmapFont/bitmapFont.cc in function BitmapFont::parseFont

It doesn`t seem to check for a specific subset, just chars or char sections in the .fnt file.

That being said, I haven`t looked at how the .fnt file handles Russian characters.

greenfire27 commented 8 years ago

It's based on ASCII characters. Any character that has an ASCII number should be fine. Try comparing the contents of your fnt file with some of the example fonts.

yurembo commented 8 years ago

In ASCII table english letters took place the first part numbers (< 128), but russian letters took place above number 128. And these letters are not output I think

yurembo commented 8 years ago

Can we extend a Torque's font to support a second part of an ASCII table? @greenfire27 do you test FontAsset and TextSprite with an extended ASCII table?

greenfire27 commented 8 years ago

The TextSprite itself should be able to support anything that goes in the fnt file. Perhaps the problem is with the way Torque handles strings. Strings are just character arrays and a char in C is a value between -128 and 127. So passing in characters with ASCII values greater than 127 would probably wrap around and be processed as a negative value. Once I convert the character to an int I could try looking for negative values and un-wrap them. That might fix the problem. I'll add it to my to-do list.

yurembo commented 8 years ago

This is looking so good!

yurembo commented 8 years ago

By the way Torque 3D supports UTF-8 well

greenfire27 commented 8 years ago

@yurembo
Well good news! After some experimenting I was able to get Russian letters (Cyrillic) to work just fine. The text sprite actually runs off of UTF-16 and can support any language that Bitmap font generator supports. All you have to do is create a font with Cyrillic checked on the right. Then when you save the font it will include Russian characters. Just use the font with your TextSprite and the characters will appear just fine.

Your problem was that you tried to use Russian characters in the 128 to 255 range. Russian characters actually fall above 1000. You have to use the right values for this to work. The nice part is that Bitmap font generator does it all for you.

Hope that helps. I'm closing the issue.

yurembo commented 8 years ago

Thank you! But still it does not work for me. What software do you use?

yurembo commented 8 years ago

I read it again and again. You use Bitmap font generator. Where do I switch to use numbers above 1000?

yurembo commented 8 years ago

@greenfire27 please look my files: fnt as txt, cs as txt and visualisation as png I have no errors in the output rfont.txt sprite.txt 2016-10-18

greenfire27 commented 8 years ago

I see what's going on. Your font file has Cryllic characters but you're trying to use Latin Extended characters. Just create a font with the Latin Extended character selected like so:

latin extended

And then you'll be able to do this:

torque2d with latin extended

I'm here if you still have problems.

yurembo commented 8 years ago

These are not cyrillic characters. I made as you tell with a font file but my app outputs one line only

greenfire27 commented 8 years ago

Right, but your font file has Cyrillic characters in it - not the needed latin ones. Create a font matching my first picture and you should be able to get my second picture.

yurembo commented 8 years ago

Yep, I tryed this, nothing changes

greenfire27 commented 8 years ago

Can you attach your new fnt file as a txt file?

yurembo commented 8 years ago

Oh, sorry, I was too slow rfont.txt

greenfire27 commented 8 years ago

This font file has all the characters you need. So if you're still not seeing them in the game then the problem is somewhere else. As I said before though, it is possible to do what you are trying to do (I have the screen shot to prove it). Walk though the steps carefully to see where things are going wrong. If you need more help then you should probably email me directly.

yurembo commented 8 years ago

latin text renders well, cyrillic is not visible, latin extended != cyrillic

greenfire27 commented 8 years ago

Lol, just create a font file with both latin extended and cyrillic.

yurembo commented 8 years ago

Yesterday I tried this, bottom cyrillic line is not visible

yurembo commented 8 years ago

Can you send me your font?