Kuczi
Kuczi

Reputation: 387

Is it possible to change TextOptions of FormattedText in c# using WPF?

I want to draw a FormattedText with different rendering options. When we create for example a Label we can set its TextOptions.TextFormattingMode(Ideal/Display) and TextOptions.TextHintingMode(Auto/AntiAliasing/ClearType/Grey Scale).

I want to set hinting mode and formatting mode on my FormattedText. I think TextFormattingMode can be passed as a constructor argument but what about TextHintingMode? Is it possible to set it?

Upvotes: 3

Views: 316

Answers (2)

Sam L.
Sam L.

Reputation: 227

Both TextRenderingMode, TextHintingMode, TextFormatingMode (and many more) can be set in code, just like that:

TextOptions.SetTextHintingMode(myControl, TextHintingMode.Fixed);

I use it after creating the control, before adding it to the visual tree, works just fine. I don't know if setting this value for a control already in the visual tree is enough to invalidate the visual (and force a redraw).

Upvotes: 0

Eli Arbel
Eli Arbel

Reputation: 22749

Both TextRenderingMode and TextHintingMode can only be set at the Visual level. So no, you won't be able to apply it to a specific FormattedText, only the entire control it's rendered in.

Upvotes: 2

Related Questions