Page 1 of 2
Bases of Elements
Posted: Wed Aug 27, 2008 8:55 pm
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 (2.8 KiB) Viewed 4939 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.
Re: Bases of Elements
Posted: Wed Aug 27, 2008 9:11 pm
by Jake
This has bugged me too. Why is it at bottom left?
Re: Bases of Elements
Posted: Wed Aug 27, 2008 10:46 pm
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.
Re: Bases of Elements
Posted: Wed Aug 27, 2008 11:45 pm
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
Re: Bases of Elements
Posted: Thu Aug 28, 2008 12:50 am
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
Re: Bases of Elements
Posted: Thu Aug 28, 2008 5:25 pm
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.
Re: Bases of Elements
Posted: Thu Aug 28, 2008 9:30 pm
by surtic
Well, SDL_ttf is reasonable with what it provides:
- Font height
- Font ascent
- Font descent
- Line skip
- Glyph metrics
- Size of text
- 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.
Re: Bases of Elements
Posted: Thu Aug 28, 2008 11:19 pm
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
Re: Bases of Elements
Posted: Fri Aug 29, 2008 5:23 pm
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.
Re: Bases of Elements
Posted: Fri Aug 29, 2008 6:22 pm
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.