Sign in to follow this  
Followers 0
Amen

About Fonts

11 posts in this topic

I've got a gui that will use a Font that is not in %windir%\Fonts dir

when prog starts copies the new font there but the font cannot be used!

if i put the new font manual there works.

Is there a registration that must be done to registry or to memory after

copying the new font?

I also tryied GUICtrlSetFont command with 'fontname' targeting the font adress

without coping to %windir%\Fonts dir but didn't work.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

oh so quick reply! :dance:

seems very nice font prog.You can preview the font etc but i need install a font programatically :whistle:

Nice logo you have. a have this wallpaper too and rulez!

Edited by Amen

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I remember a dllcall method that someone used to install a font.. lemme see if I can find it..

Well I couldn't find the AutoIt script, but I found this API function: AddFontResource

I hate to pull a layer, but I don't know for sure if that will do what you're looking for, I have to get ready for work.

Edited by Saunders

Share this post


Link to post
Share on other sites

I cant' figure it out.I dont know thease staff!!

Can anyone help here?

$My_Fontname="Adventure Subtitles.ttf"
;------------------------------------------Copy the font file to Windows
$msg=Filecopy(@SCRiptDir&"\"&$My_Fontname,@WindowsDir&"\Fonts",1)
If $msg=0 then 
    MsgBox(48,"","Cannot install gui's font",3)
Else
_LoadFont($My_Fontname);------------------------------------------Load font
eNDiF

Exit

Func _LoadFont($Fontname)
$gdi32=DllOpen ("Gdi32")
If $gdi32=-1 then MsgBox(0,"DLLcall","unable Load Gdi32")
;MsgBox(0,"DLLcall",$Gdi32) 
$msg = DllCall($gdi32, "int", "AddFontResource", "str", $Fontname)
If @error=1  Then MsgBox(0,"DLLcall","unable to use the DLL file")
If @error=2  Then MsgBox(0,"DLLcall","unknown return type")
DllClose ($gdi32)
Return $msg
EndFunc

Share this post


Link to post
Share on other sites

i just added a new font with a silly name and tracked it down in the registry. remmber i am running windows 2000. !y2kbug is the name of the font.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts

the type of key is REG_SZ

the name and data are the same name, the font name of course. with llabeling of (TrueType) at the end of the name. example below

"!Y2KBUG (TrueType)"="!Y2KBUG.TTF"


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

would require beta, haven't tested

Func _LoadFont($Fontname)
    $s_p = DllStructCreate("char[" & StringLen($Fontname) + 1 & "]")
    If @error Then
        Return @error
    EndIf
    DllStructSetData($s_p, 1, $Fontname)
    $msg = DllCall("gdi32.dll", "int", "AddFontResource", "ptr", DllStructGetPtr($s_p))
    DllStructDelete($s_p)
    If @error = 1 Then MsgBox(0, "DLLcall", "unable to use the DLL file")
    If @error = 2 Then MsgBox(0, "DLLcall", "unknown return type")
    Return $msg[0]
EndFunc  ;==>_LoadFont

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Can't make smthing to work.Worked with 2 above ideas ;)

<{POST_SNAPBACK}>

It works - see the following that is fleshed out. Remmeber, you need the beta to make it work.

FileInstall("C:\temp\BADABB__.TTF", "C:\windows\fonts")
_LoadFont("BADABB__.TTF")

Func _LoadFont($Fontname)
    $s_p = DllStructCreate("char[" & StringLen($Fontname) + 1 & "]")
    If @error Then
        Return @error
    EndIf
    DllStructSetData($s_p, 1, $Fontname)
    $msg = DllCall("gdi32.dll", "int", "AddFontResource", "ptr", DllStructGetPtr($s_p))
    DllStructDelete($s_p)
    If @error = 1 Then MsgBox(0, "DLLcall", "unable to use the DLL file")
    If @error = 2 Then MsgBox(0, "DLLcall", "unknown return type")
    Return $msg[0]
EndFunc ;==>_LoadFont

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  
Followers 0