Using italic or bold fonts

Jul 15, 2013 at 1:06 PM
Hi, congratulations again, this .dll is wonderful.

I was wondering on how to use italic or bold variations of fonts.

Let's say that i'd like to draw a string with Verdana Italic font, what should i do to do that?

thanks!
Coordinator
Jul 15, 2013 at 1:21 PM
Thanks!

To do that, create a DirectWrite text-layout and draw it with DrawTextLayout. See the TextLayouts sample for an example. You can replace DWRITE_FONT_STYLE_NORMAL with DWRITE_FONT_STYLE_ITALIC, and use DWRITE_FONT_WEIGHT_BOLD for the weight, with CreateTextFormat.
It can also be overridden in a created text-layout with IDWriteTextLayout::SetFontWeight / SetFontStyle, which can be used to make only part of a string italic / bold.

You can also use those flags in a FW1_FONTWRAPPERCREATEPARAMS structure when creating the font-wrapper object, if you want default text to be italic. See the Transforms sample for how to use that structure. It's probably not that useful though since it would make all DrawString texts be italic..


It would good feature to have easier available... I'll add a flag for it if I make another update, but for now a text-layout has to be created.

/Erik
Jul 16, 2013 at 6:25 AM
Thanks again Erik,
I'll try this afternoon!