PDA

View Full Version : enumerate the available fonts


clueless
01-14-2008, 07:20 PM
Does anyone know how to enumerate the available fonts in windows? Im sure ive seen this somewhere before. Thanks.

FoxLeader
01-14-2008, 10:01 PM
You have to enumerate the files in _SystemFolder.."\\Fonts I don't remember if it's the right name for _SystemFolder, but I think so. However I don't remember which action is for listing the files in a folder.

You could always try to get this information from the registry, but I don't know enough to help you more about it.

holtgrewe
01-14-2008, 10:01 PM
hth - I'm not really sure if this is what you're looking for.

result = File.Find("C:\\Windows\\Fonts\\", "*.ttf", false, false, nil, nil);
for x = 1, 5 do
Dialog.Message("Font: ", ""..result[x], MB_OK)
end

I'm just displaying the first 5 in this example.

clueless
01-15-2008, 04:40 AM
ahh, of course. *slaps head*
thanks. :yes

FoxLeader
01-15-2008, 11:24 AM
...but all the fonts are not TTF. There's at least OTF, but there's another if I recall correctly.

Intrigued
01-15-2008, 07:27 PM
You could just use "*.*" instead of the hard-coding the extention. But make sure to error check after you get that table of index, values!

Mina
01-16-2008, 05:09 AM
Also,
I think it might be safer to use

Shell.GetFolder(SHF_FONTS) instead of "C:\\Windows\\Fonts\\"

( if your program will be distributed )

hth - I'm not really sure if this is what you're looking for.

result = File.Find("C:\\Windows\\Fonts\\", "*.ttf", false, false, nil, nil);
for x = 1, 5 do
Dialog.Message("Font: ", ""..result[x], MB_OK)
end

I'm just displaying the first 5 in this example.