Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
- adding customized ttf2ufm (ttf2pt1) library: used to generate .ufm …
Browse files Browse the repository at this point in the history
…files

- adding ufm files for common fonts
- updated class.pdf.php to produce valid CID block output and a warning in unicode mode
- colspan bug fix to cellmap.cls.php by Ciro Mondueri
- turn on Unicode support, for now.  will ultimately need a config option


git-svn-id: http://dompdf.googlecode.com/svn/trunk/dompdf@96 8e70de24-3a84-11de-b438-597f59cd7555
  • Loading branch information
Benj Carson committed Mar 12, 2008
1 parent 1cd82e2 commit be6a3bf
Show file tree
Hide file tree
Showing 151 changed files with 88,512 additions and 111 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ http://www.digitaljunkies.ca/dompdf
Copyright (c) 2004-2005 Benj Carson
R&OS PDF class (class.pdf.php) Copyright (c) 2001-04 Wayne Munro

This product includes software developed by the TTF2PT1 Project and its
contributors. See lib/ttf2ufm/ttf2ufm-src/COPYRIGHT.

Send bug reports, patches, feature requests, complaints & hate mail (no spam
thanks) to <[email protected]>

Expand Down
7 changes: 4 additions & 3 deletions dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @version 0.5.1
*/

/* $Id: dompdf.php,v 1.22 2007-06-25 02:45:11 benjcarson Exp $ */
/* $Id: dompdf.php,v 1.23 2008-03-12 06:35:42 benjcarson Exp $ */

/**
* Display command line usage:
Expand Down Expand Up @@ -295,9 +295,10 @@ function getoptions() {
$dompdf->render();

if ( $_dompdf_show_warnings ) {
global $_dompdf_warnings;
foreach ($_dompdf_warnings as $msg)
echo $msg . "\n";
echo $dompdf->get_canvas()->messages;
echo $dompdf->get_canvas()->get_cpdf()->messages;
flush();
}

Expand All @@ -316,7 +317,7 @@ function getoptions() {
if ( strpos($outfile, DOMPDF_CHROOT) !== 0 )
throw new DOMPDF_Exception("Permission denied.");

file_put_contents($outfile, $dompdf->output());
file_put_contents($outfile, $dompdf->output( array("compress" => 0) ));
exit(0);
}

Expand Down
21 changes: 14 additions & 7 deletions dompdf_config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
* @version 0.5.1
*/

/* $Id: dompdf_config.inc.php,v 1.28 2008-02-07 07:31:05 benjcarson Exp $ */
/* $Id: dompdf_config.inc.php,v 1.29 2008-03-12 06:35:43 benjcarson Exp $ */

error_reporting(E_STRICT | E_ALL);
//error_reporting(E_STRICT | E_ALL);

/**
* The root of your DOMPDF installation
Expand Down Expand Up @@ -81,16 +81,19 @@
* allow an attacker to use dompdf to read any files on the server. This
* should be an absolute path.
*/
define("DOMPDF_CHROOT", realpath(DOMPDF_DIR . "/../"));
define("DOMPDF_CHROOT", realpath(DOMPDF_DIR));

/** * The path to the tt2pt1 utility (used to convert ttf to afm)
/**
* The path to the tt2pt1 utility (used to convert ttf to afm)
*
* Not strictly necessary, but useful if you would like to install
* additional fonts using the {@link load_font.php} utility.
*
* @link http://ttf2pt1.sourceforge.net/
*/
define("TTF2AFM", "/usr/bin/ttf2pt1");
define("TTF2AFM", DOMPDF_LIB_DIR ."/ttf2ufm/ttf2ufm-src/ttf2pt1");
//define("TTF2AFM", "/usr/bin/ttf2pt1");

// Windows users should use something like this:
//define("TTF2AFM", "C:\\Program Files\\Ttf2Pt1\\bin\\ttf2pt1.exe");

Expand Down Expand Up @@ -213,7 +216,11 @@ function DOMPDF_autoload($class) {
require_once($filename);
}

