Text on path functions?

Everything else that doesn't fall into one of the other PB categories.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Text on path functions?

Post 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! :wink: ), but am just wondering if someone can save me the bother of what will be a quite complex routine? :)

(srod = lazy b*stard! :) )
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Text on path functions?

Post 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! 8)

oh and B*stard was my call sign in the Army!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post by srod »

I was the first one to reply to the SVG thread, so yes I was aware of it. :wink:

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. :)
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Text on path functions?

Post 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! :D

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! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post 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. :)
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Text on path functions?

Post 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!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post by srod »

Yes Cairo does look impressive.
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Text on path functions?

Post 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!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
idle
Always Here
Always Here
Posts: 6239
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Text on path functions?

Post 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
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Text on path functions?

Post 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...
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post 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... :wink:
Last edited by srod on Fri Jan 08, 2010 12:53 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Text on path functions?

Post by djes »

Not in the GDI+ samples?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post by srod »

Possibly, but I do not wish to use GDI+ for this.
I may look like a mule, but I'm not a complete ass.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Text on path functions?

Post 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 :D

~ Foz
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Text on path functions?

Post by srod »

Yes exactly. Though I am hoping to avoid matrix rotation with suitable text-alignments; we shall see. :)
I may look like a mule, but I'm not a complete ass.
Post Reply