Solved

How do I check if a font exists on the user's computer?

Posted on 2011-09-23
1
723 Views
Last Modified: 2013-12-17
I have code to install fonts, but I don't want to be running that code every time the user starts the program...only when the font does not exist.  So how do I check to see if the font is already loaded on the user's machine?
0
Comment
Question by:David L. Hansen
1 Comment
 
LVL 13

Accepted Solution

by:
StormITSolutions earned 500 total points
ID: 36590499
Imports System
Imports System.Windows.Forms
Imports System.Drawing.Text
Imports System.Drawing

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        ' Get the installed fonts collection.
        Dim installed_fonts As New InstalledFontCollection

        ' Get an array of the system's font familiies.
        Dim font_families() As FontFamily = installed_fonts.Families()

        ' Display the font families.
        For Each font_family As FontFamily In font_families
            Console.Write (font_family.Name & ", ")
        Next font_family
    End Sub
End Class

Open in new window


This is a way to get all the fonts installed on a system


Use something like this
InstalledFontCollection installedFontCollection = new InstalledFontCollection();

// Get the array of FontFamily objects.
FontFamily[] fontFamilies = installedFontCollection.Families;

Open in new window


Then compare the font you want to install with the array for a match

Storm
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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