Page 5 of 10

Re: a Rich Text library for LÖVE

Posted: Sat Oct 09, 2010 2:04 am
by kikito
Believe it or not, it still has its uses.

Hint: some mail browsers deactivate all CSS rules they find on emails.

Re: Idea: RichText

Posted: Sat Oct 09, 2010 11:07 am
by vrld
Robin wrote:

Code: Select all

rt = rich.new{"{black}Hello {green}world{red}, {smile} how are {{}you} doing? {big}I'm doing fine.", 200, black = {0, 0, 0}, green = {0, 255, 0}, big = love.graphics.newFont(20), red = {255, 0, 0}, smile = love.graphics.newImage('face-laugh.png')}
I know it's probably too late for this, but may I propose a kind of lispy syntax? It would be rather easy to parse and also to write:

Code: Select all

rt = rich.new{"{black Hello} {green world}{red,} {smile} how are {{} you} doing? {big I'm doing fine}.", 200, black = {0, 0, 0}, green = {0, 255, 0}, big = love.graphics.newFont(20), red = {255, 0, 0}, smile = love.graphics.newImage('face-laugh.png')}
I.e.: extract everything between matching {} and consider the first "word" as text-modifier and the rest as text to modify. It's easy to see how much text will be affected by a modifier, and nesting would also be possible:

Code: Select all

{big {blue Hello {red cruel} World}} -- instead of {big}{blue}Hello {red}cruel {blue}World
If the modifiers are actually functions, it would be dead easy to extend:

Code: Select all

modifiers = {}
modifiers["{}"] = function(text) return "{"..text.."}" end
modifiers["big"] = function(text) ... end
modifiers["blue"] = function(text) ... end
...

Re: a Rich Text library for LÖVE

Posted: Sat Oct 09, 2010 11:30 am
by Robin
Nice idea, however it will be problematic, because it requires the lib to reset the font/color itself, and the feasibility of nesting is doubtful at best. The modifiers make it even worse, because it means you can't just supply a font, but it has to be built by the renderer first.

Re: a Rich Text library for LÖVE

Posted: Fri Oct 15, 2010 9:16 pm
by Robin
zlib it is, then.

EDIT: up on GitHub.

Re: a Rich Text library for LÖVE

Posted: Sun Nov 07, 2010 4:53 pm
by Robin
Gentlement, friends, lovers.

As the release of LÖVE 0.7.0 creeps ever closer, it's time RT has a proper release as well. For that, I need help with testing.

Grab the library here (raw link). Experiment with it, use it in a new game project of yours, try to break it. From my personal testing, I can say it's fairly stable, but I really miss other people's perspectives here.

So if you are interested in this project, now's the time to help by testing it! :)

Re: a Rich Text library for LÖVE

Posted: Mon Nov 08, 2010 5:05 am
by luminosity
I just switched my combat log rendering from native love drawing to rich text. Looks nice so far. One thing I needed to hack into my copy of it was storing the total height of the rendered text on the rich text object so I could access it later -- unless I'm overlooking something I don't see anywhere that's currently stored.

Apart from that it all looks good for my admittedly limited use of it at the moment -- though I've noticed rendering text to a buffer seems to make it extremely ugly and hard to read. That seems to be love wide rather than specific to this library though. I don't suppose anyone knows what's going on there? I can attach screenshots if someone wants.

Re: a Rich Text library for LÖVE

Posted: Mon Nov 08, 2010 6:50 am
by Mud
Just FYI, this is what I get when I run your example code (supplying my own smiley):

Image

Magnified:
Image

Re: a Rich Text library for LÖVE

Posted: Mon Nov 08, 2010 7:04 am
by Robin
luminosity wrote:One thing I needed to hack into my copy of it was storing the total height of the rendered text on the rich text object so I could access it later -- unless I'm overlooking something I don't see anywhere that's currently stored.
Oh, good. I think I forgot to implement that.
EDIT: And done.
luminosity wrote:I've noticed rendering text to a buffer seems to make it extremely ugly and hard to read. That seems to be love wide rather than specific to this library though. I don't suppose anyone knows what's going on there? I can attach screenshots if someone wants.
Odd, I have never seen that effect. Screenshots would be useful, yes. :)
Mud wrote:Just FYI, this is what I get when I run your example code (supplying my own smiley):
I'm not sure, what this is, but the LÖVE 0.7.0 used to contain a bug regarding text placement. I think it'll work better if you upgrade LÖVE to the latest build.

Re: a Rich Text library for LÖVE

Posted: Mon Nov 08, 2010 8:29 am
by Mud
Robin wrote:I'm not sure, what this is, but the LÖVE 0.7.0 used to contain a bug regarding text placement.
I was more concerned with those funky rectangles (which I know is not your library's fault).
I think it'll work better if you upgrade LÖVE to the latest build.
I got the latest from here (7 weeks old). Is there a more recent binary somewhere? I pulled down the source last night, but it doesn't include the libraries it depends on (that I could see) and I was too lazy to dig them up.

Re: a Rich Text library for LÖVE

Posted: Mon Nov 08, 2010 8:43 am
by Robin
Mud wrote:I was more concerned with those funky rectangles (which I know is not your library's fault).
Oh, I thought you enabled debug mode, which draws those rectangles so you can check whether everything's aligned OK.
Mud wrote:I got the latest from here (7 weeks old). Is there a more recent binary somewhere? I pulled down the source last night, but it doesn't include the libraries it depends on (that I could see) and I was too lazy to dig them up.
Oh, that's old. Are you on windows? I think for that you need to wait until rude makes another build, or ask a friendly lover on windows who just happened to have compiled it themselves recently. If you're on Linux, you can probably work with the PPA bartbes has set up.