0
votes

I have a problem with generating a PDF file. I have embedded the font by using a /ToUnicode character map. Then I've written the glyph IDs as a text stream.

The strange thing is: I can select and copy text from the PDF into other applications an paste the text. This works with every character, even russian, greek, etc. However, the text does not display on-screen.

Below is the structure of my PDF:

PDF Structure

The PDF itself is available at: https://drive.google.com/file/d/0B9J8lfyB3w2PX3R3N0dfT0VhRTA/view?usp=sharing

If I view this PDF inside a browser (Firefox or Chrome), the text "Hello" shows up. If I open this PDF inside Adobe Reader or other document viewers such as xpdf or the Linux document viewer, the glyphs do not show up.

I have set the Encoding to Identity-H and created a valid /ToUnicode table. I've set the Font as CIDFontType0 / (CIDFontType0C in the FontDescriptor). The FontFile3 contains a full copy of the .otf file of the font "Asimov", since I wanted to embed the complete font.

The Linux PDF viewer tells me that the font is embedded:

Settings

I can't figure out why the text isn't displaying. I wrote the text by looking up the glyph ID for the font. What do I need to do in order to make the font show up?

3
what's the insane shape next to "hello"? i.imgur.com/7mdu8FE.pngMike 'Pomax' Kamermans
Preflight reports errors in the ICC profile... sadly no more details. But you should check this first (just switch to a default color space for testing). Also the value of PageMode is invalid.Jan Slabon
The ToUnicode table is irrelevant, its only used when copying/searching the document. It has no use when rendering glyphs.KenS

3 Answers

1
votes

Your (first) problem is the definition and use of color spaces named DefaultGray, DefaultRGB and DefaultCMYK, these names have specific meanings.

These spaces are used to map colours defined in DeviceGray, DeviceRGB and DeviceCMYK into CIE colour space, in order to colour manage the definitions. You do not use the Default* colour spaces directly. The text is turning out invisible because you are (in effect) using the same colour space twice, once directly as DefaultCMYK, then again to map the resulting CMYK values into CIE and then back to RGB (for the display).

You should either;

  1. Set the colour space to DeviceCMYK etc instead of DefaultCMYK
  2. Call the named colour spaces something other than DefaultCMYK etc

I also think, as Jan Slabon stated, there's something wrong with the ICC profile you are using.

Finally, it looks like the font is broken too, so even when you fix the colour space (which I've done by changing the content stream to use /DevcieCMYK) the text still doesn't render with Acrobat.

1
votes

The FontBBox in the FontDescriptor looks incorrect: [0 1327 472912 1327]

472912 seems too big, but having the same values for the second and fourth entries would indicate that this font has no height.

You might also want to consider setting the Ascent, Descent, and CapHeight entries to non-zero values.

0
votes

The problem was I compressed the font when saving the document. For whatever reason, you may not compress the font stream or the PDF viewer can't extract the data anymore. As soon as I disabled the compression on the PDF, the font showed up again.