[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] how to find the actual font name from windows

From: Peter Montgomery
Subject: Re: [Freetype] how to find the actual font name from windows
Date: Thu, 27 Feb 2003 11:04:55 -0800


In an app I wrote, I needed to provide a list of human readable font
names to the user and get the corresponding TTF filenames.  I don't know
how anyone else does this, but here are the steps I needed to do:

1: Determine what platform the program is running on.  This is done with
a call to "GetVersionEx( )" and checking the value of the "dwPlatformId"

2: Build a string that points to the registry entry.  This path will be
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" + the windows platform +
"\CurrentVersion\Fonts\".  You need to use the information of what
platform you are running on to construct the part of the path that says
"the windows platform".  In the case of Window 95, 98, 98ME, 98,SE, you
just use "Windows".  In the case of Windows NT, 2000, XP(?), you use

3: Open the registry and enumerate all the names.  That is the human
readable part.  For each name, there is a data entry which is the font
filename.  If you are displaying the human readable names, you'll
probably want to remove the "(TrueType)" part of the string which is on
every name.  If you open RegEdit, you can look at this key and see what
I am talking about.

4: You need to find the path where Windows stores the fonts.  This is
done with a call to "SHGetSpecialFolderLocation( ), where the call will
look something like this:


SHGetSpecialFolderLocation(Application.Handle, CSIDL_FONTS, PIDL);

In this case, the 1st parameter is you application main handle, the
second is a constant defined in the Windows headers telling it what path
you're looking for, and the last is a pointer that will carry the return
value.  Here's a code snippet in Delphi from my application.  Note that
you have to free some memory when you're done:

  Path := StrAlloc(MAX_PATH);
  SHGetSpecialFolderLocation(Application.Handle, CSIDL_FONTS, PIDL);
  if SHGetPathFromIDList(PIDL, Path) then
    CurrWindowsFontPath := Path;

  // Make sure the path has a trailing directory separator
  CurrWindowsFontPath :=

5: At this point, you now have the path and a list of all the font names
in both human readable and TTF file form.  You can then build the string
to open any font file you want if you know the name of it.


----- Original Message -----
From: "Daniel B{ck" <address@hidden>
To: <address@hidden>
Sent: Thursday, February 27, 2003 9:13 AM
Subject: [Freetype] how to find the actual font name from windows

> Hi!
> I'm kind of in the same situation as Ian trying to use freetype with
> LOGFONTs. I looked throught the documentation and i didn't find any
> Windows-specific interface (Similar to the Mac-specific interface) is
> there a plan for this to come?
> I would also be interested in that code snippet that gets a filename
> Thanks in advance.
> Daniel
> At Mon, 28 Jan 2002 09:19:26, Leonard Rosenthol wrote:
> >At 11:10 AM 1/28/2002 +0100, Ian Brown wrote:
> >>       this is only peripherally related to freetype, but this
> >like
> >>the best list to ask. The bar code library that we use in our main
> >>application has moved over to using freetype for the human readable
> >text.
> >>This means that I now have to pass it a font filename rather than a
> >>The problem is that the main application still uses LOGFONTs (needs
> >be
> >>backwards compatible).
> >>So, I need to find the actual font file that windows is using when I
> >select
> >>a particular LOGFONT. Does anyone have any ideas how to get this?
> >>
> >
> >         I was just sent a code snippet that does exactly this -
> >LOGFONT->filename for use with FreeType.  I am looking at how best to
> >integrate it into the FT library much the same way as we do it on the
> >OS side.
> >
> >         If you would like the code for yourself in the meantime, I
> >certainly send it to you...
> >
> >
> >>In our main application, I use GetFontData() to read the file ...
but I
> >need
> >>to pass a filename to the library.
> >
> >         Actually, this will work fine - just use the memory calls
> >(FT_New_Memory_Face() instead of FT_New_Face()).
> >
> >
> >Leonard
> >
> _______________________________________________
> Freetype mailing list
> address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]