Page 1 of 1

How to load bold Italic font

Posted: Tue Jan 21, 2025 2:50 am
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 6052 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.

Re: How to load bold Italic font

Posted: Wed Jan 22, 2025 8:52 am
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.

Re: How to load bold Italic font

Posted: Wed Jan 22, 2025 11:32 pm
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.

Re: How to load bold Italic font

Posted: Thu Jan 23, 2025 8:01 am
by Lech Kulikowski
Hello,

You are welcome.