Love 9.0 UTF Image Font Help!

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
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Love 9.0 UTF Image Font Help!

Post by Ekamu »

LÖVE expects ISO 8859-1 encoding for the glyphs string.
Does this mean their is no support for Japanese Kana. ISO 8859-1 has support for the Latin alphabet only.

I assumed that was an old message. UTF-8 has support for Kana but my image font does not work still.

Here is my code-arrangement.

Code: Select all

	
love.graphics.newImageFont("resources/jfont1.png"," アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ"
    .."あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽ".."0123456789。、「」!?"),
    }
But I get an error saying syntax error unexpected symbol near ','
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love 9.0 UTF Image Font Help!

Post by bartbes »

I think that was for 0.8.0 only, and 0.9.0 should support utf-8 in the glyphs string. That said, the error you're getting is a syntax error, this means your code has not been formatted correctly, this has nothing to do with whether newImageFont supports utf-8 or not.
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Love 9.0 UTF Image Font Help!

Post by Ekamu »

yes your right, the syntax error it was a } misplaced somewhere...

now I get a decoding error not enough space.

I am using UTF-8 encoding without a Bomb lol. (UTF-8 without BOM).
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love 9.0 UTF Image Font Help!

Post by bartbes »

That error usually means an unfinished codepoint somewhere, are you sure it's valid utf-8?
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Love 9.0 UTF Image Font Help!

Post by Ekamu »

hmm how do I check if its valid utf-8?

here is my font table

Code: Select all

    font = {
	--Japanese Font Furagana-Katakana
	love.graphics.newImageFont("resources/jfont1.png"," アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ"
    .."あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽ".."0123456789。、「」!?"),
    love.graphics.newImageFont("resources/jfont2.png"," アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ"
    .."あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽ".."0123456789。、「」!?"),
    }
bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

[]

Post by bekey »

-snip-
Last edited by bekey on Fri Jan 24, 2014 1:35 am, edited 2 times in total.
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Love 9.0 UTF Image Font Help!

Post by Ekamu »

I still get the same error:

Decoding error there is not enough space in function "print"

So the actual image font is configured correctly...
Last edited by Ekamu on Tue Dec 31, 2013 9:52 pm, edited 2 times in total.
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Love 9.0 UTF Image Font Help!

Post by Ekamu »

Attached is the love file.
lunarv0.81.love
Attached Love File
(335.08 KiB) Downloaded 350 times
Barbarosso
Prole
Posts: 1
Joined: Thu Jan 02, 2014 4:30 am

Re: Love 9.0 UTF Image Font Help!

Post by Barbarosso »

JTEXT = "にほんご"
Its length is not 4 but 12.
Because UTF-8 Japanese character size is 3 bytes.
And, lua has poor support multi byte language.
In lua, UTF-8 string is more like byte array than string.

I suppose this program failed to generate text.cat's content at text_loop function.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Love 9.0 UTF Image Font Help!

Post by slime »

Your function text_loop updates text byte-by-byte (string.sub, string.len, etc. work with bytes), but your UTF-8 text uses multiple bytes per character, so the encoding of the string becomes broken when you do that. I'm not positive this is the (only) problem, but it seems very likely.

You can use a library such as this to do UTF-8 unicode aware operations on strings.

EDIT: yeah, what Barbarosso said.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests