gpt4 book ai didi

c# - WPF Glyphs 控制字体 uri!(它很慢并且保留在内存中)

转载 作者:太空宇宙 更新时间:2023-11-03 12:40:30 24 4
gpt4 key购买 nike

我正在制作一个类似数据网格的控件,其中包含很多行和列。问题是使用字形而不是文本 block 解决了加载时间问题。

现在的问题是,当我从应用程序包中给它一个字体时,它会变慢并保留在内存中,并且每次重新加载控件时它都会变慢并消耗更多的内存:

        Glyphs glyph = new Glyphs()
{
FlowDirection = FlowDirection.LeftToRight,
UnicodeString = "text",
FontUri = fnt,
FontRenderingEmSize = 15,
Fill = Brushes.Black,
HorizontalAlignment = HorizontalAlignment.Center
};

现在导致问题的原因是:

 Uri fnt = new Uri("pack://application:,,,/myapp;component/Fonts/times.ttf");

如果我这样做,一切都很好:

 Uri fnt = new Uri(@"C:\Windows\Fonts\times.ttf");

但我将使用其他系统上不存在的字体,它需要与我的应用程序一起使用。

最佳答案

这其实和这里的问题是一样的https://stackoverflow.com/a/31452979而且它不会很快被修复 following answer was made on 2013.10.01 :

The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.–WPF Team.

由于这两种情况都是由 UnmanagedMemoryStreams 引起的,目前您只能制作临时文件夹并将字体保存到其中。它并不漂亮,但却是我们所拥有的。

关于c# - WPF Glyphs 控制字体 uri!(它很慢并且保留在内存中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39157846/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com