We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can i set external font in drawstring method?

Hello Team,

We want to set “Proxima-Nova” font in drawstring method of Graphics class. How can we do that? For you reference, we want to set Proxima-Nove instead of Times New Roman. We are using Aspose.Imaging version 21.4.0. Please suggest.

RectangleF titleRect = new RectangleF(24, 90, 600, 68);
graphics.DrawString(item.Title, new Font(“Times New Roman”, 20, FontStyle.Bold, GraphicsUnit.Pixel), new SolidBrush(Color.FromArgb(0, 0, 0)), titleRect, new StringFormat());

@siriussynoptek

In the code sample that you have shared, you need to set the font "Proxima-Nova” instance. You need to install the font on your end too.

Thank you for given solution.

We are using azure web app and there is no facility available to install the fonts. Kindly suggest how can we achieve this using font file or live font URL. We have tried below code snippet but didn’t get font effect. Here, Proxima-Nova-Reg.ttf file is stored at “E:\Publish_Web_Internal_API\wwwroot\HTML Templates\Base Template\fonts” location.

FontSettings.SetFontsFolder(“E:\Publish_Web_Internal_API\wwwroot\HTML Templates\Base Template\fonts”);
FontSettings.UpdateFonts();
RectangleF titleRect = new RectangleF(24, 90, 600, 68);
graphics.DrawString(“This is Proxima-Nova font.”, new Font(“Proxima-Nova-Reg”, 20, FontStyle.Bold, GraphicsUnit.Pixel), new SolidBrush(Color.FromArgb(0, 0, 0)), titleRect, new StringFormat());

@siriussynoptek

Can you please possibly try the font mechanisms used in following documentation article. It refers to a font file that is not installed but is available somewhere on disk and that is referred.