PHP: Using advantages of Unicode glyphs and kerning tables of Open Type fonts (otf) directly for creating PDF as a server response

StackOverflow https://stackoverflow.com/questions/11595496

Question

I working with database of documents, contents from 5 to 20 pages of text data each.
I have three tasks:

  1. To make multilingual output as PDF document. Texts in UTF8 and may content content in english, french, german, russian etc. and combinations like translations.
  2. To add an automatic typography in PDF, which means kerning and replacement combination of letters by Unicode characters.
  3. I have MinionPro-xxx.otf (10 ligatures) font for my job.

I tried to use PHP Cphf library by Wayne Munro (pdf@ros.co.nz) and I have added a lot of regular expressions to it. I have added a lot of PDF text formatting operators, like Ts, TL, T*, Tc, Tw, Tz and I almost done, but I can not reach glyphs of characters outside of the Type 1 chars table and I have no idea how to get the 'kern' and 'hmtx' tables from the font file? How to embed the glyphs?

I believe, I can do the kerning by the matrix transform PDF text directive:

[ (A) 120 (W) 120 (A) 95 (Y again) ] TJ

UPD#1: MinionPro font have no 'kern' table. It have 'GPOS' (The Glyph Positioning Table) and I am pretty close to solving the problem. By the way, walking inside the binary file by PHP is nightmare((

Was it helpful?

Solution

Using manual kerning in small font text strings is totally wrong strategy. Microsoft Excel PDF text exporters do the same and result is not acceptable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top