how do you make sure a font gets installed with your application

Posted on 2008-11-11
Last Modified: 2012-05-05
I have a 2008 express application that needs a particular font installed on the users machine how do do that
Question by:Dov_B
    LVL 48

    Assisted Solution

    You can check in the windows\font\ if the font was already installed.
    Something like:

            If IO.File.Exists("C:\WINDOWS\Fonts\FontName.ttf") Then
                ' font installed
            End If

    Open in new window


    Author Comment

    I did not know that Thank you
    but what I meant to ask is how do I tell to install the font
    LVL 48

    Accepted Solution

    Check this example:
    Public Class Form1
       Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
           IO.File.Copy("c:\Ayuma2yk.ttf", "c:\windows\fonts\Ayuma2yk.ttf", True)
       End Sub
    End Class
    Public Class FontUtil
       Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
       Private Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
       ''' <summary>
       ''' Installs the font
       ''' </summary>
       ''' <param name="FileName">Name of the File </param>
       Public Shared Function InstallFont(ByVal FileName As String) As Boolean
           InstallFont = AddFontResource(FileName) <> 0
       End Function
       ''' <summary>
       ''' Uninstalls the font
       ''' </summary>
       ''' <param name="FileName"> Name of the File </param>
       Public Shared Function UninstallFont(ByVal FileName As String) As Boolean
           UninstallFont = RemoveFontResource(FileName) <> 0
       End Function
    End Class

    Open in new window

    LVL 69

    Assisted Solution

    by:Éric Moreau

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    This video discusses moving either the default database or any database to a new volume.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now