Hi all, I have an issue in PDFDocument where the Avenir and AvenirHeavy fonts are rendered incorrectly. A customer reported that Acrobat Reader for Windows reports that “The font ‘AvenirHeavy’ contains a bad /BBox.”
The attached screenshot shows how it is rendered on macOS.
var pdf As new PDFDocument(600, 800)
var g As Graphics = pdf.Graphics
g.FontName = "Avenir"
g.FontSize = 20
g.DrawText("Avenir", 10, 50)
var file As FolderItem = SpecialFolder.Desktop.Child("PDF_BadBBox.pdf")
Try
pdf.Save(file)
file.Open
Catch e As IOException
MessageBox(e.Message)
End Try
Adding pdf.EmbeddedFonts = True does not help, it only changes the position of the capital letter A.
Is it an issue in my code, in Xojo, and do you know of any workaround?
Looks like the font has a problem that may not show on other tools but in Xojo.
Maybe you can open an Issue (privately if needed), attach the font for Xojo team to reproduce. Not sure if they can fix something to match behavior on other software or they think the font needs fixing.
The problem seems to be in the “Book” style.
These are the results using all the fonts in the “Avenir” family, and for comparison how the same fonts are exported by Affinity Designer.
Oh okay, that’s understandable. Well, it’s very likely an issue with the Xojo PDF engine because it’s entirely custom. You’ll probably want to open a ticket, attach a sample project and the font file privately.
I added two times the Avenir Book lines at the code end, sameresult (and I cleared the 202’r4.2 caches)
In the IDE, I removed the space and add a brand new one with the space bar (in case it was a non breaking space)…
“Bbox” is a shorthand for “bounding box”, and each glyph in a font must have one that is valid. Looks like this version of the font has been damaged in some way – Acrobat is actually incredibly tolerant of oddball data in PDFs and if IT is throwing an error, you know it’s serious. I’d say install a newer version of the font if you can find it.
The font rendering system uses the bounding box to properly position letters, and you can do all manner of strange things with it if you manipulate the values. Such as … overlapping letters, just like this.
Still want your PDF, to inspect its guts, because your sample app works here, but all fonts are changed to some kind of Helvetica. I want to see if I can find and understand (no guarantees) the specific bounding box problem that Adobe just mentions.