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 API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,754 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,731 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


Your answer

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