How to Add Font File to Stimulsoft report from embedded font in C# WPF

Mojtaba_Hakim 321 Reputation points
2021-09-11T06:30:47.427+00:00

I use C# WPF and Stimulsoft

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

Please Check out this link to help me

thanks all

more detail : how-to-add-font-file-to-stimulsoft-report-from-embedded-font-in-c-sharp-wpf

Developer technologies | Windows Presentation Foundation
Developer technologies | XAML
Developer technologies | C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. P a u l 10,761 Reputation points
    2021-09-11T14:24:49.707+00:00

    Is your issue not that you're using the "font name" rather than the "file name" here?:

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

    If you try this does it work?

    StiFontCollection.AddFontFile(@"pack://application:,,,/FNT/BTITRBD.TTF");
    

    If BTITRBD.TTF has it's Build Action set to "Resource" and not "Embedded Resource" I'd expect this to work.

    Just for your info GetManifestResourceStream is used to get Embedded Resources by their resource name. That method returns a stream to the Embedded Resource's data that you can read from.

    1 person found this answer helpful.

  2. Hui Liu-MSFT 48,681 Reputation points Microsoft External Staff
    2021-09-13T09:19:57.86+00:00

    As Paul-5034 said, you could set Build Action property of BTITRBD.TTF to Resource. And you can try the following code if it is useful to you. You could also try to refer here.
    131591-3.png
    The code of xaml:

    <StackPanel Name="sp">  
            <TextBlock Text="Loading..." FontSize="30" />  
            <TextBlock Text="Loading..." FontSize="30" FontFamily="./FNT/#Al Qalam Quran Majeed Web Regular"/>  
            <TextBlock Text="Loading..." FontSize="30" FontFamily="./FNT/#Amiri Regular"/>  
    
            <TextBlock Name="tb" Text="Loading...." FontSize="30"/>  
    </StackPanel>  
    

    The code of xaml.cs:

    public partial class MainWindow : Window  
      {  
        public MainWindow()  
        {  
          InitializeComponent();  
          tb.FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./FNT/#Amiri Regular");  
        }  
      }  
    

    The picture of result:
    131510-1.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.