Rotating Lines of Text

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

Tags :


Community Content

aimfiz69105
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);
}

Tags : logfont

Page view tracker