print Traditional Chinese

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Eisekson
Prole
Posts: 3
Joined: Thu Jun 21, 2012 5:54 am

print Traditional Chinese

Post by Eisekson »

sample code:

function love.draw()
love.graphics.print("你" , 200,200)
end

it will print a Garbled.

How can I solve it?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: print Traditional Chinese

Post by bartbes »

Use a font that has it and make sure to use utf-8.
Eisekson
Prole
Posts: 3
Joined: Thu Jun 21, 2012 5:54 am

Re: print Traditional Chinese

Post by Eisekson »

Can you describe clearly?

Can you List some steps?

I will thank you very much for your help
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: print Traditional Chinese

Post 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.
Eisekson
Prole
Posts: 3
Joined: Thu Jun 21, 2012 5:54 am

Re: print Traditional Chinese

Post by Eisekson »

Thank you for your answer, but it does not work.

I use notepad++ and my .lua file with UTF-8 without BOM.

Image

Here is my code and font file.
Attachments
printChinese.zip
game package
(49.76 KiB) Downloaded 140 times
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: print Traditional Chinese

Post 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.
Attachments
suVbu.png
suVbu.png (218.86 KiB) Viewed 263 times
KcrWG.png
KcrWG.png (191.77 KiB) Viewed 263 times
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
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests