## [Library] Popo

Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

### Re: [Library] Popo

Positive07 wrote:
adnzzzzZ wrote: So I'll ask again just in case you didnt read it: Can this lib handle UTF-8?
I have absolutely no idea. At its core all I'm doing is using love.graphics.print to print each character and getting each character's width to place them in the correct position. If those two things work the same with UTF-8 then it should work, if they don't then it shouldn't.

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

### Re: [Library] Popo

How do you split the word into characters? if you are using the string library as it is I must recommend you take a look at this UTF-8 lib by Kyle
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

### Re: [Library] Popo

Positive07 wrote:How do you split the word into characters? if you are using the string library as it is I must recommend you take a look at this UTF-8 lib by Kyle
I'm using string.sub all over from what I remember. Could you provide me with an example where this fails with UTF-8 characters?

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

### Re: [Library] Popo

When you have a string like "ñÚöàê" or similar, the characters are made of several bytes, for example the ñ is constituted by the bytes 0xC3 and 0xB1 so if you do string.sub("ñÚöàê",1,1) this would return string.char(0xC3) and string.sub("ñÚöàê",2,1) would return string.char(0xB1)

The utf8 lib provides string.utf8sub which splits the string the right way:

string.utf8sub("ñÚöàê",1,1) == string.char(0xC3,0xB1) == "ñ".

If you use string.len in the loop, string.len("ñÚöàê") would not return 5, instead it will return the number of bytes, which is not right, the utf8 lib provides string.utf8len which does this right. string.utf8len("ñÚöàê") == 5
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

### Re: [Library] Popo

Try

Code: Select all

text = Text:new("ñÚöàê")

It should not print anything in the screen, print garbage, or LÖVE will error, one or the other.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

### Re: [Library] Popo

Alright thanks for pointing that out. I updated it so that it supports UTF-8 I guess (at least the ñÚöàê example now works lol).

Positive07
Party member
Posts: 1006
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

### Re: [Library] Popo

Amazing thanks, this should fix it forever I guess
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(Github.com/Positive07)

Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

### Re: [Library] Popo

Updated this with the following things:
• Wrapping text to new lines only does it on a per word basis now
• Multiple fonts can now be used for bolding, italic, light, etc text
• .justify, .align_right and .align_center configuration settings that will align the text appropriately if .wrap_width is set

Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

### Re: [Library] Popo

Updated this with the following things:
• Fixed some new line issues where the library would treat new lines differently based on what caused them (wrap width or @n)
• Added the option to define a customDraw function where you have control over how exactly each character will be drawn instead of it being hidden away
• Updated documentation to be more clear and with a few examples in some parts

master both
Party member
Posts: 259
Joined: Tue Nov 08, 2011 12:39 am
Location: Chile

### Re: [Library] Popo

Sorry for the bump, but has anyone know what happened to this library? I can't seem to find it.
EDIT: I found this repo https://github.com/mzrinsky/popo, but it seems like it's an old version.

### Who is online

Users browsing this forum: No registered users and 13 guests