Font not working for CharacterFormat.Bold = true

Hi,

for the font DIN Pro Condensed the bold weight is not working, when you set a paragraph in a Word document and then use this document to generate a PDF. The difference seems to be that Word lists it as DIN Pro Cond (see Screenshot) while GemBox requires DIN Pro Condensed (see code). It might be that the definition of the font is the problem here. Yet it is working in Word and the difference in behaviour is problematic for us.

The font:

    ComponentInfo.SetLicense("FREE-LIMITED-KEY");

    FontSettings.FontsBaseDirectory = "MyFonts";
    
    // Add a paragraph in DIN Pro Cond to doc1, it will not be printed in the correct font
    var document = DocumentModel.Load("doc1.docx");
    
    var paragraph = new Paragraph(document);
    var run = new Run(document, "ABC abc XYZ xyz Regular DIN Pro, correct font.");
    run.CharacterFormat.FontName = "DIN Pro Cond";
    run.CharacterFormat.Bold = false;
    paragraph.Inlines.Add(run);
    document.Sections.First().Blocks.Add(paragraph);
    
    var paragraph2 = new Paragraph(document);
    var run2 = new Run(document, "ABC abc XYZ xyz DIN Pro Condensed bold, this one works.");
    run2.CharacterFormat.FontName = "DIN Pro Condensed";
    run2.CharacterFormat.Bold = true;
    paragraph2.Inlines.Add(run2);
    document.Sections.First().Blocks.Add(paragraph2);
    
    var paragraph3 = new Paragraph(document);
    var run3 = new Run(document, "ABC abc XYZ xyz DIN Pro Cond bold, this one fails. This is the name used in Word.");
    run3.CharacterFormat.FontName = "DIN Pro Cond";
    run3.CharacterFormat.Bold = true;
    paragraph3.Inlines.Add(run3);
    document.Sections.First().Blocks.Add(paragraph3);


    document.Save("Private Fonts.pdf");

Hi,

Actually, MS Word lists the following fonts:

As you can see, the “DIN Pro Cond Bold” is separate from the “DIN Pro Cond” in the list.

Paragraphs of the document in the screenshot are set to the following fonts:

  • DIN Pro Cond
  • DIN Pro Cond (with Bold button selected)
  • DIN Pro Cond Bold

As you can see, there is an obvious difference between the second and the third paragraph. In the second paragraph, MS Word uses the “DIN Pro Cond” font (dinpro_condensedregular.otf) and it simulates the bold. In the third paragraph it uses the “DIN Pro Cond Bold” (dinpro_condensedbold.otf).
So the correct way to use the dinpro_condensedbold.otf font file in both MS Word and GemBox.Document would be to specify the font name as “DIN Pro Cond Bold”.

Add the following to your code snippet:

var paragraph4 = new Paragraph(document);
var run4 = new Run(document, "ABC abc XYZ xyz DIN Pro Cond Bold.");
run4.CharacterFormat.FontName = "DIN Pro Cond Bold";
//run4.CharacterFormat.Bold = true;
paragraph4.Inlines.Add(run4);
document.Sections.First().Blocks.Add(paragraph4);

and you will again see the same difference between the third and the fourth paragraph when saving the document to the DOCX file and viewing it in MS Word.

Regards,
Stipo