Bases of Elements

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Green_Hell
Citizen
Posts: 94
Joined: Thu Feb 21, 2008 1:11 am

Bases of Elements

Post by Green_Hell »

Where are bases of elements? I mean where are x0 and y0?

Image and Animation have base in the center and method setCenter()
Where is in text?
base.png
base.png (2.8 KiB) Viewed 4933 times
I need to be able to do three things:
1. Count width of whole text line (works Font:getWidth( line ))
2. Count height of whole text line (Font:getHeight( )? Who knows.)
3. The most important and difficult to explain. I need to place text on position accordingly to it's width and height. To be concrete, I need to make rectangle as an envelope for the text and place it to the center of the envelope. But I need to do it dynamically. It's not possible with this unknown base.

I'd like to know how to count it in 0.3.2 and possibly some "get" "set" functions in the future.

I know, I always want more but, I believe that placing text precisely, e.g. to do text borders, is important for other people too.
>>I love LÖVE.<<
User avatar
Jake
Prole
Posts: 27
Joined: Sun Jul 20, 2008 2:01 pm

Re: Bases of Elements

Post by Jake »

This has bugged me too. Why is it at bottom left?
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: Bases of Elements

Post by mike »

Because that is how it was foretold by the gods of yore.

Actually, it's because I wrote the whole font rendering class by following what other people had done (and rude did some stuff too) and so I have no idea what's going on half the time. It's at the bottom left because that's how the FreeType tutorial I read decided to do it. Fret not, as one of the official tasks we have written down is actually "REDO FONT" because it needs to be awesome and not just a haphazard collection of code. This redoing is coming in a few years, so be patient.
Now posting IN STEREO (where available)
Green_Hell
Citizen
Posts: 94
Joined: Thu Feb 21, 2008 1:11 am

Re: Bases of Elements

Post by Green_Hell »

mike wrote:This redoing is coming in a few years, so be patient.
I don't expect anything else. I just want to know how I can count x0 y0 from it. :(

Code: Select all

If not (you know how) then
  post(".")
end
:)
>>I love LÖVE.<<
User avatar
Jake
Prole
Posts: 27
Joined: Sun Jul 20, 2008 2:01 pm

Re: Bases of Elements

Post by Jake »

mike wrote:Because that is how it was foretold by the gods of yore.

Actually, it's because I wrote the whole font rendering class by following what other people had done (and rude did some stuff too) and so I have no idea what's going on half the time. It's at the bottom left because that's how the FreeType tutorial I read decided to do it. Fret not, as one of the official tasks we have written down is actually "REDO FONT" because it needs to be awesome and not just a haphazard collection of code. This redoing is coming in a few years, so be patient.
Oh we will just have to change all our code once you've done :)
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: Bases of Elements

Post by mike »

Jake wrote:Oh we will just have to change all our code once you've done :)
Yeah, that is just retarded. I was a bit confused about the post, but let me ask you this:
HOW DO YOU WANT IT TO WORK?
I can make some minor tweaks to the Fontage we have now, if so desired.
Now posting IN STEREO (where available)
surtic
Citizen
Posts: 74
Joined: Sat Jul 12, 2008 12:18 am

Re: Bases of Elements

Post by surtic »

Well, SDL_ttf is reasonable with what it provides:
  1. Font height
  2. Font ascent
  3. Font descent
  4. Line skip
  5. Glyph metrics
  6. Size of text
  7. Render (creates a surface)
Maybe with LÖVE we can have those 'get' functions for the font, and when we render we either get an Image object, or we render at the baseline (so x = start of bounding box, y = baseline).

I've used SDL_ttf to create a GUI library and while it doesn't provide total control over positioning, it was more than enough to get what I wanted.
Mr. Strange
Party member
Posts: 101
Joined: Mon Aug 11, 2008 5:19 am

Re: Bases of Elements

Post by Mr. Strange »

mike wrote:
Jake wrote:Oh we will just have to change all our code once you've done :)
Yeah, that is just retarded. I was a bit confused about the post, but let me ask you this:
HOW DO YOU WANT IT TO WORK?
I can make some minor tweaks to the Fontage we have now, if so desired.
I'd like to see it work thusly:

love.draw("string", x, y [, font type] [,alignment] [,xmax])

The alignment would be center, left, or right. (x,y) would define the point on the center, left, or right side of the text respectively. "xmax" would be the furthest that text is allowed to extend before wrapping.

As far as vertical alignment, I believe that the bottom of the text is proper.

Is this the best way to put text on the screen? I couldn't say. But you asked what I wanted, so I mouthed off.

--Mr. Strange
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: Bases of Elements

Post by mike »

I hope you are aware of drawf:
love.graphics.drawf( string, x, y, limit, align )

limit = size of wrapper box
align = alignment of text in the wrapper box

So, here is the official question: shall X,Y point to the bottom left corner of the text or the top left or perhaps the center by default? Word your opinion here.
Now posting IN STEREO (where available)
Green_Hell
Citizen
Posts: 94
Joined: Thu Feb 21, 2008 1:11 am

Re: Bases of Elements

Post by Green_Hell »

mike wrote:I hope you are aware of drawf:
love.graphics.drawf( string, x, y, limit, align )
Isn't solution. Still draws somewhere. I can't explain what I need. :(
mike wrote:So, here is the official question: shall X,Y point to the bottom left corner of the text or the top left or perhaps the center by default?
Don't know don't care. In my opinion current base is the best for placing text on lines. As long as I'll be able to change the base, e.g. using something like getBaseX() getBaseY(), which would return current base coordinates from (I don't care which) corner, I'll be happy.
>>I love LÖVE.<<
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests