sample code:
function love.draw()
love.graphics.print("你" , 200,200)
end
it will print a Garbled.
How can I solve it?
print Traditional Chinese
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: print Traditional Chinese
Use a font that has it and make sure to use utf-8.
Re: print Traditional Chinese
Can you describe clearly?
Can you List some steps?
I will thank you very much for your help
Can you List some steps?
I will thank you very much for your help
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: print Traditional Chinese
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.
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
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.
I use notepad++ and my .lua file with UTF-8 without BOM.
Here is my code and font file.
- Attachments
-
- printChinese.zip
- game package
- (49.76 KiB) Downloaded 140 times
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: print Traditional Chinese
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:
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.
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
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.
Missing Sentinel Software | Twitter
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Who is online
Users browsing this forum: No registered users and 2 guests