Share via

Wrong font data from CreateFontIndirectW

kyle sylvestre 0 Reputation points
2023-06-19T21:30:18.13+00:00

I'm getting the same font data regardless of the style. The font face name is Cascadia Code.

// log_font has lfFaceName, lfItalic, and lfWeight initialized        
HFONT hfont = CreateFontIndirectW(&log_font);
HDC hdc = CreateCompatibleDC(NULL);
SelectObject(hdc, hfont);

std::vector<unsigned char> bytes;
DWORD size = GetFontData(hdc, 0, 0, NULL, 0);
bytes.resize(size);
GetFontData(hdc, 0, 0, &bytes[0], size);

Windows development | Windows API - Win32

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,736 Reputation points Microsoft External Staff
    2023-06-20T01:42:34.14+00:00

    The front, Cascadia Code, works for me using the document sample Drawing Text from Different Fonts on the Same Line.

    User's image

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.