C ++ Gdiplus :: Change font size and font family

Check out 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 the font size and family using the same variable "f" (actually I use a pointer to f). Is it possible?

+3
source share
1 answer

No, you need to move a new instance of the Font class to change the style.

+2
source

Source: https://habr.com/ru/post/1772271/


All Articles