Page 1 of 1
print Traditional Chinese
Posted: Thu Jun 21, 2012 6:14 am
by Eisekson
sample code:
function love.draw()
love.graphics.print("你" , 200,200)
end
it will print a Garbled.
How can I solve it?
Re: print Traditional Chinese
Posted: Thu Jun 21, 2012 7:55 am
by bartbes
Use a font that has it and make sure to use utf-8.
Re: print Traditional Chinese
Posted: Thu Jun 21, 2012 9:09 am
by Eisekson
Can you describe clearly?
Can you List some steps?
I will thank you very much for your help
Re: print Traditional Chinese
Posted: Fri Jun 22, 2012 5:23 am
by Jasoco
You will need to include a font file, TTF file with a .ttf extension, inside your game package that has the characters you want to use.
Then the editor you use to edit the code needs to be set to save the file with UTF-8 encoding. (What editor are you using for your .lua files?)
Then you would create a new font from the TTF file using your_font_variable = love.graphics.newFont("your_font_file.ttf") in the LOAD function. (NOT the DRAW or UPDATE functions. This is a mistake a lot of newbies have made actually so I'm just putting this out there.)
Then you just set it as the current font in your DRAW function using love.graphics.setFont(your_font_variable).
If the font is correct and includes the character you are using, it should work fine.
Re: print Traditional Chinese
Posted: Fri Jun 22, 2012 1:52 pm
by Eisekson
Thank you for your answer, but it does not work.
I use notepad++ and my .lua file with UTF-8 without BOM.
Here is my code and font file.
Re: print Traditional Chinese
Posted: Fri Jun 22, 2012 3:43 pm
by josefnpat
The problem is that you're trying to print latin "df".
If you open up the font editor for POKERU.TTF, you will see the
only available glyphs are poker cards and your OAU.TTF only has
the following symbolic glyphs.
Both of which do not have "d" or "f" defined.
From
here (Arphic public license?) I downloaded the first TTF and did the following:
Code: Select all
function love.load()
font = love.graphics.newFont("bkai/bkai00mp.ttf",24)
love.graphics.setFont(font)
end
function love.draw()
love.graphics.print("dj-俇俓保俖俗僛",100,100)
end
Which you can also find attached with the font!
One thing I noticed is that there are some Chinese fonts i found aren't really entirely ttf compliant, so not every single one of them works. I can see how such a basic question can actually be tricky.
I hope this helps Eisekson!
edit: grammar cleanup, and google translate says that "俇俓保俖俗僛" = "Guangjingbaopei vulgar Qi". I really have no idea how to speak or write Chinese, as it's just a super glorified dingbats to me.