PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 7:16 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Feb 16, 2022 4:35 pm 
Offline

Joined: Wed Feb 16, 2022 4:32 pm
Posts: 1
Hi folks!

I've been using PDFSharp in one of my apps but I've noticed that if we've got emojis in a text string they're not outputting correctly - I just get a rectangular shape instead.

Can I check if this is a known limitation or if there's anything I need to look out for when outputting such content?

Thanks all and apologies if this is a newbie question :-)

Mike


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 23, 2022 3:02 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
This is a limitation of the current implementation.

Code that supports surrogate pairs can be found via this page:
https://github.com/empira/PDFsharp-1.5/issues/63

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


Last edited by TH-Soft on Sun Sep 17, 2023 4:07 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 16, 2023 1:06 am 
Offline

Joined: Sat Sep 16, 2023 1:01 am
Posts: 3
I have done research on this for a couple days and have only found that PdfSharp/MigraDoc just do not support surrogate pairs.

I hear that there is a pull request with a fix for this, but I can't find the code anywhere.

Has anyone been able to make this work?


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 16, 2023 1:09 am 
Offline

Joined: Sat Sep 16, 2023 1:01 am
Posts: 3
the link doesn't resolve. Is this code available anywhere?


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 17, 2023 4:08 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
NeilPearson73 wrote:
the link doesn't resolve.
The link works.

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


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 17, 2023 4:09 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Code that supports surrogate pairs can be found via this page:
https://github.com/empira/PDFsharp-1.5/issues/63

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 19, 2023 1:32 am 
Offline

Joined: Sat Sep 16, 2023 1:01 am
Posts: 3
TH-Soft wrote:
Code that supports surrogate pairs can be found via this page:
https://github.com/empira/PDFsharp-1.5/issues/63


Perfect, that was precisely what I needed! Thanks!

I had to apply all the code changes that @TheRealSourceSeeker suggested but in the end it works great. Now if I could only get color emojis to work.


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 23, 2023 8:45 am 
Offline

Joined: Tue Sep 30, 2014 12:29 pm
Posts: 36
I recently got colored emojis working in the current 6.0 version by supporting color-tables stored in font-files.
I took the code from the mentioned issue and expanded from there.
See this commit (and this for a small optimization)

Note there are 2 Versions of color-tables (Version 0 and Version 1).
https://learn.microsoft.com/en-us/typog ... /spec/colr

Version 0 basically supports only "flat" colors per layer.
Version 1 is more advanced, supporting gradients and such.
The code in the commit ONLY supports version 0 tables :!:

I have to admit i'm absolutely NOT an expert regarding encodings, font-handling and what have you; so be aware the code may contain flaws that are not obvious to me.

That said, i testet this successfully with the Segoe UI Emoji font, which has a version 0 color table.
I also added a test-case to render all characters supported by a certain font.
All characters of the mentioned Emoji font showed up correctly (as far as i can tell).

I'm not 100% certain, but it should not be too hard to port this to 1.5, if you need it there.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 129 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