LEADTOOLS DigitalPaint provides the following function for painting text:
This function requires:
a valid paint handle.
an optional windows device context.
the bounding rectangle in which to paint the text.
This function will paint text based on the current text properties. To determine the current text properties, call L_PntGetProperty. To set or change the current text properties, call L_PntSetProperty. For more information on the text properties, refer to the PAINTTEXT structure.
Any transformation information should be set, using the L_PntSetTransformation function before calling any text or other painting function. To get the current transformation information, call L_PntGetTransformation.
The following example sets the text properties and paints some text. It assumes the paint handle has been initialized and the window handle is valid:
HDC hDC ;
PAINTTEXT text ;
RECT rcText ;
LOGFONTW lf ;
HFONT hFont ;
/* Get device context to draw on */
hDC = GetDC ( hWnd ) ;
/* Set the required text font properties */
lf.lfHeight = 48 ;
lf.lfWidth = 0 ;
lf.lfEscapement = 0 ;
lf.lfOrientation = 0 ;
lf.lfWeight = FW_NORMAL ;
lf.lfItalic = FALSE ;
lf.lfUnderline = FALSE ;
lf.lfStrikeOut = FALSE ;
lf.lfCharSet = ANSI_CHARSET ;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ;
lf.lfQuality = DEFAULT_QUALITY ;
lf.lfPitchAndFamily = FF_DONTCARE ;
lstrcpy(lf.lfFaceName, TEXT("Times New Roman"));
/* Create the desired text font */
hFont = CreateFontIndirect ( &lf ) ;
/* Set the desired text properties */
text.nSize = sizeof ( PAINTTEXT ) ;
text.dwMask = PTF_TEXT | PTF_FONT | PTF_TRANSFORMINFO ;
text.pszText = TEXT("LEAD") ;
text.hFont = hFont ;
text.TransformInfo.nRotate = 45 ;
/* Set the new text properties */
L_PntSetProperty ( pPaint, PAINT_GROUP_TEXT, &text ) ;
/* Set the target text drawing box coordinates with respect to the DC dimensions */
SetRect ( &rcText, 10, 10, 200, 200 ) ;
/*Use the current text properties and the current transformations properties to draw the text to the DC */
L_PntApplyText ( pPaint, hDC, &rcText ) ;
/* Release the device context */
ReleaseDC ( hWnd, hDC ) ;