Sign in to follow this  
Giblodian

Text placement.

Recommended Posts

I'm fairly certain this is more of a technique question than an API one. Here goes. I have a bunch of concave objects. Free Image Hosting at www.ImageShack.us I want to put text on the concave object achieving a result like Free Image Hosting at www.ImageShack.us currently I achieve it by layering the first on top of this Free Image Hosting at www.ImageShack.us I believe this is icky because it makes things rigid, names are hardcoded into the map. I'd like to tell them where to go in a text file, or whatever. However, I'm not aware of any methods that would allow me such free form, to rotate, to shrink or grow, to ensure that the names fit entirely with an object, etc. is basically hardcoding them into the image my only choice? [Edited by - Giblodian on September 13, 2009 5:59:41 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Sik_the_hedgehog
Tried storing the text data and its properties such as position, rotation, maximum size, etc.?

EDIT: er, I guess my reply is a bit off >_>' It's hard to tell though, your question doesn't seem very clear.


English is not my first language, I'm sorry. I basically want to place text, and have it look the same way as it does in the image, but I don't want to hardcode it into the image.

So in the example shown I can switch places with Dublin or whatever, without actually editing the image, just a text file.

I could just specify absolute positions, but there'd be no guarantee that the resulting text would fit nicely within the object, I'd have to adjust font size manually, play with values for each name, etc. it just seems like a hassle.

I'm wondering if there is a rountine I could write, that would automagically resize the text, rotate it, etc. so it fits in whatever blob.

Share this post


Link to post
Share on other sites
Sounds like you would need a pretty complex algorithm for edge detection on the image. You could use a text file, with position and rotation coordinates for the text, plus the actual text itself, run edge detection on the image and resize the text so that it fits inside the nearest edges. That's about the only option I can think of off the top of my head.

It'd probably be easiest if you rendered the text to a texture first, that way you can gain easier resize/rotation properties than if you use text directly rendered to the screen buffer, but I may be off on that assumption.

Share this post


Link to post
Share on other sites
This problem would make for an awesome exam question. :)

I've never done anything like this, but my initial thought would be to start by storing the points of each polygon within a data file. From there, I'd try something like computing the greatest distance between any two points. Knowing that, you would have some idea of the orientation the text would need to be, along with the max allowable width. Getting the height could be a little trickier; maybe after computing the largest width, you might try and find the greatest distance (height) between two points that form a line that is tangent (or close enough) to the maximum width line?

My immediate concern with that approach is that the polygons are concave, which means that the greatest distance line may not lie entirely within the bounded polygon. If the polygons were all convex, life would be easier.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this