Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of fonts (Win32)

Tags:

c++

fonts

winapi

I want to make a combo box with all of the computer's installed fonts enumerated in it. I'm not sure how this is done. Do I need to access the registry to get this? Thanks

like image 474
jmasterx Avatar asked Apr 23 '10 21:04

jmasterx


2 Answers

You should use the Win32 API function EnumFontFamiliesEx. You call that function, passing a callback function matching the type of EnumFontFamExProc. The callback function is called once for every font found by EnumFontFamiliesEx.

I'd recommend using the unicode version (EnumFontFamiliesExW), as I've seen the ascii version (EnumFontFamiliesExA) display some very weird behaviour for East Asian language fonts.

The linked articles have example code.

like image 161
JoeG Avatar answered Nov 08 '22 12:11

JoeG


The winapi way of doing it is using EnumFontFamiliesEx function. You should pass a filled structure with default param DEFAULT_CHARSET to list all installed fonts.

See MSDN to get more information.

like image 45
M. Williams Avatar answered Nov 08 '22 13:11

M. Williams