Board index » delphi » Font FileName if you only know the Font.Name

Font FileName if you only know the Font.Name

Does anybody know how to retrieve the filename of a font when you only know
the font name ?

thx,
Peter

 

Re:Font FileName if you only know the Font.Name


Quote
Peter & {*word*122} wrote:

> Does anybody know how to retrieve the filename of a font when you only know
> the font name ?

Getting Times New Roman (asuming Windows 9x still stores it's font
information in win.ini... Windows NT will automatically map this to the
registry.):

  with TIniFile.Create('WIN.INI') do
  begin
    FontFile := ReadString('Fonts', 'Times New Roman (TrueType)', '');
    Free;
  end;

-- Erwin Dokter
   mailto:edok...@home.nl
   http://members.home.nl/edokter

Re:Font FileName if you only know the Font.Name


In article <VU7w6.37418$tk.4232...@afrodite.telenet-ops.be>,
ecly...@pandora.be says...

Quote
> Does anybody know how to retrieve the filename of a font when you only know
> the font name ?

In the Registry,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts lists
installed fonts by name as its Values. Value data for each is the
corresponding filename. If no path, it's in the Fonts folder. The names
contain extra information, e.g. truetype fonts have " (Truetype)"
appended.

The Registry value names can be changed. To be absolutely sure you're
matching the font name to its filename, you'd have to read the fonts in
the Fonts folder and extract the name from each. A {*word*193} business.

--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

Re:Font FileName if you only know the Font.Name


Hi Neil,

Thanks for your reply. (I'm honored.)  It helped me a great deal further.

I'd like to make a few additional comments :

-First, as you say, it's indeed a {*word*193} business to get information out of
font files.  I only know one freeware component that does a bit of this
trick (Ttfcomp), but even that is not completely foolproof.

-Second, fonts can also be stored in the system32 directory instead of the
fonts directory and even then there are no paths mentioned in the registry,
so you still don't know the exact path of the fontfile.

-Third, there's also still an additional check for the windows version to
make if you want to find the correct registry key.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts

-Also, even when the fonts appear to be TrueType fonts, the extra
information added to the fontname is sometimes empty, sometimes 'normal' ,
sometimes ' (Truetype)', or maybe even other things, which doesn't make it
any easier to identify the correct ttf-files.

What a windows nightmare....

But I know where to look and what to check for now, so thanks again and
please don't forget to check out the 'X-Fonter' utility on
http://users.pandora.be/eclypse
(just wait a few days until my new version is ready :-)

Greetings,
Peter Boey

"Neil J. Rubenking" <jrube...@SPAM-B-GONE.mother.com> wrote in message
news:MPG.152ba1267dd57f329899af@news.mother.com...

Quote
> In article <VU7w6.37418$tk.4232...@afrodite.telenet-ops.be>,
> ecly...@pandora.be says...
> > Does anybody know how to retrieve the filename of a font when you only
know
> > the font name ?

> In the Registry,
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts lists
> installed fonts by name as its Values. Value data for each is the
> corresponding filename. If no path, it's in the Fonts folder. The names
> contain extra information, e.g. truetype fonts have " (Truetype)"
> appended.

> The Registry value names can be changed. To be absolutely sure you're
> matching the font name to its filename, you'd have to read the fonts in
> the Fonts folder and extract the name from each. A {*word*193} business.

> --
> Neil J. Rubenking
> Contributing Technical Editor
> PC Magazine

Other Threads