a Rich Text library for LÖVE

Showcase your libraries, tools and other projects that help your fellow love users.

Which license should richtext use?

Poll ended at Sat Oct 09, 2010 4:36 pm

Public Domain
4
22%
BSD
1
6%
MIT/X11
5
28%
LPCL
0
No votes
zlib
6
33%
LGPL
1
6%
Other (please specify in replies)
1
6%
 
Total votes: 18

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: a Rich Text library for LÖVE

Post by kikito »

Believe it or not, it still has its uses.

Hint: some mail browsers deactivate all CSS rules they find on emails.
When I write def I mean function.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Idea: RichText

Post 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
...
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: a Rich Text library for LÖVE

Post 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.
Help us help you: attach a .love.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: a Rich Text library for LÖVE

Post by Robin »

zlib it is, then.

EDIT: up on GitHub.
Help us help you: attach a .love.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: a Rich Text library for LÖVE

Post 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! :)
Help us help you: attach a .love.
luminosity
Prole
Posts: 34
Joined: Fri Sep 24, 2010 5:46 am

Re: a Rich Text library for LÖVE

Post 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.
User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: a Rich Text library for LÖVE

Post by Mud »

Just FYI, this is what I get when I run your example code (supplying my own smiley):

Image

Magnified:
Image
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: a Rich Text library for LÖVE

Post 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.
Help us help you: attach a .love.
User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: a Rich Text library for LÖVE

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: a Rich Text library for LÖVE

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 72 guests