## Which license should richtext use?

Public Domain
4
22%
BSD
1
6%
MIT/X11
5
28%
LPCL
0
zlib
6
33%
LGPL
1
6%
1
6%

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

### a Rich Text library for LÖVE

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.
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

### Re: Idea: RichText

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

### Re: Idea: RichText

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.
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

### Re: Idea: RichText

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

### Re: Idea: RichText

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.
VideroBoy
Party member
Posts: 102
Joined: Wed Mar 31, 2010 6:12 pm

### Re: Idea: RichText

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

### Re: Idea: RichText

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}})

nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

### Re: Idea: RichText

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! (Don't really care either way)
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Idea: RichText

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

### Re: Idea: RichText

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.)

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.