8000 Minor updates to the Canvas adapter by bsweeney · Pull Request #3704 · dompdf/dompdf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions lib/Cpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,10 @@ private function processFont(int $fontObjId, array $object_info)
}

// also need to adjust the widths for the differences array
if (isset($object['differences'])) {
foreach ($object['differences'] as $charNum => $charName) {
if (isset($object_info['differences'])) {
foreach ($object_info['differences'] as $charNum => $charName) {
if ($charNum > $lastChar) {
if (!$object['isUnicode']) {
if (!$object_info['isUnicode']) {
// With Unicode, widths array isn't used
for ($i = $lastChar + 1; $i <= $charNum; $i++) {
$widths[] = 0;
Expand Down Expand Up @@ -3758,7 +3758,7 @@ private function openFont($font)

$c = (int)$dtmp['U'];
$n = $dtmp['N'];
$glyph = $dtmp['G'];
$glyph = (int)$dtmp['G'];
$width = floatval($dtmp['WX']);

if ($c >= 0) {
Expand Down Expand Up @@ -3810,7 +3810,7 @@ private function openFont($font)
}

if (!isset($this->fonts[$font])) {
$this->addMessage("openFont: no font file found for $font. Do you need to run load_font.php?");
$this->addMessage("openFont: no font file found for $font.");
}
}

Expand Down Expand Up @@ -4831,6 +4831,25 @@ public function clippingPolygon(array $p): void
$this->addContent("W n");
}

/**
* saves the graphics state prior to manually drawing shapes to be used for clipping
*
* after drawing a shape use the clip() function to use the shape for clipping,
* and then use clippingEnd() to end the clipping region and restore the graphics state
*/
function clippingStart()
{
$this->save();
}

/**
* uses the previously drawn path for clipping, all the elements added after this will be clipped
*/
function clip()
{
$this->addContent("\nW n");
}

/**
* ends the last clipping shape
*/
Expand Down Expand Up @@ -6375,7 +6394,6 @@ function addPngFromBuf(&$data, $file, $x, $y, $w = 0.0, $h = 0.0, $is_mask = fal
$info['filterMethod'] = ord($data[$p + 19]);
$info['interlaceMethod'] = ord($data[$p + 20]);

//print_r($info);
$haveHeader = 1;
if ($info['compressionMethod'] != 0) {
$error = 1;
Expand Down Expand Up @@ -6549,14 +6567,12 @@ function addPngFromBuf(&$data, $file, $x, $y, $w = 0.0, $h = 0.0, $is_mask = fal
return;
}

//print_r($info);
// so this image is ok... add it in.
$this->numImages++;
$im = $this->numImages;
$label = "I$im";
$this->numObj++;

// $this->o_image($this->numObj,'new',array('label' => $label,'data' => $idata,'iw' => $w,'ih' => $h,'type' => 'png','ic' => $info['width']));
$options = [
'label' => $label,
'data' => $idata,
Expand Down
0