Page 2 of 3
Re: [Library] Popo
Posted: Tue Jan 20, 2015 12:34 am
by adnzzzzZ
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.
Re: [Library] Popo
Posted: Tue Jan 20, 2015 1:03 am
by Positive07
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
Re: [Library] Popo
Posted: Tue Jan 20, 2015 1:09 am
by adnzzzzZ
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?
Re: [Library] Popo
Posted: Tue Jan 20, 2015 1:18 am
by Positive07
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
Re: [Library] Popo
Posted: Tue Jan 20, 2015 1:33 am
by Positive07
Try
It should not print anything in the screen, print garbage, or LÖVE will error, one or the other.
Re: [Library] Popo
Posted: Tue Jan 20, 2015 2:22 am
by adnzzzzZ
Alright thanks for pointing that out. I updated it so that it supports UTF-8 I guess (at least the ñÚöàê example now works lol).
Re: [Library] Popo
Posted: Tue Jan 20, 2015 2:48 am
by Positive07
Amazing thanks, this should fix it forever I guess
Re: [Library] Popo
Posted: Tue Mar 10, 2015 10:13 am
by adnzzzzZ
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
https://github.com/adonaac/popo
Re: [Library] Popo
Posted: Thu Jul 16, 2015 11:59 pm
by adnzzzzZ
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
https://github.com/adonaac/popo
Re: [Library] Popo
Posted: Sat Mar 03, 2018 7:05 pm
by master both
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.