 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
viciouskinid
Joined: 23 Jun 2007 Posts: 136
|
Posted: Tue Jul 22, 2008 2:16 pm Post subject: Portable font |
|
|
I am using a font that is not standard in windows. Is there a way that I can call the font without having to install it on each computer.
something like the below
Gui,1: Font, s8 CDefault, today.TTF
but it doesn't work. |
|
| Back to top |
|
 |
argneo
Joined: 14 Sep 2007 Posts: 136
|
Posted: Tue Jul 22, 2008 2:38 pm Post subject: |
|
|
Not if you pretend to use text as it is. Because you are using windows controls, and windows needs to install the font. _________________ WoW |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Wed Jul 23, 2008 4:59 am Post subject: Re: Portable font |
|
|
| viciouskinid wrote: | | I am using a font that is not standard in windows. Is there a way that I can call the font without having to install it on each computer. |
The simplest way is to put font on you scripts folder and load it as follows:
| Code: | DllCall( "AddFontResource", Str,"MyFont.TTF" )
SendMessage, 0x1D,,,, ahk_id 0xFFFF ; Broadcast the change |
But the problem is the font will be accessible from other applications ( like, Word, Wordpad ), even though your script quits. The user would mostly have to reboot to ward-off he effect
You could the icon load private if the OS version >= Win2k.
Here is a working example:
| Code: | #SingleInstance, Force
IfNotExist, DS-DIGIB.TTF
URLDownloadToFile, http://autohotkey.net/~goyyah/samples/DS-DIGIB.TTF, DS-DIGIB.TTF
DllCall( "GDI32.DLL\AddFontResourceEx", Str,"DS-DIGIB.TTF",UInt,(FR_PRIVATE:=0x10), Int,0)
Gui, +ToolWindow
Gui, Font, s48, DS-Digital Bold
Gui, Add, Text, w200 h100 +Border +0x201, 88:88
Gui, Show,, Digital Clock
Return
GuiClose:
DllCall( "GDI32.DLL\RemoveFontResourceEx",Str,"DS-DIGIB.TTF",UInt,(FR_PRIVATE:=0x10),Int,0)
ExitApp |
If you want no dependency and would like to load the font directly fom the script, try the following topic: Crazy Scripting : Include and Use TrueType font from Script posted by SKAN
 |
|
| Back to top |
|
 |
viciouskinid
Joined: 23 Jun 2007 Posts: 136
|
Posted: Wed Jul 23, 2008 5:43 am Post subject: |
|
|
Thanks I will try that.
One question.
I have been using dlls a lot but it has been a copy and paste exercise. I was wondering where I could go to get some documentation on dlls. I am looking for something that explains what is possible. How did you find out about "AddFontResource". I want to know what else I am missing out on. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Wed Jul 23, 2008 5:57 am Post subject: |
|
|
| viciouskinid wrote: | | I have been using dlls a lot but it has been a copy and paste exercise. I was wondering where I could go to get some documentation on dlls. I am looking for something that explains what is possible. |
I always keep digging MSDN and CodeProject.com.
When I started as a newbie, there were very few people proficient with DllCall(), but now there are many and lots of resources in the forum.
I might want to collaborate with heresy in future:
| Quote: | | How did you find out about "AddFontResource". |
I was a newbie and Serenity enlightened me about it : http://www.autohotkey.com/forum/viewtopic.php?p=43981#43981
 _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|