Page 1 of 1
Text on path functions?
Posted: Wed Jan 06, 2010 2:58 pm
by srod
Hi,
has anyone coded any kind of routine (Windows) for rendering text on any GDI path? For example, displaying a line of text on the boundary of a circle etc?
I understand the principles of how to do this kind of thing (and possess the math skills!

), but am just wondering if someone can save me the bother of what will be a quite complex routine?
(srod = lazy b*stard!

)
Re: Text on path functions?
Posted: Thu Jan 07, 2010 8:05 pm
by Rook Zimbabwe
srod... There was a recent post about SVG graphics... vector graphics is what thatis all about (Corel Draw which I KNOW you know!) I bet you could use that to do this!
oh and B*stard was my call sign in the Army!
Re: Text on path functions?
Posted: Thu Jan 07, 2010 8:19 pm
by srod
I was the first one to reply to the SVG thread, so yes I was aware of it.
SVG is not what I am after on this occasion, but good old GDI.
It's no problem, I'll just have to roll my sleeves up and get busy.

Re: Text on path functions?
Posted: Thu Jan 07, 2010 9:00 pm
by Rook Zimbabwe
I had done just thought that since it pretty much had to be on a vector to get the shape correct that SVG wuold be the natural accompliment!
http://sourceforge.net/projects/freetype/
http://www.xach.com/lisp/vecto/
http://www.apptree.net/drawkit.htm
http://cairographics.org/
http://g2.sourceforge.net/
http://www.afterstep.org/afterimage/
http://www.levien.com/libart/
I think the latest OGRE may have some ability in this scope as well...
Hope something helps!

Re: Text on path functions?
Posted: Thu Jan 07, 2010 9:14 pm
by srod
I appreciate the effort, but PB GDI code is what I am after and was just hoping that someone had already done the necessary grunt work.

Re: Text on path functions?
Posted: Thu Jan 07, 2010 9:16 pm
by Rook Zimbabwe
You know Cairo might work for Kwai Chang and his arrows issue!
I wish we had access to COCO as that drawkit looks FANTASTIC!
Re: Text on path functions?
Posted: Thu Jan 07, 2010 9:18 pm
by srod
Yes Cairo does look impressive.
Re: Text on path functions?
Posted: Thu Jan 07, 2010 10:01 pm
by Rook Zimbabwe
INKscape (A tool I am using and watching like I did with GIMP for years) uses Cairo
http://inkscape.modevia.com/win32libs/
They maintain a build for windows as well!
Re: Text on path functions?
Posted: Fri Jan 08, 2010 7:58 am
by idle
Why cant you use the PB DrawRotatedText into an image and blit it to the dc?
So draw regular text to an image get its extents and then calculate the path
Re: Text on path functions?
Posted: Fri Jan 08, 2010 11:03 am
by Foz
He's wanting to draw text that runs a long a (what could be a twisty) path, so that means for each letter point calculating the letter rotation, and making sure that it doesn't "crash" into the other letters.
We did do this in .net for rendering our own street maps (writing street names on twisty streets), but that obviously isn't in PB, otherwise I'd post it...
Re: Text on path functions?
Posted: Fri Jan 08, 2010 11:24 am
by srod
Yes Foz is correct; take any closed GDI path, flatten it and then position each character perpendicular to the line segment upon which the glyph's baseline will reside. Not too difficult in theory, but in practice...

Re: Text on path functions?
Posted: Fri Jan 08, 2010 12:50 pm
by djes
Not in the GDI+ samples?
Re: Text on path functions?
Posted: Fri Jan 08, 2010 12:53 pm
by srod
Possibly, but I do not wish to use GDI+ for this.
Re: Text on path functions?
Posted: Fri Jan 08, 2010 1:02 pm
by Foz
GDI+ doesn't have a draw text to path - otherwise we would have used it when rendering our street maps, we want simple
Our code is a two stage process:
1. Calculate the angle and offset of each letter to the next (using Vector3 Lerps)
2. Use a matrix to rotate and transform the location for drawing each letter
There might be easier methods, but it was the easiest for us, and that was key
~ Foz
Re: Text on path functions?
Posted: Fri Jan 08, 2010 1:13 pm
by srod
Yes exactly. Though I am hoping to avoid matrix rotation with suitable text-alignments; we shall see.
