Non-embedded fonts

  • Steve Hannah
    Steve Hannah

    The PHP TCPDF library allows you to "not embed" core fonts and CID-0 fonts.
    "The fonts that could be not embedded are only the standard core fonts and CID-0 fonts."

    I see that they have created their own PHP files with the cmap tables for each font/language. They seem to be based on the ArialUnicodeMS font.

    Here is a sample from their korean font (cid0kr.php):

    // Korean
    $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Korea1','Supplement'=>0);
    $desc=array('Flags'=>32,'FontBBox'=>'[-1011 -330 2260 1078]','ItalicAngle'=>0,'Ascent'=>1069,'Descent'=>-271,'Leading'=>0,'CapHeight'=>716,'XHeight'=>518,'StemV'=>34,'StemH'=>15,'AvgWidth'=>441,'MaxWidth'=>2259,'MissingWidth'=>1000);
    $cw=array(0=>1000,32=>278,33=>278,34=>355,35=>556, etc....

    So my question is: Is there a similar facility in PDFClown to be able to specify the characters to be displayed without actually embedding the font?

    Thanks for any tips.


    • Steve Hannah
      Steve Hannah

      I managed to get Chinese, Japanese, and Korean fonts working as CIDType0, non-embedded fonts by subclassing the Font class and creating a parser TCPDF's fonts. It is working well, but I am having difficulty getting the widths of fonts to render correctly. If I use the character widths in the font and use the /W [] array, it places too much space between the characters.

      If I make it so that the glyphWidths map stores the correct widths, but I store the widths in the /W array (inside the PDF document) scaled down by a factor of 2, it approximately comes out right.

      Any idea what would cause this?


      I know this doesn't offer much of a clue as to where to start

  • Steve Hannah
    Steve Hannah

    Got it all sorted out. I was encoding each character with 4 bytes. Should have been using only 2 bytes. I have uploaded the library to GitHub so you can use Chinese, Japanese, and Korean fonts now easily in PDFClown.