0
在自定義Shape
與PathGeometry
爲DefiningGeometry
我希望PathGeometry
顯示文本。如何從文本中獲取PathGeometry(未列出/格式化)
我試過FormattedText,但這看起來像藝術文本(如三維字形)。我沒有意識到,可能是語言障礙。
我想創建看起來像純文本格式文本PathGeometry
,但仍與字體,字體大小,懷特等
我怎麼能這樣做?我可以給BuildGeometry
一個參數嗎? 我嘗試這樣做:
PathGeometry geometry = new PathGeometry();
FormattedText formattedText = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Tahoma"), 12, Brushes.Black);
var geometrygroup = formattedText.BuildGeometry(new Point())as GeometryGroup;
if (geometrygroup != null)
{
foreach (var child in geometrygroup.Children)
{
var line = child as GeometryGroup;
if (line != null)
{
foreach (var glyph in line.Children)
{
var path = glyph as PathGeometry;
if (path != null)
{
geometry.AddGeometry(path);
}
}
}
}
}
geometry.Transform = new TranslateTransform(20, 80);
我希望生活總是那麼容易。 – Gerard