Jump to content

About Fonts


Amen
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
Link to comment
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"

Link to comment
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.

 

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...