Font MPDFAA+Arial is missing the following glyphs:
Greetings!
While creating PDF file with cyrillic text my code shows me:
Font MPDFAA+DejaVuSansCondensed is missing the following glyphs:
with Arial font:
Font MPDFAA+Arial is missing the following glyphs:
code
pdf = FPDF()
pdf.add_page()
pdf.add_font('DejaVu', 'B', 'DejaVuSansCondensed.ttf')
pdf.set_font('DejaVu', 'B', 14)
with pdf.table(text_align=("LEFT"), borders_layout="MINIMAL", line_height = 5) as table:
row = table.row()
row.cell(someData)
pdf.output(fileName, ".pdf")
How can I find char, string, positon or other place where message appear. I distorbing that some data was missing.
Windows 10 Python 3.10 fpdf2 2.7.8
It looks like your text contains some unusual non-printing characters. Being unusual results in them not being present in some popular fonts. Being non-printing results in them not showing up in a recognizable form in that error message.
Maybe that error message should really output the Unicode values of the missing glyphs instead of trying to print them to the console...
I'm using data only from the web to create PDF files. My script generated more than 1300 pages with a 10pt font, and I couldn't find any missing data by hand. Is the fpdf module using some parameters or arguments to show missing glyphs?
If a character actually has a visible glyph, then the warning message you received would show that.
But it obviously doesn't in your case. There are many unicode characters that are considered whitespace characters. It could well be one of those that causes your message, or possibly something even more exotic.
If you really want to know what it is, use the "unicodedata" Python library module, collect all the unicode code points present in your affected data and print out their numbers and names. You may end up with something obvious, or a small list of suspects. Trying to render each of those with fpdf2 will tell you exactly who the culprit is.
In my logs, I see
fpdf.output WARNING Font MPDFAA+DejaVuSansCondensed is missing the following glyphs:
I use Python module logging. How can I disable this message?
Hi @blinking-led
We have a bit of documentation regarding logging control related to fpdf2 and its dependencies:
https://py-pdf.github.io/fpdf2/Logging.html
But overall, logging control is a broader topic. You may want to read the official Python documentation on the subject: https://docs.python.org/3/library/logging.html
If you want to suppress those warnings programmatically in a script, a starting point could be:
logging.getLogger('fpdf.output').level = logging.ERROR # no DEBUG/INFO/WARN logs will be produced
Quoting @gmischler answer:
Maybe that error message should really output the Unicode values of the missing glyphs instead of trying to print them to the console...
I think that is a great idea yes! Having both the character printed AND its unicode value displayed seems helpful.
Maybe that error message should really output the Unicode values of the missing glyphs instead of trying to print them to the console...
I think that is a great idea yes! Having both the character printed AND its unicode value displayed seems helpful.
I implemented this in this PR: https://github.com/py-pdf/fpdf2/pull/1179
@Lucas-C thank you for the advice. I am already using it. But I want to see all messages in my log, but without
missing the following glyphs
I generate a number of files with about 2000 pages, and I see in my log a huge number WARNING
Can I skip missing glyphs while assembling the PDF to escape this message?
@Lucas-C thank you for the advice. I am already using it. But I want to see all messages in my log, but without
missing the following glyphsI generate a number of files with about 2000 pages, and I see in my log a huge number WARNING Can I skip missing glyphs while assembling the PDF to escape this message?
I am sorry, I think that I do not quite understand what you mean 😅
I am already using it.
Are you refering to the log filtering mechanism I mentioned, logging.getLogger('fpdf.output').level = logging.ERROR ?
I want to see all messages in my log, but without
missing the following glyphsI generate a number of files with about 2000 pages. [...] Can I skip missing glyphs while assembling the PDF to escape this message?
OK, so what I understand is that you want to suppress only this log line but preserve the other DEBUG/INFO logs from the fpdf.output module: is that correct?
If that's correct, you may want to look into solutions like this: https://stackoverflow.com/a/879937/636849
Finally, other valid approaches could be to remove duplicate log lines or to aggregate those log lines to concatenate them and only report missing glyphs ONCE at the end of the PDF generation process. All those solutions can improve your situation when generating massive PDF documents, but it's really outside the scope of this library to provide implementations on those subjects, so you will have to research a little bit on yourself how to implement them 🙂
Edit: on second thought, just to be sure: in your use case, you are seing this log message only once per font, right? So you are generating a 2000 pages document with many fonts? Is this huge number of repeated log lines due to the fact that you are generating many files?
Exactly! Thank you @Lucas-C!