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

a Rich Text library for LÖVE

Post by Robin »

Update: For the latest version, go to GitHub.

Yet another idea, which will have to wait for implementation until that friggin laptop arrives.

Anyway, the idea is this: a library that knows how to draw text with different fonts, and how to insert images between them.

The lover would specify what to draw by doing something like:

Code: Select all

rt = rich.new("Hello, {font:big}world! {img:smile}", {big = bigFont, smile = smileyImage})
--or
rt = rich.new{"Hello, {font:big}world! {img:smile}", big = bigFont, smile = smileyImage})
--or
rt = rich.new{"Hello, {big}world! {smile}", big = bigFont, smile = smileyImage}
(I'm not sure yet which is better.)

Then one would do:

Code: Select all

function love.draw()
    rt:draw()
end
rich.new() will probably start by rendering to a Framebuffer, because such text is probably static while quite expensive to generate.

I'm also planning on having it word-wrap and handle NPO2 images gracefully.

What do you think? Useful or useless?

EDIT: closed poll. Popular vote decided RT to be licensed zlib.
Last edited by Robin on Fri Dec 03, 2010 10:50 pm, edited 3 times in total.
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Idea: RichText

Post by nevon »

Yes please! I've had to do stuff like this manually oh-so-many times, and it's a freaking pain.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Idea: RichText

Post by Robin »

Good. You (and other lovers who'd like to use this) could help by listing requirements and such while I wait for my new laptop to arrive. ;)
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Idea: RichText

Post by nevon »

Optional parameters for specifying the width and height of the image(s), since you often have to pad for Po2-ness, is the first thing that comes to mind.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Idea: RichText

Post by Robin »

nevon wrote:Optional parameters for specifying the width and height of the image(s), since you often have to pad for Po2-ness, is the first thing that comes to mind.
Ah, yes, I had that in mind as well.

Here's the idea: you can specify an image as, well, an image:

Code: Select all

... keyz = love.graphics.newImage("images/keys/z.png"), ...
or as a table:

Code: Select all

... keyz = {love.graphics.newImage("images/keys/z.png"), width = 36, height = 26}, ... -- where that image is padded in the image editor to 64x32
(or perhaps even with a string:

Code: Select all

... keyz = "images/keys/z.png", ...
)

The big idea is, that if you don't manually specify a width and height, the library will autopad the image itself, remember the original dimensions, and use those for drawing.
Help us help you: attach a .love.
User avatar
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm
Location: Canada

Re: Idea: RichText

Post by VideroBoy »

If we can specify dimensions, we should also have Quad support.

Code: Select all

rt = rich.new("Hello, {font:big}world! {img:smile quad:myQuad}", {big = bigFont, smile = smileyImage, myQuad = whateverQuad})
Also, may I propose either HTML or BBCode as the syntax?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Idea: RichText

Post by Robin »

VideroBoy wrote:If we can specify dimensions, we should also have Quad support.

Code: Select all

rt = rich.new("Hello, {font:big}world! {img:smile quad:myQuad}", {big = bigFont, smile = smileyImage, myQuad = whateverQuad})
Good idea. However, I don't think it would be specified in-string, but rather as something like:

Code: Select all

rt = rich.new("Hello, {font:big}world! {img:smile}", {big = bigFont, smile = {smileyImage, quad = whateverQuad}})
This to keep the strings relatively easy to parse.
VideroBoy wrote:Also, may I propose either HTML or BBCode as the syntax?
You may. Syntax is of course subject to change (since I haven't written a damned line for it yet), but I think I might actually prefer the BBCode-inspired "tags", since [] do not require the shift key to type them (as opposed to {} and <>, at least on my keyboard).

And another thing: I think the font: and img: prefixes will be dropped, since their type can be inferred.

Example:

Code: Select all

rt = rich.new("Hello, [big]world! [smile]", {big = bigFont, smile = {smileyImage, quad = whateverQuad}})
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Idea: RichText

Post by nevon »

Robin wrote:I think I might actually prefer the BBCode-inspired "tags", since [] do not require the shift key to type them (as opposed to {} and <>, at least on my keyboard).
Instead they require Ctrl + Alt or Alt Gr. Wee! :P (Don't really care either way)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Idea: RichText

Post by bartbes »

I prefer rich.new{} syntax btw.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Idea: RichText

Post by Robin »

Heh, as soon as I saw you replied, I thought "bartbes is going to burn this idea to the ground, showing three different reasons why it is both unneccesary and destined for failure". (Actually I was waiting for this since I wrote the OP.) :crazy:

But anyway, you reminded me of something rather important I forgot: the alternate alternate syntax I had in mind:

Code: Select all

rt = rich.new("Hello, ", bigFont, "world! ", {smileyImage, quad = someQuad})
... only this may not be feasible, since I intend to add optional extra parameters for wrapping and such.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 82 guests