Odd Behavior with Lucida Sans font

Hi,

I have noticed strange behavior with Lucida Sans fonts specifically. This only happens on a machine that has font ‘Lucida Sans’ installed with the font faces ‘Italic’, ‘Demibold Roman’ and ‘Demibold Italic’. When on a machine like this the following code is run:

var doc = new Document();
var builder = new DocumentBuilder(doc);
builder.ParagraphFormat.Style.Font.Name = "Lucida Sans";
builder.Writeln("I am a paragraph in Lucida Sans font");
doc.Save("out.pdf");
doc.Save("out.docx");

the pdf version seems to pick the ‘Italic’ font face, and docx version picks the ‘Demibold Roman’ font face. This is quite suprising, as I would think the same font will be selected for both output formats, and that is what happened a couple .Words versions ago (22.8) where both were using ‘Demibold Roman’. Could you let me know whether this is expected?

Thanks

@acturisaspose Could you please also attach your output documents and fonts used on your side. I have tested on my side and both documents uses Lucida Sans:
out.docx (7.1 KB)
out.pdf (9.4 KB)

If the font specified in the document is not available both Aspose.Words and MS Word substitutes the missed font.

Hi Alexey,

Attaching the Word document and the pdf I got from running the code, and the pdf I got from saving the docx to pdf with Word 2016.

As for the fonts themselves, unfortunately the security staff at my company advised me against sending them due to copyright limitations around distributing the font, but if it’s any help, the exact list of font files relating to Lucida fonts in my Windows/Fonts folder is :
Lucon.ttf
L_10646.ttf
LSANSD.TTF
LSANSDI.TTF
LSANSI.TTF

It would seem like due to there not being a plain ‘Lucida Sans’ font variant without any subtype and only the Italic, Demibold, and Demibold Italic variants, when saving to pdf/docx substitutes are picked for both formats, but docx seems to prefer Demibold, and pdf chooses Italic instead.

out.docx (7.1 KB)

out_ConvertedWithWord2016.pdf (14.3 KB)

out.pdf (9.4 KB)

@acturisaspose Unfortunately, without the fonts I cannot test the scenario on my side. On my side I have the following fonts under Lucida Sans family:
LSANSDI.TTF
LSANSD.TTF
LSANSI.TTF
LSANS.TTF

Hi Alexey,

just an idea - the font

sounds like the basic Lucida Sans font face. Could you please try removing it from your machine for a moment and running the code then? This should hopefully cause the same font substitution and difference in docx/pdf I’m seeing on my side.

Thanks

@acturisaspose This is an expected behavior that if the font specified in the document is not available the font is substituted. Rendering to PDF without fonts is impossible. The fonts are required to get text metrics for building document layout.

Without basic Lucida Sans font, PDF document is rendered as the following: