Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name of a font file.

Status
Not open for further replies.

Tremorblue

Programmer
Apr 30, 2004
56
GB
Hi,

I am using borland builder v6.

If I have the name of a font file (from c:\windows\fonts) to find the name of that font file in borland builder ?

Or is there a way to do the opposite, find a font file given a font name.

Thanks
TBlue
 
I should explain the name is from a font dialog box and its a string like this "Arial Black" from that I need to find out which .ttf file is required for that font. In this case it would be ariblk.ttf

TBlue.
 
I worked it out myself... This function searches the registry for the font file..

AnsiString __fastcall TForm1::FindFontFile(AnsiString aFontName)
{
if(aFontName!="")
{
TRegistry *RegistryKey = new TRegistry();
AnsiString OpenKey;
TStringList *Keys = new TStringList;
RegistryKey->RootKey = HKEY_LOCAL_MACHINE;
OpenKey = "Software\\Microsoft\\WindowsNT\\CurrentVersion\\Fonts";
RegistryKey->OpenKeyReadOnly(OpenKey);
RegistryKey->GetValueNames(Keys);
for(int i=0;i<Keys->Count-1;i++)
{
if(UpperCase(aFontName)==UpperCase(Keys->Strings.SubString(1,aFontName.Length())))
{
return(RegistryKey->ReadString(Keys->Strings));
}
}
delete RegistryKey;
}
return("");
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top