0 out of 1 rated this helpful - Rate this topic

Rotating Lines of Text

This content has moved to another location. See Rotating Lines of Text for the latest version.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
LOGFONT structure initialization
There's a lot more to initializing a LOGFONT descriptor than what this code does. Here's a better approach:

void init_logfont_descriptor(LOGFONT     *lf, //)
                             C8          *typeface_name,
                             S32          point_size,
                             F32          escapement,
                             FONT_EFFECTS effects)
{
   CHARSETINFO csi;

UINTa curSysCp = GetACP();

S32 result = TranslateCharsetInfo((DWORD *) curSysCp, &csi, TCI_SRCCODEPAGE);

memset(lf, 0, sizeof(LOGFONT));

HDC hSDC = GetDC(NULL);
   lf->lfHeight = -MulDiv(point_size, GetDeviceCaps(hSDC, LOGPIXELSY), 72);
   ReleaseDC(NULL, hSDC);

lf->lfWidth = 0;
   lf->lfEscapement    = (S32) (escapement * 10.0F);
   lf->lfOrientation   = (S32) (escapement * 10.0F);
   lf->lfUnderline     = FALSE;
   lf->lfStrikeOut     = FALSE;
   lf->lfCharSet       = csi.ciCharset;
   lf->lfOutPrecision  = OUT_DEFAULT_PRECIS;
   lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
   lf->lfQuality       = PROOF_QUALITY;
   lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;

strcpy(lf->lfFaceName, typeface_name);

lf->lfWeight = (effects & FE_BOLD) ? FW_BOLD : FW_NORMAL;
   lf->lfItalic = (S8) ((effects & FE_ITALIC) ? TRUE    : FALSE);
}