StringFormat::GenericTypographic method (gdiplusstringformat.h)

The StringFormat::GenericTypographic method creates a generic, typographic StringFormat object.

Syntax

const StringFormat * GenericTypographic();

Return value

Type: StringFormat*

This method returns a pointer to the new StringFormat object.

Remarks

A generic, typographic StringFormat object has the following characteristics:

  • String format flags StringFormatFlagsLineLimit, StringFormatFlagsNoClip, and StringFormatFlagsNoFitBlackBox are set.
  • Character alignment and line alignment are set to StringAlignmentNear.
  • Language ID is set to neutral language, which means that the current language associated with the calling thread is used.
  • String digit substitution is set to StringDigitSubstituteUser.
  • Hot key prefix is set to HotkeyPrefixNone.
  • Number of tab stops is set to zero.
  • String trimming is set to StringTrimmingNone.

Examples

The following example creates a generic, typographic StringFormat object and then uses it to draw a formatted string. The code also draws the string's layout rectangle.

VOID Example_GenericTypographic(HDC hdc)
{
   Graphics graphics(hdc);
   SolidBrush  solidBrush(Color(255, 255, 0, 0)); 
   FontFamily  fontFamily(L"Times New Roman");
   Font        font(&fontFamily, 12, FontStyleRegular, UnitPoint);
   
   // Create a generic typographic StringFormat object.
   const StringFormat* pStringFormat = StringFormat::GenericTypographic();
   // Use the generic typographic StringFormat object 
   // in a call to DrawString.
  graphics.DrawString(
      L"Formatted by a generic typographic StringFormat object", 
      54,  // string length
      &font, 
      RectF(30, 30, 100, 120), 
      pStringFormat, 
      &solidBrush);
   // Draw the rectangle that encloses the text.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawRectangle(&pen, 30, 30, 100, 120);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusstringformat.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Font

HotkeyPrefix

LOGFONT

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming