Font being overridden

2.7k Views Asked by At

I'm currently fighting with an issue of styling. I am creating a PDF using IronPDF and generating the new PDF from HTML.

I have an instance where my fonts are being overridden. The style is the following:

.bbBlankPage {
    font-size: 20px; /*14 pt*/
    text-align: center;
    font-family: Arial !important;
    font-weight: bold;
    padding-top: 55%;
    text-indent: 40px;
}

When the HTML is generated and spit out into the PDF, the PDF shows the font as ArialBold. This is causing an issue with the font looking smaller and scrunched up in comparison to the original. I'm trying to overcompensate by enlarging the font size but the change in font family has me stumped. If I remove font-weight, it becomes ArialRegular, which isn't right either. I just want normal Arial font.

2

There are 2 best solutions below

6
On

I work for IronSoftware as a support engineer.

Try using a local font by importing it from a folder instead of using the system font installed on the system. This isn't perfect though gives a better result.

Code example below references Arial:

<style type="text/css">
@font-face {
font-family: 'Arial';
src: url('./Arial.eot');
src: local('Arial'), url('./Arial.woff') format('woff'), url('./Arial.ttf') format('truetype');
}
.fontsforweb_fontid_1080 {
font-family: 'Arial' !important;
}
</style>

This issue will be resolved with a new rendering engine we are building for release in the first half of 2021.

1
On

Kerning is working for me well after the 2021.9 update of IronPDF

I propose the solution. is to download IronPdf 2021.9.3737 or greater from nuget and use the new IronPdf.ChromePdfRenderer Class which is functionally identical to desktop Chrome browser in 2021.

This fixed all of our rendering issues with HTML to PDF in C#, including kerning of the Arial typeface.

PM> Install-Package IronPdf -Version 2021.9.3737