Font Embedding
-
Hi everyone! I'm desperly trying to make application, in Borland C++ 5.0, with my TTF fonts inside it.(I think its called Font embedding) Is there anyone who could help? I'd be gratefull:rolleyes: tanx dArK cHAriSmA
-
Hi everyone! I'm desperly trying to make application, in Borland C++ 5.0, with my TTF fonts inside it.(I think its called Font embedding) Is there anyone who could help? I'd be gratefull:rolleyes: tanx dArK cHAriSmA
I did this for an MFC application recently. I guess it’ll be similar with Borland. I created a custom resource, gave it a name, and associated it with the .TTF file. Then when I built the .exe file, I found the byte sequence for the .TTF file inside. So that’s the first step – getting the .TTF file into the .exe file. The second step is to get the byte sequence at run time. Call
::FindResource()
, then::LoadResource()
, then::LockResource()
, then::SizeofResource()
. The third step is to tell Windows to use the byte sequence as a TrueType font. I haven’t found a good way of doing this. I don’t know if there is a good way. The method I use uses two indirections. Having found the byte sequence, write it out to a temporary file, then read in the file using::AddFontResource()
. Then call::CreateFontIndirect(&lf)
, having setlf.lfFaceName
to the name of your font, and hope that Windows chooses to use your font. Then call::FreeResource()
(I’m not sure if this is necessary, but some of the MSDN samples do it). And before your program ends, call::RemoveFontResource()
, otherwise your font will probably be in the system for ever more. HTH, Chris.