First take a program that converts any binary to C (bin2c but I wrote my own for inhouse work) and write out your binary into C code (unsigned char).
Make sure you know the real font's name because Windows isn't going to let you write in the font if you don't know its real name.
Now with that done and having the info ready here is the magical Windows' code
Code: Select all
DWORD nFonts;
size_t len = sizeof(FONT_FROM_THE_C_FILE_WE_CONVERTED);
void *data = NAME_OF_THE_FONT_FROM_THE_C_FILE_WE_CONVERTED;
void *m_fonthandle = AddFontMemResourceEx(data, len, NULL, &nFonts);
if(m_fonthandle==0)
wxLogError("Font add failed.");
Basically, I just write out the binary of the .ttf into an unsigned char that gets placed into a .cpp file then I include that inside my main .cpp so that my application will then have the font embedded into it and I don't need it on the end user's hard drive nor in a cumbersome resource.
I hope this helps someone out there.