GDI+ and text outlines

Post your working scripts, libraries and tools
cmann
Posts: 8
Joined: 03 Feb 2014, 09:36

GDI+ and text outlines

03 Feb 2014, 10:04

I have been using the GDI+ library I found here: http://www.autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/ and recently I wanted to draw text with outlines but GDI does not directly provide functions to do this so I found some articles on the internet and implemented it myself.

I have attached the file Gdip_Ext.ahk where you can find the new function which supports text outlines as well as some other extra functions that were missing from the original library.
A few of the functions that I added were copied from someone else but I cannot remember where I originally found them.

Usage:
I simply made a copy of the original function and named it Gdip_TextToGraphics2 so it functions exactly like the original except there are now 3 extra options:
OW<Width>: Specifies the outline width. Set this to a value >= 0 to enable outlines eg. ow2
OC<ARGB>: Sets the outlines colour eg. ocFF00FF00 will make a fully opaque green outline
OF<0 or 1>: If this option is set to 1 the text fill will be drawn using the same path that the outline is drawn with and the FillPath function instead of the default DrawString method. The reason I added this option is because text and paths are rendered slightly differently so when using the DrawString method the text outline and the text fill may not line up perfectly. Enabling this option can produce better results.
Attachments
Gdip_Ext.zip
(2.98 KiB) Downloaded 159 times
User avatar
noname
Posts: 507
Joined: 19 Nov 2013, 09:15

Re: GDI+ and text outlines

05 Feb 2014, 08:47

I get an error for non existent function and i do not have a clue what that function should be.


Error: Call to nonexistent function.

Specifically: out("YO1", RC_x, RC_y)
cmann
Posts: 8
Joined: 03 Feb 2014, 09:36

Re: GDI+ and text outlines

05 Feb 2014, 15:36

lain wrote:I get an error for non existent function and i do not have a clue what that function should be.


Error: Call to nonexistent function.

Specifically: out("YO1", RC_x, RC_y)

Sorry, my mistake. I used those lines when testing the script and they should have been taken out, I have uploaded the script again with them removed
Attachments
Gdip_Ext.zip
(2.94 KiB) Downloaded 189 times
User avatar
noname
Posts: 507
Joined: 19 Nov 2013, 09:15

Re: GDI+ and text outlines

07 Feb 2014, 08:31

Thanks for sharing,very nice. :)
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: GDI+ and text outlines

07 Feb 2014, 09:00

any examples using these functions? :geek:
cmann
Posts: 8
Joined: 03 Feb 2014, 09:36

Re: GDI+ and text outlines

10 Feb 2014, 08:52

I have taken the original text drawing sample from the library and added in a second line of text using my extend function.
It is very simple to use and the options and results are identical to the original function, all you have to do is specify an outline colour and width.

Just look for the line that says "Gdip_TextToGraphics2 example" somewhere in the middle of the script

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



You can find the original samples here: http://www.autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/
And the example I used was the eighth one.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 14 guests