PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problems with font names containing spaces
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3765
Page 1 of 1

Author:  mabian [ Mon Apr 16, 2018 8:37 am ]
Post subject:  Problems with font names containing spaces

Hello,

new PDFSharp user here, very powerful tool but struggling with a problem on font names.

When trying to embed Times New Roman, the font name referenced in the PDF is somehow transformed in "Times#20New#20Roman" and Adobe applications complain about not being able to find the font when loading the PDF (tried on Illustrator and InDesign).

Is it something known (possibly some glaring oversight since I cannot believe this is not happening to somebody else)?

Using Windows (10) with Adobe CC applications and PDFSharp 1.50.4845-RC2a.

Thank you very much in advance.

Best regards,
Mario

Author:  Thomas Hoevel [ Mon Apr 16, 2018 10:03 am ]
Post subject:  Re: Problems with font names containing spaces

Hi!

I'd expect the font name in the PDF to start with "TimesNewRoman".

Nothing we will do without an MCVE aka IssueSubmissionTemplate.
viewtopic.php?f=2&t=832

Author:  mabian [ Mon Apr 16, 2018 10:11 am ]
Post subject:  Re: Problems with font names containing spaces

Hello, thanks for the prompt reply.

I opened the PDF file with a text editor and I see a lot of those:

/BaseFont/QDAHJM+Times#20New#20Roman
/FontName/QDAHJM+Times#20New#20Roman

We tried with a different library, same system, same fonts, and there's no problem with the resulting PDF.

Thanks!

- Mario

Author:  mabian [ Mon Apr 16, 2018 10:22 am ]
Post subject:  Re: Problems with font names containing spaces

(Zipped) PDF file attached, preparing a stripped down example in Visual Studio that exhibits the issue.

- Mario

Attachments:
C22D2D77-7CD7-4920-9970-0CFCEDB2DE6C_tempfile.zip [91.53 KiB]
Downloaded 35 times

Author:  mabian [ Mon Apr 16, 2018 10:49 am ]
Post subject:  Re: Problems with font names containing spaces

Also attached an MCVE, Visual Studio solution.

Thanks,
Mario

Attachments:
SVGtoPDFPoC.zip [158.01 KiB]
Downloaded 37 times

Author:  TH-Soft [ Mon Apr 16, 2018 9:12 pm ]
Post subject:  Re: Problems with font names containing spaces

Hi!

I thought I knew PDFsharp, but turns out I do not.

Until PDFsharp 1.50 beta 2 there were no spaces.
With PDFsharp 1.50 beta 3 and later there are spaces.

In the PDF Reference I found no information whether spaces are allowed or forbidden.
Adobe Reader does not complain. And the spaces "#20" persist when I use "Save as" in Adobe Reader DC, so it looks as if spaces are OK for PDF - just not OK for older Adobe tools it seems.

A PDF created from Word shows "TimesNewRoman" without spaces.

I'll investigate this a bit further, but not tonight.
It could be better to use fontnames without spaces like early versions did.

Author:  mabian [ Mon Apr 23, 2018 7:04 am ]
Post subject:  Re: Problems with font names containing spaces

Hello, we went into more details and our investigations so far uncovered a couple of connected issues:

1) Postscript name is not fetched correctly.
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
It seems that in the RC2a library version a different name is used (often containing spaces, while all proper postscript names I saw never included spaces).
Times New Roman is a good example that shows the problem.

2) In these fonts in which the name used by PDFSharp includes spaces, every space is replaced by a "#20" escape sequence; while I guess that this is good for many other cases, it seems that an "escaped" font name in the above-mentioned PDF directives cause issues in many applications, among which Adobe ones, that don't deal properly with them (probably they are out of specs).

I hope the above points can be taken care soon because they make the current version quite unusable.

Best regards,
Mario

Author:  Thomas Hoevel [ Mon Apr 23, 2018 9:58 am ]
Post subject:  Re: Problems with font names containing spaces

mabian wrote:
I hope the above points can be taken care soon because they make the current version quite unusable.
The "#20" is there since December 2015 (and not just since RC2) and you are the first to complain about it. If it was "quite unusable" then we should have heard many complaints so far.

mabian wrote:
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
What are the specs? How should spaces be treated?

Author:  mabian [ Mon Apr 23, 2018 10:49 am ]
Post subject:  Re: Problems with font names containing spaces

Thomas Hoevel wrote:
mabian wrote:
I hope the above points can be taken care soon because they make the current version quite unusable.
The "#20" is there since December 2015 (and not just since RC2) and you are the first to complain about it. If it was "quite unusable" then we should have heard many complaints so far.


Probably only a few people use fonts which name, as processed by PDFSharp, has spaces in it.
Or people don't get annoyed by having to deal with a "font remap" window each time the pdf is opened in an application like Illustrator.
Or they don't use fonts of the type that triggers the troublesome case.

In the process we are developing, hundreds of PDF files are produced automatically and then worked in Illustrator, this loading delay can be significant.
So, maybe not unusable but for sure a bit annoying - at least in the context I described.

Thomas Hoevel wrote:
mabian wrote:
If I understand well the specs, the /FontName and /BaseFont directives expect the postscript name of the font.
What are the specs? How should spaces be treated?

I took a look at the PDF 1.7 specs (see attachment) and there's no explicit mention of forbidden spaces.
But I never saw a name with spaces in all PDFs I inspected, other than the ones produced with PDFSharp.
The specs are quite clear in describing how to get the correct name to put in the BaseFont and FontName statements, though they don't explicitly mention escaping rules.

I'm surprised like you that nobody else reported this issue.
For the moment being, the quickest solution for us was reverting to an earlier version, of course with the risk of getting some bugs and losing enhancements that were introduced in later versions..

Thanks,
Mario

Attachments:
Postscript.png
Postscript.png [ 117.8 KiB | Viewed 725 times ]

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/