Solved

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

Posted on 2011-09-23
1
752 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
Allan Nisbet 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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