Add a "setDefaultFontSize" function to lpdf, and set it to something reasonable for backwards compatability

Update lpdf's table functions to honour the default font size setting.

(this works great, except for the column widths -  if you choose a font-size too big, its not oging to fit in the pre-defined column widths.)
This commit is contained in:
james 2010-03-23 16:42:59 +00:00
parent b34ad909b5
commit ea58b4b6a8
2 changed files with 30 additions and 11 deletions

View File

@ -71,8 +71,14 @@
$report_options['label_logo'] = array('desc' => 'Print the fair logo at the top of each label',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
$report_options['default_font_size'] = array('desc' => 'Default font size to use in the report',
'values' => array(
'10'=>'10',
'11'=>'11', '12'=>'12',
'13'=>'13', '14'=>'14', '15'=>'15', '16'=>'16', '18'=>'18',
'20'=>'20', '22'=>'22', '24'=>'24'
)
);
/*
@ -558,7 +564,15 @@ foreach($report_stock as $n=>$v) {
i18n($report['name']),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo.gif");
$rep->newPage($label_stock['page_width'], $label_stock['page_height']);
$rep->setFontSize(11);
if($report['option']['default_font_size']) {
$rep->setDefaultFontSize($report['option']['default_font_size']);
$rep->setFontSize($report['option']['default_font_size']);
}
else {
$rep->setDefaultFontSize(11);
$rep->setFontSize(11);
}
$gen_mode = 'table';
if($report['option']['allow_multiline'] == 'yes')
$table['option']['allow_multiline'] = true;

View File

@ -55,6 +55,7 @@ class lpdf
var $current_label_row_index=1;
var $currentFontSize=12;
var $defaultFontSize=10;
var $normalfont;
var $boldfont;
@ -146,6 +147,10 @@ class lpdf
$this->yloc-=$space;
}
function setDefaultFontSize($size) {
$this->defaultFontSize=$size;
}
function setFontSize($size)
{
$this->currentFontSize=$size;
@ -573,7 +578,7 @@ class lpdf
if($this->yloc< (1.1 + 12/72 + 4/72) )
$this->newPage();
pdf_setfont($this->pdf,$this->headerfont,12);
pdf_setfont($this->pdf,$this->headerfont, round($this->defaultFontSize*1.2));
$this->addText($text,"left",0,"headerfont");
pdf_setfont($this->pdf,$this->normalfont,$this->currentFontSize);
//now leave some space under the heading (4 is 1/3 of 12, so 1/3 of the line height we leave)
@ -586,7 +591,7 @@ class lpdf
{
if(is_array($table['header'])) {
$table_cols=count($table['header']);
$height_header=0.2;
$height_header=round(round($this->defaultFontSize*1.2)/50,2);
} else {
$table_cols=count($table['data']);
$height_header=0;
@ -609,7 +614,7 @@ class lpdf
pdf_stroke($this->pdf);
$xpos=$xpos_of_table;
pdf_setfont($this->pdf,$this->headerfont,12);
pdf_setfont($this->pdf,$this->headerfont,round($this->defaultFontSize*1.2));
for($c=0;$c<$table_cols;$c++)
{
@ -619,7 +624,7 @@ class lpdf
pdf_show_boxed($this->pdf,$head,$this->loc($xpos),$this->loc($this->yloc),$this->loc($width),$this->loc($height_header),"center",null);
$xpos+=$width;
}
pdf_setfont($this->pdf,$this->normalfont,10);
pdf_setfont($this->pdf,$this->normalfont,$this->defaultFontSize);
}
return $top_of_table;
@ -629,7 +634,7 @@ class lpdf
{
if(is_array($table['header'])) {
$table_cols=count($table['header']);
$height_header=0.2;
$height_header=round(round($this->defaultFontSize*1.2)/50,2);
} else {
$table_cols=count($table['data']);
$height_header=0;
@ -664,7 +669,7 @@ class lpdf
} else {
$table_cols=count($table['data']);
}
$line_height=0.18;
$line_height=round(round($this->defaultFontSize)/64,2);
$table_width=array_sum($table['widths']);
$table_padding=0.03;
@ -686,7 +691,7 @@ class lpdf
//now do the data in the table
if($table['data'])
{
pdf_setfont($this->pdf,$this->normalfont,10);
pdf_setfont($this->pdf,$this->normalfont,$this->defaultFontSize);
foreach($table['data'] AS $dataline)
{
// $this->yloc-=$line_height;
@ -775,7 +780,7 @@ class lpdf
$this->loc($xpos+$width-0.10),$this->loc($this->yloc-$line_height-0.05),
$this->loc(0.10),$this->loc($line_height),
$table['dataalign'][$c],null);
pdf_setfont($this->pdf,$this->normalfont,10);
pdf_setfont($this->pdf,$this->normalfont,$this->defaultFontSize);
}
$xpos+=$width;