Reputation: 141
I'm making a datagrid like control with lots of rows and columns. the problem was loading time that was solved with using glyphs instead of textblock.
now the problem is when I give it a font from applications pack it slows down and remains in memory and each time control reloads it gets slower and consumes much more memory:
Glyphs glyph = new Glyphs()
{
FlowDirection = FlowDirection.LeftToRight,
UnicodeString = "text",
FontUri = fnt,
FontRenderingEmSize = 15,
Fill = Brushes.Black,
HorizontalAlignment = HorizontalAlignment.Center
};
now what causing problem is :
Uri fnt = new Uri("pack://application:,,,/myapp;component/Fonts/times.ttf");
everything is okay if I do this:
Uri fnt = new Uri(@"C:\Windows\Fonts\times.ttf");
but I'm going to use a font that does not exist on other systems and it needs to be with my app.
Upvotes: 2
Views: 758
Reputation: 116
This is actually the same problem as here https://stackoverflow.com/a/31452979 and it's not going to be fixed anytime soon as 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.
As both these cases are caused by UnmanagedMemoryStreams for now you can only make temporary folder and save font into it. It is not pretty but is all what we have.
Upvotes: 1