Non-embedded fonts

Help
2013-07-19
2013-07-25
  • Steve Hannah
    Steve Hannah
    2013-07-19

    The PHP TCPDF library allows you to "not embed" core fonts and CID-0 fonts.

    http://www.tcpdf.org/fonts.php
    "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):

    <?php
    // TCPDF FONT FILE DESCRIPTION
    $type='cidfont0';
    $name='ArialUnicodeMS';
    $up=-100;
    $ut=50;
    $dw=1000;
    $diff='';
    $originalsize=23275812;
    // Korean
    $enc='UniKS-UTF16-H';
    $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'Korea1','Supplement'=>0);
    include(dirname(__FILE__).'/uni2cid_ak12.php');
    $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

     
    • Steve Hannah
      Steve Hannah
      2013-07-24

      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?

      Steve

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

       
  • Steve Hannah
    Steve Hannah
    2013-07-25

    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.
    https://github.com/shannah/PDFClownCJKFont