Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am just wondering if anybody knows of a convenient way to get all the names of fonts and font colors in two different arrays.

I am attempting to make a text editor using win32 C/C++ and I would like to display all the fonts and font colors in a combo boxes.


Thanks for your time,
robNO.
Posted

Hi,

You can enumerate fonts by using the EnumFontFamilies function[^] and supplying an EnumFontFamProc callback function[^].

or

On Windows Vista SP2 and above you could use the IDWriteFontCollection[^]. Font Enumeration Sample[^].

[Update 03, December, 2011]
Sorry, I forgot about the color part of the question. You could use the GetSystemPaletteEntries function[^] to retrieve the system palette associated with the device context... but realistically... this is a non-issue in the year 2011.

Browser Display Statistics[^] : 97% of the world is capable of displaying 24+ bits of color.

If you want to support the remaining 3% you should read some old articles such as: Colors: The Safety Palette[^] (Notice the date of 1996)

Best Wishes,
-David Delaune
 
Share this answer
 
v2
Comments
RobNO 2-Dec-11 16:36pm    
Thanks for your Help!!!
robNO.
Fonts don't have colours they are merely shapes. When displaying characters on a device context you set the colours using the RGB macro selected from this information[^].
 
Share this answer
 
Comments
RobNO 1-Dec-11 14:47pm    
Is it possible to get a standard set of colors programatically rather than hardcodding colors? For example, the Standard HTML Colors in your link in some sort of container.
Richard MacCutchan 2-Dec-11 4:36am    
I'm not aware of any Windows function that does that. Whenever I have needed such a list I've created it from the HTML set which are published in various places as found here by Google.
RobNO 2-Dec-11 16:36pm    
Thanks For your Help!!!

robNO.
[no name] 3-Dec-11 18:35pm    
Hi,

I have updated my answer to #include some information about color depth and safe color palettes.

Best Wishes,
-David Delaune

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900