Use of CreateFontIndirect

Discussion in 'Win32' started by watson, Jul 24, 2010.

  1. watson

    watson New Member

    Joined:
    Jul 24, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Say, if I want to create a font:
    Code:
    LOGFONT lf = {0};
    lf.lfHeight = 12;
    lf.lfWeight = FW_THIN;
    VERIFY(StringCchCopy(lf.lfFaceName, sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]), _T("Calibri")) == S_OK);
    HFONT hFont = CreateFontIndirect(&lf);
    if(!hFont)
    {
    	//Font created OK
    }
    
    If I specify pretty much any name as lfFaceName CreateFontIndirect() returns a handle anyway. My understanding was that it will return NULL if it can't create that exact font. Am I correct on that one?

    PS. I'm running this code on Windows 7, so maybe they added some fail-safe mechanism for it already...

    PS 2. I'm kind of confused over this statement:

    I do not have a machine with East Asian languages, nor that I can speak those languages. What would be the correct way to create a font on those machines?

    The strategy I thought of is to try to create a font that I want, say, "Calibri", and if it can't be created (if it's not installed), try some basic font, like "Arial" for instance. But again, CreateFontIndirect seems to return a handle for any font type name I specify for it.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice