mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
🎨 replace TCPPDF:SetFont calls by iTopPDF::SetFontParams
This ensures that the same font is used in every caller
This commit is contained in:
@@ -13,18 +13,22 @@ class iTopPDF extends TCPDF
|
||||
protected $sDocumentTitle;
|
||||
|
||||
/**
|
||||
* Shortcut to set only weight and size
|
||||
* Shortcut for {@link TCPDF::SetFont}, to use the font configured
|
||||
*
|
||||
* @param string $style
|
||||
* @param int $size
|
||||
* @param string $fontfile
|
||||
* @param string $subset
|
||||
* @param bool $out
|
||||
*
|
||||
* @uses \TCPDF::SetFont()
|
||||
* @uses \iTopPDF::GetPdfFont()
|
||||
* @since 2.7
|
||||
*/
|
||||
public function SetFontParams($style, $size)
|
||||
public function SetFontParams($style, $size, $fontfile='', $subset='default', $out=true)
|
||||
{
|
||||
$siTopFont = self::GetPdfFont();
|
||||
$this->SetFont($siTopFont, $style, $size);
|
||||
$this->SetFont($siTopFont, $style, $size, $fontfile, $subset, $out);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,6 +92,7 @@ class iTopPDF extends TCPDF
|
||||
}
|
||||
|
||||
/**
|
||||
* dejavusans is a UTF-8 Unicode font. Standard PDF fonts like helvetica or times new roman are NOT UTF-8
|
||||
* @return string font in the config file (export_pdf_font)
|
||||
*/
|
||||
public static function GetPdfFont()
|
||||
@@ -121,9 +126,8 @@ class PDFPage extends WebPage
|
||||
|
||||
$this->oPdf->setFontSubsetting(true);
|
||||
|
||||
// Set font
|
||||
// dejavusans is a UTF-8 Unicode font. Standard PDF fonts like helvetica or times new roman are NOT UTF-8
|
||||
$this->oPdf->SetFont(iTopPDF::GetPdfFont(), '', 10, '', true);
|
||||
$this->oPdf->SetFontParams('', 10, '', true);
|
||||
|
||||
// set auto page breaks
|
||||
$this->oPdf->SetAutoPageBreak(true, 15); // 15 mm break margin at the bottom
|
||||
|
||||
@@ -111,7 +111,7 @@ class DisplayableNode extends GraphNode
|
||||
return $aNode;
|
||||
}
|
||||
|
||||
public function RenderAsPDF(TCPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
public function RenderAsPDF(iTopPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
{
|
||||
$Alpha = 1.0;
|
||||
$oPdf->SetFillColor(200, 200, 200);
|
||||
@@ -162,8 +162,7 @@ class DisplayableNode extends GraphNode
|
||||
}
|
||||
}
|
||||
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 24 * $fScale, '', true);
|
||||
$oPdf->SetFontParams('', 24 * $fScale, '', true);
|
||||
$width = $oPdf->GetStringWidth($this->GetProperty('label'));
|
||||
$height = $oPdf->GetStringHeight(1000, $this->GetProperty('label'));
|
||||
$oPdf->setAlpha(0.6 * $Alpha);
|
||||
@@ -533,7 +532,7 @@ class DisplayableRedundancyNode extends DisplayableNode
|
||||
return $aNode;
|
||||
}
|
||||
|
||||
public function RenderAsPDF(TCPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
public function RenderAsPDF(iTopPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
{
|
||||
$oPdf->SetAlpha(1);
|
||||
if($this->GetProperty('is_reached_count') > $this->GetProperty('threshold'))
|
||||
@@ -548,8 +547,7 @@ class DisplayableRedundancyNode extends DisplayableNode
|
||||
$oPdf->Circle($this->x*$fScale, $this->y*$fScale, 16*$fScale, 0, 360, 'DF');
|
||||
|
||||
$oPdf->SetTextColor(255, 255, 255);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 28 * $fScale, '', true);
|
||||
$oPdf->SetFontParams('', 28 * $fScale, '', true);
|
||||
$sLabel = (string)$this->GetProperty('label');
|
||||
$width = $oPdf->GetStringWidth($sLabel, iTopPDF::GetPdfFont(), 'B', 24 * $fScale);
|
||||
$height = $oPdf->GetStringHeight(1000, $sLabel);
|
||||
@@ -766,7 +764,7 @@ class DisplayableGroupNode extends DisplayableNode
|
||||
return $aNode;
|
||||
}
|
||||
|
||||
public function RenderAsPDF(TCPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
public function RenderAsPDF(iTopPDF $oPdf, DisplayableGraph $oGraph, $fScale, $aContextDefs)
|
||||
{
|
||||
$bReached = $this->GetProperty('is_reached');
|
||||
$oPdf->SetFillColor(255, 255, 255);
|
||||
@@ -796,8 +794,7 @@ class DisplayableGroupNode extends DisplayableNode
|
||||
$oPdf->Image($sIconPath, ($this->x - 17)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$oPdf->Image($sIconPath, ($this->x + 1)*$fScale, ($this->y - 17)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$oPdf->Image($sIconPath, ($this->x -8)*$fScale, ($this->y +1)*$fScale, 16*$fScale, 16*$fScale);
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', 24 * $fScale, '', true);
|
||||
$oPdf->SetFontParams('', 24 * $fScale, '', true);
|
||||
$width = $oPdf->GetStringWidth($this->GetProperty('label'));
|
||||
$oPdf->SetTextColor(0, 0, 0);
|
||||
$oPdf->Text($this->x*$fScale - $width/2, ($this->y + 25)*$fScale, $this->GetProperty('label'));
|
||||
@@ -1288,7 +1285,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
* @param hash $aContextDefs
|
||||
* @return hash An array ('xmin' => , 'xmax' => ,'ymin' => , 'ymax' => ) of the remaining available area to paint the graph
|
||||
*/
|
||||
protected function RenderKey(TCPDF $oPdf, $sComments, $xMin, $yMin, $xMax, $yMax, $aContextDefs)
|
||||
protected function RenderKey(iTopPDF $oPdf, $sComments, $xMin, $yMin, $xMax, $yMax, $aContextDefs)
|
||||
{
|
||||
$fFontSize = 7; // in mm
|
||||
$fIconSize = 6; // in mm
|
||||
@@ -1299,8 +1296,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$aIcons = array();
|
||||
$aContexts = array();
|
||||
$aContextIcons = array();
|
||||
$siTopFont = iTopPDF::GetPdfFont();
|
||||
$oPdf->SetFont($siTopFont, '', $fFontSize, '', true);
|
||||
$oPdf->SetFontParams('', $fFontSize, '', true);
|
||||
foreach($oIterator as $sId => $oNode)
|
||||
{
|
||||
if ($sClass = $oNode->GetObjectClass())
|
||||
|
||||
Reference in New Issue
Block a user