locked
Install font in windows 7

    Question

  • I wish to install a font on a windows 7 computer as follows:

    Filecopy("c:\sourcefolder\brushsci.ttf", "c:\windows\fonts\brushsci.ttf")

    This generates error = 5 and the font is not installed.

    What's wrong with this?

    Friday, November 26, 2010 5:19 AM

Answers

  • Imports System.IO

    Public Class Form1

    Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Source As String = "C:\Test\Arial3.ttf"

    Dim Destination As String = "C:\Windows\Fonts\Arial3.ttf"


    If File.Exists(Source) Then MsgBox( "File Source OK" )


    Dim Dest As String = "C:\Windows\Fonts\"

    If File.Exists(Dest) Then MsgBox( "Dest Folder OK" )

    System.IO.File.Copy(Source, Destination)


    If File.Exists(Destination) Then MsgBox( "OK" )

    Else

    MsgBox( "Fail" )

    End If

    End Sub

    End Class


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 Express
    • Proposed as answer by Acebu50t Friday, November 26, 2010 4:31 PM
    • Marked as answer by Kee PoppyModerator Wednesday, December 01, 2010 3:54 AM
    Friday, November 26, 2010 8:03 AM
  •  

    Unless your application is a font installer, You should never install a new font on your user computer.

    The reason for that, is that once installed on his computer, the font may be used for any purpose outside of your application, whish may result in Copywright problems, since your user does not have the copywright on this font  ...

    The right practice is to use an application PrivateFontCollection, which make the font installation only available to your application and this installation being a memory installation is garbage colleted when your PrivateFontCollection object is

     

     

        Dim MyFonts As New Drawing.Text.PrivateFontCollection
        MyFonts.AddFontFile("C:\tst\ahronbd.ttf")
        MyFonts.AddFontFile("C:\tst\PrivateFont1.ttf")
        MyFonts.AddFontFile("C:\tst\PrivateFont2.ttf")
        Dim Font1 = MyFonts.Families(0)
    
        Label1.Font = New Font(Font1, 16, FontStyle.Bold, GraphicsUnit.Pixel)
        Label1.Text = "CrazyPennie"
    
    

     

    • Proposed as answer by Giftzwockel Friday, November 26, 2010 8:11 PM
    • Marked as answer by Kee PoppyModerator Wednesday, December 01, 2010 3:54 AM
    Friday, November 26, 2010 2:55 PM

All replies

  • Firts of all please stay in your original thread.

    Second, I'm sot sure but I belive the path is typesensitive.

    What is error 5? Is it a individual error message of your application? Sorry I don't know error 5. If this is a own description have a look to what the error message describes.

    Last but not least look here:

    http://www.homeandlearn.co.uk/net/nets8p6.html


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 Express
    Friday, November 26, 2010 7:45 AM
  • Imports System.IO

    Public Class Form1

    Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Source As String = "C:\Test\Arial3.ttf"

    Dim Destination As String = "C:\Windows\Fonts\Arial3.ttf"


    If File.Exists(Source) Then MsgBox( "File Source OK" )


    Dim Dest As String = "C:\Windows\Fonts\"

    If File.Exists(Dest) Then MsgBox( "Dest Folder OK" )

    System.IO.File.Copy(Source, Destination)


    If File.Exists(Destination) Then MsgBox( "OK" )

    Else

    MsgBox( "Fail" )

    End If

    End Sub

    End Class


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 Express
    • Proposed as answer by Acebu50t Friday, November 26, 2010 4:31 PM
    • Marked as answer by Kee PoppyModerator Wednesday, December 01, 2010 3:54 AM
    Friday, November 26, 2010 8:03 AM
  • There might more to installing a font then putting it in the fonts folder like registry setting etc . Try running the font file as a process and see if the font preview dialogbox opens and the install button is available . You might also want to look at this link http://www.microsoft.com/typography/TrueTypeInstall.mspx
    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
    Friday, November 26, 2010 9:13 AM
  • Dear all,

     

    Sorry when I wrote nonsence. I was sure doing this successfully in the past. Might be, the font has been INSTALLED before.

    Regarding ths request I found now a exiting link:

    http://www.tek-tips.com/faqs.cfm?fid=4747


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 Express
    Friday, November 26, 2010 11:33 AM
  •  

    Unless your application is a font installer, You should never install a new font on your user computer.

    The reason for that, is that once installed on his computer, the font may be used for any purpose outside of your application, whish may result in Copywright problems, since your user does not have the copywright on this font  ...

    The right practice is to use an application PrivateFontCollection, which make the font installation only available to your application and this installation being a memory installation is garbage colleted when your PrivateFontCollection object is

     

     

        Dim MyFonts As New Drawing.Text.PrivateFontCollection
        MyFonts.AddFontFile("C:\tst\ahronbd.ttf")
        MyFonts.AddFontFile("C:\tst\PrivateFont1.ttf")
        MyFonts.AddFontFile("C:\tst\PrivateFont2.ttf")
        Dim Font1 = MyFonts.Families(0)
    
        Label1.Font = New Font(Font1, 16, FontStyle.Bold, GraphicsUnit.Pixel)
        Label1.Text = "CrazyPennie"
    
    

     

    • Proposed as answer by Giftzwockel Friday, November 26, 2010 8:11 PM
    • Marked as answer by Kee PoppyModerator Wednesday, December 01, 2010 3:54 AM
    Friday, November 26, 2010 2:55 PM