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 wrote:adnzzzzZ wrote: So I'll ask again just in case you didnt read it: Can this lib handle UTF-8?
[Library] Popo
Re: [Library] Popo
- Positive07
- Party member
- Posts: 1014
- 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/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: [Library] Popo
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 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
- Positive07
- Party member
- Posts: 1014
- 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
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/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: [Library] Popo
Try
It should not print anything in the screen, print garbage, or LÖVE will error, one or the other.
Code: Select all
text = Text:new("ñÚöàê")
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
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: 1014
- 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/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
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
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 new_line_positions and n_lines variables to expose more information when texts have multiple lines
- 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: 262
- 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.
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 6 guests