question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fonts not embedded in PDF

See original GitHub issue

Hi, i was using weasyprint 52.2 with python 3.8 on fedora32. After upgrading to fedora33, my fonts are not embedded into the resulting pdf any more. fedora33 uses python 3.9, i also upgraded to weasyprint 52.4… no change to the result.

What i did so far:

  1. using weasyprint standalone (this is my main usage)
weasyprint in.html out.pdf

A pdf is generated, embedded fonts missing

  1. using weasyprint as python script
from weasyprint import HTML, CSS
from weasyprint.fonts import FontConfiguration
font_config = FontConfiguration()
html=HTML('in.md.html')
html.write_pdf('out.pdf',font_config=font_config)

same result, no fonts in pdf

My Html uses an external css with @font-face e.g.

@font-face {
  font-family: mySerif;
    font-weight: normal;
    font-style: normal;
    font-stretch: normal;
  src: local('Liberation Serif'),
       url(file:///usr/share/fonts/liberation-serif/LiberationSerif-Regular.ttf) format('truetype');
}

The browser has no problems rendering my embedded fonts, neither did weasyprint on fedora32/py3.8 (if that matters at all…) So, my old working pdf output had these fonts (successfully embedded)

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AOAFFM+LiberationSerif               TrueType          WinAnsi          yes yes yes     36  0
VZUWYF+LiberationSerif               CID TrueType      Identity-H       yes yes yes     37  0
DIVSUD+RobotoMono-Regular            TrueType          WinAnsi          yes yes yes     84  0
JPSGLH+CairoFont-2-0                 Type 1C           WinAnsi          yes yes yes     85  0
HNYAUK+RobotoMono-Bold               TrueType          WinAnsi          yes yes yes    112  0
IQFZUN+RobotoMono-Regular            TrueType          WinAnsi          yes yes yes    113  0

The new one has only these default fonts:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
ANQKNJ+BitstreamVeraSans-Roman       TrueType          WinAnsi          yes yes yes     37  0
JBCTMJ+DejaVuSans                    CID TrueType      Identity-H       yes yes yes     38  0
XMKNHA+BitstreamVeraSans-Roman       CID TrueType      Identity-H       yes yes yes     83  0
YNMLOL+BitstreamVeraSans-Bold        TrueType          WinAnsi          yes yes yes     84  0
EZEEOY+BitstreamVeraSans-Oblique     TrueType          WinAnsi          yes yes yes    122  0

I had a (one!) font embedded into my pdf when using

weasyprint -v ${filename}.md.html ${filename}.md.pdf -s <(echo 'body { font-family: 'Liberation Serif' !important }')

with this font list:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
MNDGRP+LiberationSerif               TrueType          WinAnsi          yes yes yes     37  0
RLFUEA+LiberationSerif               CID TrueType      Identity-H       yes yes yes     38  0
AFSQCL+BitstreamVeraSans-Roman       TrueType          WinAnsi          yes yes yes     39  0
WKPJBS+LiberationSerif-Bold          TrueType          WinAnsi          yes yes yes     87  0
YTXGBQ+BitstreamVeraSans-Bold        TrueType          WinAnsi          yes yes yes    114  0
EZEEOY+BitstreamVeraSans-Oblique     TrueType          WinAnsi          yes yes yes    115  0

Overriding with user styelsheets and !important cannot be the solution… I’m running out of ideas for now, any help?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
slartibart70commented, Mar 23, 2021

you’re my hero!!! Thanks for pointing to the patch, appllied it and we’re back to ‘normal’ again!!

1reaction
FelixSchwarzcommented, Mar 23, 2021

@liZe Thanks for bringing this to my attention. I recently got an automated notification that WeasyPrint’s test suite has even more test failures in Fedora but I did not have time to debug this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Font not embedded - Accessibility is the right thing to do!
In Acrobat Pro, Tools > Print Production > Preflight > expand “PDF Fixups” > select “Embed Fonts” > click “Analyze and fix”. This...
Read more >
Solved: Missing Embedded Fonts - Adobe Support Community
Go to Tools > Print Production > Preflight select the “PDF fixups” option and select “Embed missing fonts” and click the “Analyze and...
Read more >
How to Embed Fonts in PDFs (and Why You Need to Do It)
Open your PDF file · Click File > Document Properties · Click on the Fonts Tab to display the list of all fonts...
Read more >
FAQ: Why some fonts cannot be embedded into my pdf file?
FAQ: Why some fonts cannot be embedded into my pdf file? · Open the Word or Excel file that you need to convert....
Read more >
How Do I Embed Fonts in a PDF? Print - Knowledge Base - Lulu
Confirm Fonts are Embedded are in your PDF: · Open the file using Adobe Reader or Acrobat Pro · Go to File >...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found