PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Dec 10, 2018 10:59 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Sep 27, 2018 11:44 am 
Offline

Joined: Thu Sep 27, 2018 11:30 am
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2018 2:28 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2893
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 9:05 am 
Offline

Joined: Thu Sep 27, 2018 11:30 am
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 9:46 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 28, 2018 9:56 pm 
Offline

Joined: Fri Sep 28, 2018 9:40 pm
Posts: 3
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?


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 29, 2018 6:31 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 428
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 29, 2018 5:52 pm 
Offline

Joined: Fri Sep 28, 2018 9:40 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group