Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Embedding fonts in an exported PDF (Read 2074 times)
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Embedding fonts in an exported PDF
Jul 14th, 2025 at 10:52am
Print Post  
The PDF files that I export from PdfExporter do not show the fonts correctly in MS Edge, but look good in Acrobat. An internet search suggests that the fonts should be embedded in the PDF file for them to be shown correctly in Edge.  Is there an option or combination of options to do this?

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #1 - Jul 14th, 2025 at 2:52pm
Print Post  
We might have done that deliberately, font files were usually copyrighted at the time we created PDF exporter... We'll have in mind an option for next release, in case you'd want to use it with free fonts (e.g. https://developers.google.com/fonts).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #2 - Jul 15th, 2025 at 3:27pm
Print Post  
In our tests, Edge, Chrome and Firefox all display the fonts referenced from PDF as long as they are installed on the local system. Is there any specific font that's not working for you in that scenario?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Embedding fonts in an exported PDF
Reply #3 - Jul 18th, 2025 at 5:52pm
Print Post  
Just testing with Edge, our default font, Segoe UI, does not work, and neither does Arial. Acrobat seems to read both files OK.  The code we use to generate the files looks a bit like this...

                    var pdf = new PdfExporter();

                    try
                    {
                        pdf.AutoDetectEncoding = false;
                        pdf.DefaultEncoding = Encoding.Unicode;

                        pdf.Export(FlowChart, dlg.FileName);
                    }

                    catch (Exception ex)
                    {
                        ErrorBox(Resources.String_WriteFileFailed + ex.Message);
                    }

Both Arial and Segoe UI seemed to be installed locally.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #4 - Jul 21st, 2025 at 9:25am
Print Post  
It seems to work without the encoding options, does this display correctly on your side?

https://mindfusion.eu/_temp/test.pdf

So maybe Edge cannot recognize whatever PDF values we add for encodings. Our developer will review that part.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Embedding fonts in an exported PDF
Reply #5 - Jul 21st, 2025 at 10:30am
Print Post  
Yes, that file does display correctly, and our files now display correctly with those two lines of code removed.

However, the font does look a bit strange. Our default font of Segoe UI Semibold looks like the attached file.

If things could be improved, that would be great.

DavidL

  

Screenshot_2025-07-21_112629.png ( 12 KB | 42 Downloads )
Screenshot_2025-07-21_112629.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #6 - Jul 22nd, 2025 at 10:46am
Print Post  
Right, this one looks different in every browser, with Chrome version looking best. For time being maybe you could recommend it for online viewing, until we find more about how Edge renders PDFs:

https://mindfusion.eu/_temp/test2.pdf



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #7 - Jul 22nd, 2025 at 6:09pm
Print Post  
It looks nice in Edge too if you open the edge://flags/ page, find the "New PDF Viewer" flag, and set that to Disabled.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Embedding fonts in an exported PDF
Reply #8 - Jul 23rd, 2025 at 9:13am
Print Post  
That is an improvement, but we can't really ask customers to do that, especially as it says at the top of that page that you should't change these flags in a production environment.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #9 - Jul 25th, 2025 at 9:03am
Print Post  
We can't find any information on that new renderer, while old one is probably Chrome's PDFium. Our developers will try to implement font embedding after summer vacations to see if that fixes Edge's rendering. Meanwhile you might offer downloading the PDF for local viewing if server code is under your control and you detect Edge's user agent - add download attribute to the href or set Content-Disposition header for PDF files.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #10 - Jul 28th, 2025 at 5:59am
Print Post  
Our developer's managed to fix the Edge rendering -

https://www.nuget.org/packages/MindFusion.Diagramming/7.1.0-beta2
https://mindfusion.eu/_temp/test5.pdf

PdfExporter adds an optional /XHeight entry to PDF font descriptors (apparently used only by Edge's new renderer), which is copied from otmsXHeight field of this structure -

https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-outlinetext...

and we've just discovered otmsXHeight is listed as 'Not supported' and the API fills it with a hard-coded 250 value that does not match Segoe's x height. The exporter now measures actual "x" string to find the height.

Regarding embedding, we only find it feasible to embed the whole font file, which would add 1MB for Segoe UI Semibold to a PDF. Dedicated PDF generation libraries also do font subsetting (copy glyphs used for current PDF's text to keep it smaller), but that would require us to parse various complex font type files and generate back their subsets. If you'd need subsetting, we could expose some interface that PdfExporter calls and you'd implement using third party libraries for font manipulation (e.g. https://github.com/LayoutFarm/Typography might work).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Embedding fonts in an exported PDF
Reply #11 - Aug 4th, 2025 at 10:03am
Print Post  
Many thanks, that looks a lot better. Sorry, I missed your reply - I don't set notifications for replies, as I have a feeling that feature no longer works.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Embedding fonts in an exported PDF
Reply #12 - Feb 26th, 2026 at 12:01pm
Print Post  
This version lets you embed font files -

https://www.nuget.org/packages/MindFusion.Diagramming/7.2.0-alpha1

Code
Select All
pdfExporter.EmbedFont = (fontName) => true; 



We can probably extract from font's metadata whether the font owner allows embedding it, but for time being leaving that to your discretion. Microsoft seem to allow embedding Segoe UI specifically, as in screenshot.

Regards,
Slavcho
Mindfusion
  

segoe.png ( 23 KB | 4 Downloads )
segoe.png
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint