[英]Avalonia: fails to draw text to DrawingContext
I am developping a project using Avalonia.我正在使用 Avalonia 开发一个项目。 I used as a workingBase for a graphical editor the following project which allaws to draw lines and rectangles: https://github.com/wieslawsoltes/LineEditor
我将以下项目用作图形编辑器的工作基础,该项目允许绘制线条和矩形: https://github.com/wieslawsoltes/LineEditor
I am trying to write text in the Avalonia.Media.DrawingContext but i have a NullRefereceException on calling DrawingContext.DrawText (in debbuger, formattedText._platformImpl is null)我正在尝试在 Avalonia.Media.DrawingContext 中编写文本,但在调用 DrawingContext.DrawText 时出现 NullRefereceException(在调试器中,formattedText._platformImpl 为空)
public void DrawText(DrawingContext dc, TextShape textShape)
{
var brush = new SolidColorBrush(ToColor(textShape.Stroke));
var point1 = new Point(textShape.TopLeft.X, textShape.TopLeft.Y);
var typeface = new Typeface("Arial");
var formattedText = new FormattedText("Hello", typeface, 12, TextAlignment.Left, TextWrapping.NoWrap, Size.Infinity);
dc.DrawText(brush, point1, formattedText );
}
Did you update the AvaloniaUI NuGet to the last version?您是否将 AvaloniaUI NuGet 更新到最新版本? the version is old in this archived repo.
此存档回购中的版本是旧的。
A quick search in a more recent example https://github.com/wieslawsoltes/Core2D and you can find DrawText occurences在最近的示例https://github.com/wieslawsoltes/Core2D中快速搜索,您可以找到 DrawText 出现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.