Sign in to follow this  
Followers 0
spyrorocks

Function: Installfont()

10 posts in this topic

OK, here is a function that will install a font that you specify...

Requirements: Autoit v3

Parimeters:

1. Path To Font File

Returns:

0 = Failure

1 = Success

2 = Font Already Exists

@error:

1 = Failure

2 = Not A Font File

-1 = Invalid Path To Fontfile

Example:

msgbox(0, "Font Manager", installfont("NEUROPOL.ttf"))

Function:

#include <file.au3>

func installfont($file)
; Font Function By Spyrorocks
dim $drive,$dir,$fname,$ext
if not fileexists($file) then
seterror(-1)
return 0
endif
$path = _PathSplit($file, $drive, $dir, $fname, $ext)
if not $path[4] = "ttf" then
if not $path[4] = "fon" then
seterror(2)
return 0
endif
endif
if fileexists(@WindowsDir & "\Fonts\" & $path[3] & $path[4]) then return 2
if filecopy($file, @WindowsDir & "\Fonts\" & $path[3] & $path[4]) = 0 then
seterror(1)
return 0
endif
return 1
endfunc

So, any comments or ideas?

Share this post


Link to post
Share on other sites



nice i will probally use this alot. www.dafont.com has alot of cool fonts. I always waste time doing i by hand whenever im installing a new font to use for Photoshop. But thx for the program!!!


50% of the time, it works all the time

Share this post


Link to post
Share on other sites

could be useful if you want to use a custom font in a gui, Because you can install it with this


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

take a look at your returns

they are not correct

8)

ret2

not2


NEWHeader1.png

Share this post


Link to post
Share on other sites

I looked. Where are they incorrect? I could not see. Anyways, thats nice that some people can use this :). I should now make a uninstall font function...

correction...

i confused

@error

2 = Not A Font File

and Return 2

....

also an install/uninstall with a gui would be a good idea

list the fonts on the computer and maybe get others from web-sites... at users option

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

yes you should


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

are you sure that a simple copy will work for fonts?

I remember there have been posts before and that special dllcalls were needed to register the font.

anyways this piece of code looks wrong to me:

If Not $path[4] = "ttf" Then
        If Not $path[4] = "fon" Then
            SetError(2)
            Return 0
        EndIf
    EndIf

(Indenting code helps to make it readable)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It works perfecly fine. No dllcalls are needed. I tested it and everything. It works fine.

correction...

i confused

@error

2 = Not A Font File

and Return 2

....

also an install/uninstall with a gui would be a good idea

list the fonts on the computer and maybe get others from web-sites... at users option

8)

Return 2 = Font already exists

@error = 2 = The specifyed file to install as a font is not a font file.

There is a differance.

And yes, I should work on a gui browse thinggie.

EDIT:

PS- I am now working on a font libary!

Edited by spyrorocks

Share this post


Link to post
Share on other sites

Make a font manager that you can just click on a font in a list press a uninstall button and it appears in another list, when you click it there you can press install and it's running again. I suggest moving the uninstalled fonts from "/fonts/" to "/fonts-/", i got this idea from Spybot Search and Destroy which does the same thing with startup programs.

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