题
我渲染FormattedText具有不同前景色为不同的字符(例如前前两个红色,接下来的2黄色等。),现在我有显示轮廓围绕该文本。对于应用轮廓(中风)1具有与本FormattedText转换成几何形状,然后绘制几何等
几何textGeometry = FormattedText.BuildGeometry(新点(_xOffset,_yOffset)); drawingContext.DrawGeometry(空,新的笔(新的SolidColorBrush(OutlineColor),storkeWidth),textGeometry);
但问题是,它将使FormattedText以红色和失去了我的格式的颜色。 我思念的东西或者有另一种方式来勾勒出文字。
解决方案
我想我找到了解决办法。 第一绘制格式化的文本,然后几何形状,它将显示在文本以及轮廓。
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);
如果有一些更好的方法,请让我知道。
不隶属于 StackOverflow