views:

25

answers:

1

Look this code

Gdiplus::Graphics g(hDC);
Gdiplus::Font *f = new Font(L"Times new roman", 16);
Gdiplus::SolidBrush b(Gdiplus::Color(255,0,0,0));

g.DrawString(L"Hello", 5, f, &Gdiplus::StringFormat(), &b);

// Now i want to change font styles
// using f->setSize() or f->setFontFamily().

g.DrawString(L"Hello", 5, f, &Gdiplus::StringFormat(), &b);

I want to change font size and family using the same "f" variable (actually i'm using a pointer to f). Is it possible?

+1  A: 

Nope, you have to ceate a new instance of the Font class to alter the style.

Hans Passant
I don't know what "doesn't work" means. I can only guess that you don't use the Font() constructor overload that lets you set the style.
Hans Passant