if ( !function_exists("__autoload") ) {
if ( function_exists("spl_autoload_register") ) {

spl_autoload_register("DOMPDF_autoload");

} else if ( !function_exists("__autoload") ) {
/**
* Default __autoload() function
*
Expand All @@ -222,7 +229,7 @@ function DOMPDF_autoload($class) {
function __autoload($class) {
DOMPDF_autoload($class);
}
}
}

// ### End of user-configurable options ###

Expand Down
8 changes: 7 additions & 1 deletion include/cellmap.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: cellmap.cls.php,v 1.15 2007-06-25 02:45:12 benjcarson Exp $ */
/* $Id: cellmap.cls.php,v 1.16 2008-03-12 06:35:43 benjcarson Exp $ */

/**
* Maps table cells to the table grid.
Expand Down Expand Up @@ -416,6 +416,12 @@ function add_frame(Frame $frame) {
// Add the frame to the cellmap
$max_left = $max_right = 0;

// Find the next available column (fix by Ciro Mondueri)
$ac = $this->__col;
while ( isset($this->_cells[$this->__row][$ac]) )
$ac++;
$this->__col = $ac;

// Rows:
for ( $i = 0; $i < $rowspan; $i++ ) {
$row = $this->__row + $i;
Expand Down
4 changes: 2 additions & 2 deletions include/cpdf_adapter.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @version 0.5.1
*/

/* $Id: cpdf_adapter.cls.php,v 1.20 2008-02-07 07:31:05 benjcarson Exp $ */
/* $Id: cpdf_adapter.cls.php,v 1.21 2008-03-12 06:35:43 benjcarson Exp $ */

// FIXME: Need to sanity check inputs to this class
require_once(DOMPDF_LIB_DIR . "/class.pdf.php");
Expand Down Expand Up @@ -206,7 +206,7 @@ function __construct($paper = "letter", $orientation = "portrait") {
// Some people may not want to do this. Should we have
// a DOMPDF config variable somewhere that lets people
// choose?
$this->_pdf = new Cpdf($size, false);
$this->_pdf = new Cpdf($size, true);
$this->_pdf->addInfo("Creator", "dompdf");

// Silence pedantic warnings about missing TZ settings
Expand Down
4 changes: 2 additions & 2 deletions include/dompdf.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: dompdf.cls.php,v 1.22 2008-02-07 07:31:05 benjcarson Exp $ */
/* $Id: dompdf.cls.php,v 1.23 2008-03-12 06:35:43 benjcarson Exp $ */

/**
* DOMPDF - PHP5 HTML to PDF renderer
Expand Down Expand Up @@ -369,7 +369,7 @@ protected function _process_html() {

} else
$css = $style->nodeValue;

// Set the base path of the Stylesheet to that of the file being processed
$this->_css->set_protocol($this->_protocol);
$this->_css->set_host($this->_base_host);
Expand Down
3 changes: 1 addition & 2 deletions include/font_metrics.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: font_metrics.cls.php,v 1.6 2006-07-07 21:31:03 benjcarson Exp $ */
/* $Id: font_metrics.cls.php,v 1.7 2008-03-12 06:35:43 benjcarson Exp $ */

require_once(DOMPDF_LIB_DIR . "/class.pdf.php");

Expand Down Expand Up @@ -177,7 +177,6 @@ static function load_font_families() {

if ( $data != "" )
eval ('self::$_font_lookup = ' . $data . ";");

}

/**
Expand Down
3 changes: 2 additions & 1 deletion include/style.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: style.cls.php,v 1.21 2006-10-12 22:02:15 benjcarson Exp $ */
/* $Id: style.cls.php,v 1.22 2008-03-12 06:35:43 benjcarson Exp $ */

/**
* Represents CSS properties.
Expand Down Expand Up @@ -782,6 +782,7 @@ function get_font_family() {
// Resolve the font family
$families = explode(",", $this->_props["font_family"]);
reset($families);

$font = null;
while ( current($families) ) {
list(,$family) = each($families);
Expand Down
4 changes: 2 additions & 2 deletions include/stylesheet.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: stylesheet.cls.php,v 1.18 2006-10-18 21:49:11 benjcarson Exp $ */
/* $Id: stylesheet.cls.php,v 1.19 2008-03-12 06:35:43 benjcarson Exp $ */

/**
* The location of the default built-in CSS file.
Expand Down Expand Up @@ -845,7 +845,7 @@ private function _parse_sections($str) {

$selectors = explode(",", mb_substr($sect, 0, $i));
$style = $this->_parse_properties(trim(mb_substr($sect, $i+1)));

// Assign it to the selected elements
foreach ($selectors as $selector) {
$selector = trim($selector);
Expand Down
16 changes: 8 additions & 8 deletions include/text_frame_decorator.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: text_frame_decorator.cls.php,v 1.7 2007-08-22 23:02:07 benjcarson Exp $ */
/* $Id: text_frame_decorator.cls.php,v 1.8 2008-03-12 06:35:43 benjcarson Exp $ */

/**
* Decorates Frame objects for text layout
Expand Down Expand Up @@ -77,13 +77,13 @@ function get_text() {
$this->_frame->get_style()->content = "normal";
}

// pre_r("---");
// $style = $this->_frame->get_style();
// var_dump($text = $this->_frame->get_node()->data);
// var_dump($asc = utf8_decode($text));
// for ($i = 0; $i < strlen($asc); $i++)
// pre_r("$i: " . $asc{$i} . " - " . ord($asc{$i}));
// pre_r("width: " . Font_Metrics::get_text_width($text, $style->font_family, $style->font_size));
// pre_r("---");
// $style = $this->_frame->get_style();
// var_dump($text = $this->_frame->get_node()->data);
// var_dump($asc = utf8_decode($text));
// for ($i = 0; $i < strlen($asc); $i++)
// pre_r("$i: " . $asc{$i} . " - " . ord($asc{$i}));
// pre_r("width: " . Font_Metrics::get_text_width($text, $style->font_family, $style->font_size));

return $this->_frame->get_node()->data;
}
Expand Down
3 changes: 2 additions & 1 deletion include/text_renderer.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @version 0.5.1
*/

/* $Id: text_renderer.cls.php,v 1.7 2008-02-07 07:31:05 benjcarson Exp $ */
/* $Id: text_renderer.cls.php,v 1.8 2008-03-12 06:35:43 benjcarson Exp $ */
/**
* Renders text frames
*
Expand Down Expand Up @@ -71,6 +71,7 @@ function render(Frame $frame) {
$x += $style->length_in_pt( array($ml, $pl, $bl), $cb["w"] );

$text = $frame->get_text();

$font = $style->font_family;
$size = $style->font_size;
$height = $style->height;
Expand Down
63 changes: 32 additions & 31 deletions lib/class.pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,29 +823,31 @@ function o_font($id, $action, $options = '') {
$toUnicodeId = ++$this->numObj;
$this->o_contents($toUnicodeId, 'new', 'raw');
$this->objects[$id]['info']['toUnicode'] = $toUnicodeId;
$res= "<</Length 383>>\n";
$res.= "stream\n";
$res.= "/CIDInit /ProcSet findresource begin\n";
$res.= "12 dict begin\n";
$res.= "begincmap\n";
$res.= "/CIDSystemInfo\n";
$res.= "<</Registry (Adobe)\n";
$res.= "/Ordering (UCS)\n";
$res.= "/Supplement 0\n";
$res.= ">> def\n";
$res.= "/CMapName /Adobe-Identity-UCS def\n";
$res.= "/CMapType 2 def\n";
$res.= "1 begincodespacerange\n";
$res.= "<0000> <FFFF>\n";
$res.= "endcodespacerange\n";
$res.= "1 beginbfrange\n";
$res.= "<0000> <FFFF> <0000>\n";
$res.= "endbfrange\n";
$res.= "endcmap\n";
$res.= "CMapName currentdict /CMap defineresource pop\n";
$res.= "end\n";
$res.= "end\n";
$res.= "endstream";

$stream = "/CIDInit /ProcSet findresource begin\n";
$stream.= "12 dict begin\n";
$stream.= "begincmap\n";
$stream.= "/CIDSystemInfo\n";
$stream.= "<</Registry (Adobe)\n";
$stream.= "/Ordering (UCS)\n";
$stream.= "/Supplement 0\n";
$stream.= ">> def\n";
$stream.= "/CMapName /Adobe-Identity-UCS def\n";
$stream.= "/CMapType 2 def\n";
$stream.= "1 begincodespacerange\n";
$stream.= "<0000> <FFFF>\n";
$stream.= "endcodespacerange\n";
$stream.= "1 beginbfrange\n";
$stream.= "<0000> <FFFF> <0000>\n";
$stream.= "endbfrange\n";
$stream.= "endcmap\n";
$stream.= "CMapName currentdict /CMap defineresource pop\n";
$stream.= "end\n";
$stream.= "end\n";

$res = "<</Length " . strlen($stream) . " >>\n";
$res .= "stream\n" . $stream . "endstream";

$this->objects[$toUnicodeId]['c'] = $res;

$cidFontId = ++$this->numObj;
Expand Down Expand Up @@ -1243,9 +1245,9 @@ function o_fontGIDtoCIDMap($id, $action, $options = '') {
break;

case 'out':

$res = "\n".$id." 0 obj\n";
$this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
$tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']);
$compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
$this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];

Expand Down Expand Up @@ -1737,7 +1739,6 @@ function o_contents($id, $action, $options = '') {
}

case 'out':

$tmp = $o['c'];

$res = "\n".$id." 0 obj\n";
Expand Down Expand Up @@ -2679,9 +2680,9 @@ function openFont($font) {
}

if (!isset($this->fonts[$font])) {

$this->addMessage('openFont: no font file found');

$this->addMessage("openFont: no font file found for $font. Do you need to run load_font.php?");
// echo 'Font not Found '.$font;

}
Expand Down Expand Up @@ -3586,8 +3587,8 @@ function getFontHeight($size) {
if (!$this->numFonts) {
$this->selectFont('./fonts/Helvetica');
}

// for the current font, and the given size, what is the height of the font in user units
// for the current font, and the given size, what is the height of the font in user units
$h = $this->fonts[$this->currentFont]['FontBBox'][3]-$this->fonts[$this->currentFont]['FontBBox'][1];

// have to adjust by a font offset for Windows fonts. unfortunately it looks like
Expand Down
Loading

0 comments on commit be6a3bf

Please sign in to comment.