Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FPDF #13

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: Unconfirmed bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions 1_Base_Files/YOUR_ADMIN/includes/auto_loaders/config.fpdf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
// FPDF

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}

$autoLoadConfig[999][] = array('autoType'=>'class',
'loadFile'=>'fpdf.php',
'classPath'=>DIR_WS_CLASSES . 'fpdf/');

$autoLoadConfig[999][] = array('autoType'=>'class',
'loadFile'=>'pdf.php',
'classPath'=>DIR_WS_CLASSES . 'fpdf/');
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
$ut = 50;
for($i=0;$i<=255;$i++)
$cw[chr($i)] = 600;
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
$ut = 50;
for($i=0;$i<=255;$i++)
$cw[chr($i)] = 600;
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
$ut = 50;
for($i=0;$i<=255;$i++)
$cw[chr($i)] = 600;
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
$ut = 50;
for($i=0;$i<=255;$i++)
$cw[chr($i)] = 600;
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
$enc = 'cp1252';
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
?>
142 changes: 110 additions & 32 deletions 1_Base_Files/YOUR_ADMIN/includes/classes/fpdf/font/makefont/makefont.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/*******************************************************************************
* Utility to generate font definition files *
* *
* Version: 1.2 *
* Date: 2011-06-18 *
* Version: 1.3 *
* Date: 2015-11-29 *
* Author: Olivier PLATHEY *
*******************************************************************************/

Expand Down Expand Up @@ -59,21 +59,40 @@ function LoadMap($enc)
return $map;
}

