Search Knowledge Base by Keyword
CreatePointFont function to dynamically create barcodes within a C++ application?
Can the CreatePointFont function be used to dynamically create instances of fonts within a C++ application? Yes, it can. The following is an example of using the CreatePointFont function. Ensure that the variables are scoped properly to avoid any problems with the fonts being sized correctly through each pass of this routine.
/***************************************************************/
private void CreateAFont()
{
//Create a font object in case we want to test with a different kind of font
CFont pageNumFont;
//The initial point size times a "magnifier" variable.
pageNumFont.CreatePointFont(200 * m_Flags.m_Zoom, "Arial Bold", pCDC);
//Here is the data that is going to be drawn on the screen
CString pageStyleNum = "898798789:;
//Create a font object
CFont OCRAfont;
long lPointSize = 100;
//Create a 10 Point font out of the IDAutomationOCRa font using the device context
//of the screen. The parameters are the point size of the font (multiplied
//by a factor of 10), the name of the font, and a pointer to the device
//context that the font will be drawn on
OCRAfont.CreatePointFont(lPointSize , "Advocra", this->GetDC());
//Here is the bounding rectangle for the text that we are going to draw
CRect OCRArect(50, 100, 600, 200);
//Select the font needed to draw with
pCDC->SelectObject(&OCRAfont);
pCDC->DrawText(pageStyleNum, OCRArect, DT_SINGLELINE | DT_LEFT |
DT_NOCLIP);
}
/***************************************************************/