Search code examples
c++fontsmfclabelletter-spacing

Letter Spacing in CStatic Control?


Is there any way to set Letter Spacing in a CStatic Label? So that "TEST" would look like "T E S T" ? I tried it via the SetFont() method using a LOGFONT and its parameters like this:

LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -24;
lf.lfWidth = -17;
lf.lfWeight = FW_THIN;
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
lf.lfQuality = ANTIALIASED_QUALITY;
wcscpy_s(lf.lfFaceName, m_mainFont.GetFontFamilyName().c_str());

CFont font;
font.CreateFontIndirectW(&lf);

m_staticCtl.SetFont(&font);

The lfWidth parameter does not seem to set any spacing, it just stretches characters in width.

Is there any option which allows letter-spacing in a CStatic Control or in a CFont? Or could I manipulate the drawing in an inherited CStatic class somehow?


Edit: I am talking about letter-spacing. The TEST was just an example... I was hoping this is clear. I want specific letter spacing between characters in pixels (not additional space characters.)


Solution

  • Is this what you need?

    "Intercharacter spacing is controlled using the GDI call SetTextCharacterExtra. Another answer would be to use ExtTextOut".... http://social.msdn.microsoft.com/Forums/vstudio/en-US/538607f8-0d88-42f3-b6bc-f3008002b607/how-to-change-the-lineheight-and-letterspacing-value-when-drawing-text-in-gdiplus?forum=vcgeneral