PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

PdfSharpException: Error on parsing OpenType font (chinese)
http://forum.pdfsharp.com/viewtopic.php?f=2&t=3850
Page 1 of 1

Author:  erftruner [ Thu Sep 27, 2018 11:44 am ]
Post subject:  PdfSharpException: Error on parsing OpenType font (chinese)

Hello,

I am using PdfSharp to generate PDFs with a chinese font doing something like the following:

Code:
Style style = doc.Styles["Normal"];
style.Font.Name = "Microsoft JhengHei"; 


This works perfectly on a Windows7 PC in german. A chinese co worker has a Win10 chinese OS.
He gets the above mentioned message "error while parsing an OpenType font".

According to control->fonts the font is installed on both PCs. Any ideas?

Thanks in advance
Peter

Author:  Thomas Hoevel [ Thu Sep 27, 2018 2:28 pm ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

Hi!

I get the error message "TrueType collection fonts are not yet supported by PDFsharp."

So the workaround is clear: use "normal" fonts, no font collections.

Author:  erftruner [ Fri Sep 28, 2018 9:05 am ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

Thomas Hoevel wrote:
Hi!

So the workaround is clear: use "normal" fonts, no font collections.


Hello,

I am not a font expert, I "inherited" the code. I now see that "Microsoft JhengHei" is a font family that consists of "Microsoft JhengHei Standard" and "Microsoft JhengHei Fett" (Win7) and an additional font in Win10, at least in the german version.
Trying to use "Microsoft JhengHei Standard" was not effective:

Code:
           
Style style = doc.Styles["Normal"];
style.Font.Name = "Microsoft JhengHei Standard"


The outcome is a PDF with lots of squares in it :( . It there a way to use this font inside a font familiy with a "trick" or do I have to use a complete other font?
Is there a special notation to use a font inside a font family?

("Arial" seems to work although it is aslo a font family. :-/)

Grüße aus Köln
Peter

Author:  TH-Soft [ Fri Sep 28, 2018 9:46 am ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

Hi!
erftruner wrote:
("Arial" seems to work although it is aslo a font family. :-/)
On my computer, Arial has the extension TTF (works with PDFsharp), not the collection extension TTC that does not (yet) work with PDFsharp.
Font families work, font collections do not.

Look for *.TTF in the fonts folder or on the Internet.

Somebody told us on the font that they modified PDFsharp to support font collections and promised to provide us with that code - but that was months ago and so far they did not.

Supporting font collection seems to be a rather simple modification. Feel free to tackle that task and provide your changes to the community.
Most likely TTC is just a wrapper for several TTF files.

Author:  marksu22 [ Fri Sep 28, 2018 9:56 pm ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

Hi,

Is it confirmed that we can generate PDF with contents in Chinese?

I only got squares at Chinese characters.

Some attempts as follow:
1. No change to style of document. No exception. Got squares.
2. Specify font name to "Microsoft JhengHei UI Bold". No exception. Got squares.
3. Specify font name to "Microsoft JhengHei UI". Got exception.
[IndexOutOfRangeException]
PdfSharp.Fonts.OpenType.OpenTypeFontface.ReadLong() +97
PdfSharp.Fonts.OpenType.CMapTable.Read() +114

Despite the font exception, do I miss something to get rid of these squares?

Author:  TH-Soft [ Sat Sep 29, 2018 6:31 am ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

marksu22 wrote:
I only got squares at Chinese characters.
Use a font that exists, has a format supported by PDFsharp, and has the characters you want to display.

marksu22 wrote:
Specify font name to "Microsoft JhengHei UI Bold". No exception. Got squares.
Is JHengHei still the TTC font that is not supported?
You will probably get the same result with "Epic fail qwe qwe qwe" as the font name - coz a substitution font will be used and there are no Chinese characters in it.

Find a TTF file with Chinese characters first.

Author:  marksu22 [ Sat Sep 29, 2018 5:52 pm ]
Post subject:  Re: PdfSharpException: Error on parsing OpenType font (chine

TH-Soft wrote:
Find a TTF file with Chinese characters first.

Thanks for your information.

I check the Chinese fonts come with the Windows 10, and most of them are TTC.

There is one TTF and its font name is "標楷體".

Yes. This one is okay.

This is good enough for now.

Thank you very much.

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