Skip to main content
Known Participant
February 27, 2023
Question

C++ SDK - bad /BBox for any TT fonts in appearance stream even though they display fine

  • February 27, 2023
  • 11 replies
  • 1631 views

I am using teh STAMPR sample to create a custom annotation type. It works as far as displaying it goes, but the first time it displays a True Type character, i get the pop up that says the font has a bad /BBox. I have tried diffrent fonts and they all getit. i use the font elsewhere in a textrun and it doesn't get the error.

I modified the Cos generation in teh sample as shown below the commented out parts were where I tried a couple of things - one that I found suggested as it culd force a defaut and the other just being a large BBox that no character should ever exceed. Currently not adding the entry at all as the doc say it will be  determined by using information in the font.

After I get the message box once, it doesn't show again until I close and reopen the file.

And finally, there is one symptom that concerns me the most and makes me wonder if it might be a problem with Acrobat. If I use two different fonts, it will only complain about teh first charcter of the first font. It will not report a problem with the second font. This is true in either order; whichever font I use first will get an error reported once only and teh other font will not get an error reported.

 

Creating the font entry:


// Add Font resource to Resources dictionary.
fontResObj = CosNewDict(cdoc, true, 1L);
fontResObj2 = CosNewDict(cdoc, true, 5L);
cObj = CosNewNameFromString(cdoc, false, "Font");
CosDictPutKeyString(fontResObj2, "Type", cObj);
cObj = CosNewNameFromString(cdoc, false, "TrueType");
CosDictPutKeyString(fontResObj2, "Subtype", cObj);
//cObj = CosNewNameFromString(cdoc, false, CurrentTickItem->FontName.c_str());
//CosDictPutKeyString(fontResObj2, "Name", cObj);
cObj = CosNewNameFromString(cdoc, false, sFontName);
CosDictPutKeyString(fontResObj2, "BaseFont", cObj);
//cBBoxObj = CosNewArray(cdoc, false, 4L);
//CosArrayInsert(cBBoxObj, 0L, CosNewInteger(cdoc, false, 0L)); // left
//CosArrayInsert(cBBoxObj, 1L, CosNewInteger(cdoc, false, 0L)); // top
//CosArrayInsert(cBBoxObj, 2L, CosNewInteger(cdoc, false, 0L)); // right
//CosArrayInsert(cBBoxObj, 3L, CosNewInteger(cdoc, false, 0L)); // bottom
//CosDictPutKeyString(fontResObj2, "FontBBox", cBBoxObj);
//cObj = CosNewNameFromString(cdoc, false, "[-8 -280 995 855]");
//CosDictPutKeyString(fontResObj2, "FontBBox", cObj);

CosDictPutKeyString(fontResObj, sFontName, fontResObj2);
CosDictPutKeyString(cResObj, "Font", fontResObj);

 

This topic is closed to new replies. Start a new post to keep the conversation going.

11 replies

Legend
February 27, 2023

By my reading of the PDF spec, and my estimate of what your code does, it is not a compliant font object (even if it sometimes works) because

- FontBBox belongs in a FontDescriptor, not a Font Dictionary (except for type 3 fonts)

- FontBBox is required

Furthermore, //cObj = CosNewNameFromString(cdoc, false, "[-8 -280 995 855]"); if you used it, is not how you create a FontBBox. It must be an array object.

- FontDescriptor is required (except for the base 14 fonts)

Known Participant
February 27, 2023

In the PDF spec, there is an example of a PDF entry for a TrueType font. It does not have a /BBox. BTW, it doesn't "sometimes work". It always works - 100% of the time the character shows using the requested font. Acrobat pops up teh message box once and only once, for the first occurence of an appearance stream using a TrueType font. It does not pop up for subsequent appearance streams even if they use a different TrueType font

Example 5.8 1

7 0 obj

<< /Type /Font

/Subtype /TrueType

/BaseFont /NewYork,Bold

/FirstChar 0

/LastChar 255

/Widths 23 0 R

/FontDescriptor 7 0 R

/Encoding /MacRomanEncoding >> endobj

23 0 obj [0333 333 333 333 333 333 333 0 333 333 333 333 333 333 333 333 333

…Omitted data…

803 790 803 780 780 780 340 636 636 636 636 636 636 636 636 636 636 ] endobj