Mike Pliam
September 20th, 2008, 03:46 PM
GDI+ provides for the output of vertical text, as shown by the following code. (CChart is an MFC class derived from CStatic)
void CChart::DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
{
Graphics graphics(hdc);
// Initialize arguments.
FontFamily fontFamily(L"Arial");
Font myFont(&fontFamily, 18, FontStyleBold, UnitPixel);
StringFormat format;
format.SetFormatFlags(StringFormatFlagsDirectionVertical|StringFormatFlagsDirectionRightToLeft);
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(string, 11, &myFont, layoutRect, &format, &blackBrush);
// Draw layoutRect.
//graphics.DrawRectangle(&Pen(Color::Black, 3), layoutRect);
}// DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
Now, while this code works, the vertical text is always written from top to bottom (unable to render here). I would prefer the vertical text to be rendered from bottom to top, that is, what is conventionally left to right reading becomes bottom to top. IMHO, it just looks better.
The format flags I have tried here have no effect. Does anyone know how to render vertical text to read bottom to top using GDI+ ?
:wave:
void CChart::DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
{
Graphics graphics(hdc);
// Initialize arguments.
FontFamily fontFamily(L"Arial");
Font myFont(&fontFamily, 18, FontStyleBold, UnitPixel);
StringFormat format;
format.SetFormatFlags(StringFormatFlagsDirectionVertical|StringFormatFlagsDirectionRightToLeft);
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Draw string.
graphics.DrawString(string, 11, &myFont, layoutRect, &format, &blackBrush);
// Draw layoutRect.
//graphics.DrawRectangle(&Pen(Color::Black, 3), layoutRect);
}// DrawVLabel(WCHAR * string, RectF layoutRect, HDC hdc)
Now, while this code works, the vertical text is always written from top to bottom (unable to render here). I would prefer the vertical text to be rendered from bottom to top, that is, what is conventionally left to right reading becomes bottom to top. IMHO, it just looks better.
The format flags I have tried here have no effect. Does anyone know how to render vertical text to read bottom to top using GDI+ ?
:wave: