We have an application that allows our users to create ready-to-print PDF documents using variable data (names, names, phone numbers, etc.) that their customer enters through the e-commerce website. To facilitate variable data, we need to embed the entire font character map. In windows, we use the Windows API function GetFontData (...) as follows:
#ifdef Q_WS_WIN
HDC DC = CreateCompatibleDC(NULL);
HFONT hFont = font.handle();
HFONT oFont=(HFONT)SelectObject(DC,hFont);
DWORD fontLength = ::GetFontData(DC, 0, 0, 0, 0);
if(fontLength != GDI_ERROR)
{
fontData.GrowAllocation(fontLength);
if(::GetFontData(DC, 0, 0, fontData.GetBuffer(), fontLength) == GDI_ERROR)
{
fontData.Clear();
}
else
{
fontData.SetLength(fontLength);
returnVal = true;
}
}
SelectObject(DC,oFont);
DeleteDC(DC);
#elif defined(Q_WS_MAC)
#endif
This method works very well in our particular version of Windows; however, we ported the application to Qt for installation on the Mac OSX platform.
: Qt QFont, QFontDatabase .., pdf? . #ifdef . , fontData , , , .
: Qt OS, OSX GetFontData?