function GetInfoFromTrueType($file, $embed, $map)
function GetInfoFromTrueType($file, $embed, $subset, $map)
{
// Return informations from a TrueType font
$ttf = new TTFParser();
$ttf->Parse($file);
// Return information from a TrueType font
try
{
$ttf = new TTFParser($file);
$ttf->Parse();
}
catch(Exception $e)
{
Error($e->getMessage());
}
if($embed)
{
if(!$ttf->Embeddable)
if(!$ttf->embeddable)
Error('Font license does not allow embedding');
$info['Data'] = file_get_contents($file);
$info['OriginalSize'] = filesize($file);
if($subset)
{
$chars = array();
foreach($map as $v)
{
if($v['name']!='.notdef')
$chars[] = $v['uv'];
}
$ttf->Subset($chars);
$info['Data'] = $ttf->Build();
}
else
$info['Data'] = file_get_contents($file);
$info['OriginalSize'] = strlen($info['Data']);
}
$k = 1000/$ttf->unitsPerEm;
$info['FontName'] = $ttf->postScriptName;
$info['Bold'] = $ttf->Bold;
$info['Bold'] = $ttf->bold;
$info['ItalicAngle'] = $ttf->italicAngle;
$info['IsFixedPitch'] = $ttf->isFixedPitch;
$info['Ascender'] = round($k*$ttf->typoAscender);
Expand All @@ -82,20 +101,20 @@ function GetInfoFromTrueType($file, $embed, $map)
$info['UnderlinePosition'] = round($k*$ttf->underlinePosition);
$info['FontBBox'] = array(round($k*$ttf->xMin), round($k*$ttf->yMin), round($k*$ttf->xMax), round($k*$ttf->yMax));
$info['CapHeight'] = round($k*$ttf->capHeight);
$info['MissingWidth'] = round($k*$ttf->widths[0]);
$info['MissingWidth'] = round($k*$ttf->glyphs[0]['w']);
$widths = array_fill(0, 256, $info['MissingWidth']);
for($c=0;$c<=255;$c++)
foreach($map as $c=>$v)
{
if($map[$c]['name']!='.notdef')
if($v['name']!='.notdef')
{
$uv = $map[$c]['uv'];
if(isset($ttf->chars[$uv]))
if(isset($ttf->chars[$v['uv']]))
{
$w = $ttf->widths[$ttf->chars[$uv]];
$id = $ttf->chars[$v['uv']];
$w = $ttf->glyphs[$id]['w'];
$widths[$c] = round($k*$w);
}
else
Warning('Character '.$map[$c]['name'].' is missing');
Warning('Character '.$v['name'].' is missing');
}
}
$info['Widths'] = $widths;
Expand All @@ -104,7 +123,7 @@ function GetInfoFromTrueType($file, $embed, $map)

function GetInfoFromType1($file, $embed, $map)
{
// Return informations from a Type1 font
// Return information from a Type1 font
if($embed)
{
$f = fopen($file, 'rb');
Expand Down Expand Up @@ -172,21 +191,24 @@ function GetInfoFromType1($file, $embed, $map)

if(!isset($info['FontName']))
Error('FontName missing in AFM file');
if(!isset($info['Ascender']))
$info['Ascender'] = $info['FontBBox'][3];
if(!isset($info['Descender']))
$info['Descender'] = $info['FontBBox'][1];
$info['Bold'] = isset($info['Weight']) && preg_match('/bold|black/i', $info['Weight']);
if(isset($cw['.notdef']))
$info['MissingWidth'] = $cw['.notdef'];
else
$info['MissingWidth'] = 0;
$widths = array_fill(0, 256, $info['MissingWidth']);
for($c=0;$c<=255;$c++)
foreach($map as $c=>$v)
{
$name = $map[$c]['name'];
if($name!='.notdef')
if($v['name']!='.notdef')
{
if(isset($cw[$name]))
$widths[$c] = $cw[$name];
if(isset($cw[$v['name']]))
$widths[$c] = $cw[$v['name']];
else
Warning('Character '.$name.' is missing');
Warning('Character '.$v['name'].' is missing');
}
}
$info['Widths'] = $widths;
Expand Down Expand Up @@ -272,16 +294,61 @@ function MakeFontEncoding($map)
return rtrim($s);
}

function MakeUnicodeArray($map)
{
// Build mapping to Unicode values
$ranges = array();
foreach($map as $c=>$v)
{
$uv = $v['uv'];
if($uv!=-1)
{
if(isset($range))
{
if($c==$range[1]+1 && $uv==$range[3]+1)
{
$range[1]++;
$range[3]++;
}
else
{
$ranges[] = $range;
$range = array($c, $c, $uv, $uv);
}
}
else
$range = array($c, $c, $uv, $uv);
}
}
$ranges[] = $range;

foreach($ranges as $range)
{
if(isset($s))
$s .= ',';
else
$s = 'array(';
$s .= $range[0].'=>';
$nb = $range[1]-$range[0]+1;
if($nb>1)
$s .= 'array('.$range[2].','.$nb.')';
else
$s .= $range[2];
}
$s .= ')';
return $s;
}

function SaveToFile($file, $s, $mode)
{
$f = fopen($file, 'w'.$mode);
if(!$f)
Error('Can\'t write to file '.$file);
fwrite($f, $s, strlen($s));
fwrite($f, $s);
fclose($f);
}

function MakeDefinitionFile($file, $type, $enc, $embed, $map, $info)
function MakeDefinitionFile($file, $type, $enc, $embed, $subset, $map, $info)
{
$s = "<?php\n";
$s .= '$type = \''.$type."';\n";
Expand All @@ -294,6 +361,7 @@ function MakeDefinitionFile($file, $type, $enc, $embed, $map, $info)
$diff = MakeFontEncoding($map);
if($diff)
$s .= '$diff = \''.$diff."';\n";
$s .= '$uv = '.MakeUnicodeArray($map).";\n";
if($embed)
{
$s .= '$file = \''.$info['File']."';\n";
Expand All @@ -303,17 +371,21 @@ function MakeDefinitionFile($file, $type, $enc, $embed, $map, $info)
$s .= '$size2 = '.$info['Size2'].";\n";
}
else
{
$s .= '$originalsize = '.$info['OriginalSize'].";\n";
if($subset)
$s .= "\$subsetted = true;\n";
}
}
$s .= "?>\n";
SaveToFile($file, $s, 't');
}

function MakeFont($fontfile, $enc='cp1252', $embed=true)
function MakeFont($fontfile, $enc='cp1252', $embed=true, $subset=true)
{
// Generate a font definition file
if(get_magic_quotes_runtime())
@set_magic_quotes_runtime(0);
@set_magic_quotes_runtime(false);
ini_set('auto_detect_line_endings', '1');

if(!file_exists($fontfile))
Expand All @@ -329,7 +401,7 @@ function MakeFont($fontfile, $enc='cp1252', $embed=true)
$map = LoadMap($enc);

if($type=='TrueType')
$info = GetInfoFromTrueType($fontfile, $embed, $map);
$info = GetInfoFromTrueType($fontfile, $embed, $subset, $map);
else
$info = GetInfoFromType1($fontfile, $embed, $map);

Expand All @@ -346,19 +418,21 @@ function MakeFont($fontfile, $enc='cp1252', $embed=true)
else
{
$info['File'] = basename($fontfile);
$subset = false;
Notice('Font file could not be compressed (zlib extension not available)');
}
}

MakeDefinitionFile($basename.'.php', $type, $enc, $embed, $map, $info);
MakeDefinitionFile($basename.'.php', $type, $enc, $embed, $subset, $map, $info);
Message('Font definition file generated: '.$basename.'.php');
}

if(PHP_SAPI=='cli')
{
// Command-line interface
ini_set('log_errors', '0');
if($argc==1)
die("Usage: php makefont.php fontfile [enc] [embed]\n");
die("Usage: php makefont.php fontfile [encoding] [embed] [subset]\n");
$fontfile = $argv[1];
if($argc>=3)
$enc = $argv[2];
Expand All @@ -368,6 +442,10 @@ function MakeFont($fontfile, $enc='cp1252', $embed=true)
$embed = ($argv[3]=='true' || $argv[3]=='1');
else
$embed = true;
MakeFont($fontfile, $enc, $embed);
if($argc>=5)
$subset = ($argv[4]=='true' || $argv[4]=='1');
else
$subset = true;
MakeFont($fontfile, $enc, $embed, $subset);
}
?>
Loading