Click here to Skip to main content
15,305,625 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use C# WPF and Stimulsoft

I want to send path my font file was embedded to my report when need to show

I have embedded font in my WPF Project and I use it like this :

in XAML :
<Label x:Name="preloader" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Loading . . ." Margin="319,178,48,34" FontFamily="/WpfApp5;component/FNT/#B Titr" FontSize="48" Background="White"/>

The font was embed from font's folder in my project :[^]

for my report was generated in stimulsoft I cannot embed font but I can send it a path of my font

by this I can send it my font path :[^]

for that I tried two way

What I have tried:

C# Code :

1- :
StiFontCollection.AddFontFile(@"pack://application:,,,/FNT/#B Titr");

this case will show this error :
System.NotSupportedException: 'The given path's format is not supported.'

2- :
var fntpath = Assembly.GetEntryAssembly().GetManifestResourceStream("WpfApp5.FNT.BTITRBD.TTF");

and in this fntpath.ToString() is null !

How to Add Font File to Stimulsoft report from embedded font in C# WPF - Stack Overflow[^]
Updated 13-Sep-21 0:03am
Richard Deeming 13-Sep-21 5:53am
If you want to ask a question, then ask a question. Don't just dump a link to your question on another site.

Click the green "Improve question" link and update your question to include a full and complete description of the problem, the relevant parts of your code, and the full details of any errors. Tell us what you have tried, and where you are stuck.

1 solution

The AddFontFile method expects the path of a physical file on disk. You cannot pass in a pack: URI, because it doesn't understand that format. And you cannot just call .ToString() on a Stream, since that won't produce any meaningful information.

You need to extract your font file to a temporary file, and pass the path to that file to the AddFontFile method.
string tempPath = Path.GetTempPath();
string fileName = "WpfApp5.FNT.BTITRBD.TTF";
string fontPath = Path.Combine(tempPath, fileName);
if (!File.Exists(fontPath))
    using (var stream = Assembly.GetEntryAssembly().GetManifestResourceStream(fileName))
    using (var output = File.Create(fontPath))


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900