I'm trying to write some code to select a bold font (I actually want to get the font filename to send to a cross platform font renderer, but that's not too relevant). I use CreateFont() setting the cWeight to FW_BOLD and pszFaceName to "Arial". I select this font into a DC and use GetTextFace() to check which font was actually selected. The result is Arial. I was surprised that the font wasn't Arial Bold, which is a separate face with a different font file. The only way to specify the Arial Bold font was to set pszFaceName to "Arial Bold". Unfortunately simply appending Bold to the end of a font name only works for some fonts as some fonts don't have a separate bold font.
Is there any general way to specify bold that will ensure the actual bold version of a font is returned?
Thanks
Phil
This is just not the way it works, the Windows font mapper won't substitute the face name. "Arial Bold" is not a standard font nor does it have any relation to the standard "Arial" font. If you want to use it then you'll have to ask for it.
Asking for "Arial" with FW_BOLD selects the c:\windows\fonts\arialbd.ttf font file. A font file that was expressly designed to render bold arial. With a face name of "Arial". Similarly, ariali.ttf supplies the italic version, arialbi.ttf supplies the bold italic version, arial.ttf is the normal one.