How draw chinese word?

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
User avatar
netwan
Prole
Posts: 5
Joined: Tue Jul 21, 2009 3:23 pm
Location: China.Guangdong

How draw chinese word?

Post by netwan »

I write a test love project. test output Chinese word, How can i do to got the correct .
THANKS!

Code: Select all

function load()

font = love.graphics.newFont("simsun.ttc", 14) -- the number denotes the font size
love.graphics.setFont(font)

end

function update(dt)
end


function draw()

love.graphics.draw("中文\nhello world", 100, 100)

end
love.JPG
love.JPG (19.32 KiB) Viewed 4571 times
LÖVE, i'mlovin'it
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: How draw chinese word?

Post by rude »

Can't do that. Have to use ImageFont. One day Unicode will be supported, but doing it properly is pretty complex. For now, there's only ascii truetype fonts and ImageFont.
User avatar
Tenoch
Citizen
Posts: 76
Joined: Mon Jul 21, 2008 7:49 am

Re: How draw chinese word?

Post by Tenoch »

Does "one day" mean 0.6? Because now that we have unicode input (well, at least locale translated input), it's be rather useless if we couldn't draw inputed text on screen...

EDIT: I suppose we don't use SDL_ttf then, since unicode works fine with it.
"When in doubt, use brute force." Ken Thompson
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: How draw chinese word?

Post by bartbes »

You could've looked that up yourself.. We use libfreetype.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: How draw chinese word?

Post by rude »

Most certainly not 0.6.0. This does not make translated chars useless. It respects keyboard layout and modifier keys. Many non-US chars are in ascii.
Can't use SDL_ttf. Way too simple. Does not use GPU in correct way. There is a tracker issue on the subject with an interesting link.


(Reason for odd sentences: mobile phone)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: How draw chinese word?

Post by bartbes »

I just checked the source and a manual I found, it seems the glyphs are loaded by using glCallLists. (please correct me if I'm wrong, I don't know OpenGL) With this information, and the fact that freetype supports unicode, I would conclude that it might be as easy as changing GL_UNSIGNED_BYTE into GL_UNSIGNED_SHORT. (1 byte -> 2 bytes)
I might be way off, but it can't be that hard, because freetype is supposed to support unicode.

(reason for odd sentences: it's me :P)

EDIT: or GL_2_BYTES, but it seems that reads the bytes in reverse order (or I'm just wrong, again)
User avatar
Tenoch
Citizen
Posts: 76
Joined: Mon Jul 21, 2008 7:49 am

Re: How draw chinese word?

Post by Tenoch »

rude wrote:Many non-US chars are in ascii.
Mmm, I'm sorry but that is not entirely correct. ASCII is on 7 bits only, and has 128 characters only: some nonprintable stuff and
123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

I suppose you meant any of the 8 bits encodings that uses ASCII as the 128 lowest characters. From the little test I ran, it appears that draw() (or print() in 0.6) interprets strings as ISO 8859-1

Its printable higher chars are:
¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ

(which indeed covers many european languages)

Encodings jungle FTW :neko:
"When in doubt, use brute force." Ken Thompson
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: How draw chinese word?

Post by rude »

bartbes: can't use glCallLists in the future. Not supported by OGL ES. Also: not nearly enough GPU memory to create textures for the entire Unicode range.

Tenoch: I meant within 8bits, yes. I know nothing about encodings. :)

(still mobile)
Post Reply

Who is online

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