Reputation: 7454
I am rendering the FormattedText with different foreground color to different character(fore example first two red, next 2 yellow like..), now i have to display outline surrounded to this text. For apply outline(stroke) i have to convert this FormattedText into geometry and then draw geometry like
Geometry textGeometry = FormattedText.BuildGeometry(new Point(_xOffset, _yOffset)); drawingContext.DrawGeometry(null, new Pen(new SolidColorBrush(OutlineColor), storkeWidth),textGeometry);
but the problem is that it will render the FormattedText in red color and lost my formatting color. am I missing something or there is another way to outline the text.
Upvotes: 3
Views: 2619
Reputation: 7454
I think i found the solution. first draw the formatted text and then the geometry, it will display the text as well as outline.
Geometry textGeometry = FormattedText.BuildGeometry(new Point(_xOffset, _yOffset));
drawingContext.DrawText(FormattedText,new Point(0,0));
drawingContext.DrawGeometry(null, new Pen(new SolidColorBrush(OutlineColor), storkeWidth),textGeometry);
If some has better approach please let me know.
Upvotes: 8