How to load bold Italic font

Stimulsoft Reports.JS discussion
Post Reply
nirav.blitzm
Posts: 6
Joined: Sun Jan 19, 2025 9:45 pm

How to load bold Italic font

Post by nirav.blitzm »

Hi,

I am trying to load Open Sans (https://fonts.google.com/specimen/Open+Sans) fonts file into the report designer (React web app). Below my code

Code: Select all


import regularFont from '../../static/fonts/OpenSans-Regular.ttf';
import boldFont from '../../static/fonts/OpenSans-Bold.ttf';
import italicFont from '../../static/fonts/OpenSans-Italic.ttf';
import boldItalicFont from '../../static/fonts/OpenSans-BoldItalic.ttf';


        const options = new Stimulsoft.Designer.StiDesignerOptions();
        options.viewerOptions.exports.showExportToJson = true;
        options.viewerOptions.email.showEmailDialog = false;
        options.viewerOptions.toolbar.showBookmarksButton = false;
        options.viewerOptions.toolbar.showSendEmailButton = false;
        options.appearance.showSystemFonts = false;
        options.toolbar.showFileMenu = false;
        
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
  regularFont,
  'Open Sans',
  Stimulsoft.System.Drawing.FontStyle.Regular,
);
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
  boldFont,
  'Open Sans',
  Stimulsoft.System.Drawing.FontStyle.Bold,
);
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
  italicFont,
  'Open Sans',
  Stimulsoft.System.Drawing.FontStyle.Italic,
);

// Below code in question
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
  boldItalicFont,
  'Open San',
  Stimulsoft.System.Drawing.FontStyle.Italic,
);
My question here is how do I load font type Bold + Italic? There is no 'Stimulsoft.System.Drawing.FontStyle' enum option for loading font of type BoldItalic as highlighted in image.
Screenshot 2025-01-21 at 1.43.05 pm.png
Screenshot 2025-01-21 at 1.43.05 pm.png (376.42 KiB) Viewed 714 times
Furthermore I tried loading only Regular, Bold & Italic fonts only but I am unable to format text in Bold & Italic style. When viewing the preview text will be rendered with regular style instead of bold + regular.

Cheers.
Attachments
report_2025-01-21T02_49_09.385Z.mrt
(1.24 KiB) Downloaded 20 times
Lech Kulikowski
Posts: 7019
Joined: Tue Mar 20, 2018 5:34 am

Re: How to load bold Italic font

Post by Lech Kulikowski »

Hello,

Please try to use the following code:
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
italicFont,
'Open Sans',
Stimulsoft.System.Drawing.FontStyle.Italic | Stimulsoft.System.Drawing.FontStyle.Bold
);

Thank you.
nirav.blitzm
Posts: 6
Joined: Sun Jan 19, 2025 9:45 pm

Re: How to load bold Italic font

Post by nirav.blitzm »

Lech Kulikowski wrote: Wed Jan 22, 2025 8:52 am Hello,

Please try to use the following code:
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile(
italicFont,
'Open Sans',
Stimulsoft.System.Drawing.FontStyle.Italic | Stimulsoft.System.Drawing.FontStyle.Bold
);

Thank you.
Thank you.

Code: Select all

Stimulsoft.System.Drawing.FontStyle.Italic | Stimulsoft.System.Drawing.FontStyle.Bold
fixed the issue.
Lech Kulikowski
Posts: 7019
Joined: Tue Mar 20, 2018 5:34 am

Re: How to load bold Italic font

Post by Lech Kulikowski »

Hello,

You are welcome.
Post Reply