Qual: Can externalize fonts.

This commit is contained in:
Laurent Destailleur 2011-08-14 18:25:15 +00:00
parent d6bb618dfe
commit 2409c7fbfd
14 changed files with 1224 additions and 1175 deletions

View File

@ -6,8 +6,3 @@ embedded-javascript-library usr/share/dolibarr/htdocs/includes/fckeditor/fckedit
embedded-php-library usr/share/dolibarr/htdocs/includes/magpierss/extlib/Snoopy.class.inc
embedded-php-library usr/share/dolibarr/htdocs/includes/magpierss/rss_parse.inc
embedded-php-library usr/share/dolibarr/htdocs/includes/nusoap/lib/nusoap.php
# embedded fonts, wich are specific to Dolibarr usage
font-in-non-font-package usr/share/dolibarr/htdocs/includes/artichow/font/Tuffy.ttf
font-in-non-font-package usr/share/dolibarr/htdocs/includes/artichow/font/TuffyBold.ttf
font-in-non-font-package usr/share/dolibarr/htdocs/includes/artichow/font/TuffyBoldItalic.ttf
font-in-non-font-package usr/share/dolibarr/htdocs/includes/artichow/font/TuffyItalic.ttf

View File

@ -2,7 +2,7 @@
#----------------------------------------------------------------------------
# \file build/makepack-dolibarr.pl
# \brief Dolibarr package builder (tgz, zip, rpm, deb, exe, aps)
# \version $Id: makepack-dolibarr.pl,v 1.144 2011/08/14 17:17:20 eldy Exp $
# \version $Id: makepack-dolibarr.pl,v 1.145 2011/08/14 18:26:21 eldy Exp $
# \author (c)2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
#----------------------------------------------------------------------------
@ -45,7 +45,7 @@ if (-d "/usr/src/RPM") { $RPMDIR="/usr/src/RPM"; } # mandrake
use vars qw/ $REVISION $VERSION /;
$REVISION='$Revision: 1.144 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
$REVISION='$Revision: 1.145 $'; $REVISION =~ /\s(.*)\s/; $REVISION=$1;
$VERSION="3.2 (build $REVISION)";
@ -503,6 +503,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/zip`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/build/perl`;
# We remove embedded libraries or fonts
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/artichow/font`,
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/fonts`,
#$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`;
$ret=`rm -fr $BUILDROOT/$FILENAMETGZ2/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip/gnu-lgpl.txt`;
@ -703,6 +704,7 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/rpm`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/zip`;
# We remove embedded libraries or fonts
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/artichow/font`,
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/barcode/php-barcode/fonts`,
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
$ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`;

View File

@ -20,7 +20,7 @@
* \file htdocs/core/class/dolgraph.class.php
* \ingroup core
* \brief Fichier de la classe mere de gestion des graph
* \version $Id: dolgraph.class.php,v 1.7 2011/07/31 23:45:15 eldy Exp $
* \version $Id: dolgraph.class.php,v 1.8 2011/08/14 18:26:26 eldy Exp $
*
* Usage:
* $graph_data = array(array('labelA',yA),array('labelB',yB));
@ -415,6 +415,7 @@ class DolGraph
*/
function draw_artichow($file)
{
global $artichow_defaultfont;
dol_syslog("DolGraph.class::draw_artichow this->type=".$this->type);
if (! defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP',3);
@ -442,7 +443,8 @@ class DolGraph
if (isset($this->title))
{
$graph->title->set($this->title);
$graph->title->setFont(new Tuffy(10));
//print $artichow_defaultfont;exit;
$graph->title->setFont(new $artichow_defaultfont(10));
}
if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor);
@ -555,7 +557,7 @@ class DolGraph
//$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures
$group->legend->setTextFont(new Tuffy(10)); // This is to force Artichow to use awFileFontDriver to
$group->legend->setTextFont(new $artichow_defaultfont(10)); // This is to force Artichow to use awFileFontDriver to
// solve a bug in Artichow with UTF8
if (sizeof($this->Legend))
{
@ -568,7 +570,7 @@ class DolGraph
}
$group->axis->bottom->setLabelText($legends);
$group->axis->bottom->label->setFont(new Tuffy(7));
$group->axis->bottom->label->setFont(new $artichow_defaultfont(7));
//print $group->axis->bottom->getLabelNumber();
if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval);

View File

@ -69,11 +69,19 @@ define('ARTICHOW_DEPRECATED', TRUE);
/*
* Fonts to use
*/
$fonts = array(
// DOL_CHANGE LDR
if (defined('ARTICHOW_FONT_NAMES')) $fonts=explode(',',constant('ARTICHOW_FONT_NAMES'));
else $fonts = array(
'Tuffy',
'TuffyBold',
'TuffyBoldItalic',
'TuffyItalic'
);
global $artichow_defaultfont;
$artichow_defaultfont=$fonts[0];
//var_dump(ARTICHOW_FONT);
//var_dump($fonts);
//var_dump($artichow_defaultfont);
//exit;
?>

View File

@ -158,6 +158,9 @@ registerClass('ComponentGroup', TRUE);
* Build the component
*/
function awComponent() {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
// Component legend
$this->legend = new awLegend();
@ -168,7 +171,7 @@ registerClass('ComponentGroup', TRUE);
// Component title
$this->title = new awLabel(
NULL,
new awTuffy(10),
new $classfontname(10),
NULL,
0
);

View File

@ -87,6 +87,10 @@ class awGraph extends awImage {
*/
function awGraph($width = NULL, $height = NULL, $name = NULL, $timeout = 0) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
parent::awImage();
$this->setSize($width, $height);
@ -125,7 +129,7 @@ class awGraph extends awImage {
$this->title = new awLabel(
NULL,
new awTuffy(16),
new $classfontname(16),
NULL,
0
);

View File

@ -228,6 +228,9 @@ class awMathPlot extends awComponent {
}
function initAxis(&$axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->setLabelPrecision(1);
$axis->addTick('major', new awTick(0, 5));
@ -235,7 +238,7 @@ class awMathPlot extends awComponent {
$axis->addTick('micro', new awTick(0, 1));
$axis->setNumberByTick('minor', 'major', 1);
$axis->setNumberByTick('micro', 'minor', 4);
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
}

View File

@ -157,6 +157,9 @@ define("PLOT_BOTH", 'both');
*
*/
function awPlot() {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
parent::awComponent();
@ -169,7 +172,7 @@ define("PLOT_BOTH", 'both');
$this->xAxis->addTick('major', new awTick(0, 5));
$this->xAxis->addTick('minor', new awTick(0, 3));
$this->xAxis->setTickStyle(TICK_OUT);
$this->xAxis->label->setFont(new awTuffy(7));
$this->xAxis->label->setFont(new $classfontname(7));
$this->yAxis = new awAxis;
$this->yAxis->auto(TRUE);
@ -177,7 +180,7 @@ define("PLOT_BOTH", 'both');
$this->yAxis->addTick('minor', new awTick(0, 3));
$this->yAxis->setTickStyle(TICK_OUT);
$this->yAxis->setNumberByTick('minor', 'major', 3);
$this->yAxis->label->setFont(new awTuffy(7));
$this->yAxis->label->setFont(new $classfontname(7));
$this->yAxis->title->setAngle(90);
}
@ -772,19 +775,25 @@ class awPlotAxis {
}
function xAxis(&$axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->addTick('major', new awTick(0, 5));
$axis->addTick('minor', new awTick(0, 3));
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
}
function yAxis(&$axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->addTick('major', new awTick(0, 5));
$axis->addTick('minor', new awTick(0, 3));
$axis->setNumberByTick('minor', 'major', 3);
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
$axis->title->setAngle(90);
}

View File

@ -159,6 +159,10 @@ abstract class awComponent {
*/
public function __construct() {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
// Component legend
$this->legend = new awLegend();
@ -168,7 +172,7 @@ abstract class awComponent {
// Component title
$this->title = new awLabel(
NULL,
new awTuffy(10),
new $classfontname(10),
NULL,
0
);

View File

@ -92,6 +92,10 @@ class awGraph extends awImage {
*/
public function __construct($width = NULL, $height = NULL, $name = NULL, $timeout = 0) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
parent::__construct();
$this->setSize($width, $height);
@ -130,7 +134,7 @@ class awGraph extends awImage {
$this->title = new awLabel(
NULL,
new awTuffy(16),
new $classfontname(16),
NULL,
0
);

View File

@ -228,6 +228,9 @@ class awMathPlot extends awComponent {
}
protected function initAxis(awAxis $axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->setLabelPrecision(1);
$axis->addTick('major', new awTick(0, 5));
@ -235,7 +238,7 @@ class awMathPlot extends awComponent {
$axis->addTick('micro', new awTick(0, 1));
$axis->setNumberByTick('minor', 'major', 1);
$axis->setNumberByTick('micro', 'minor', 4);
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
}

View File

@ -157,6 +157,9 @@ abstract class awPlot extends awComponent {
*
*/
public function __construct() {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
parent::__construct();
@ -169,7 +172,7 @@ abstract class awPlot extends awComponent {
$this->xAxis->addTick('major', new awTick(0, 5));
$this->xAxis->addTick('minor', new awTick(0, 3));
$this->xAxis->setTickStyle(awTick::OUT);
$this->xAxis->label->setFont(new awTuffy(7));
$this->xAxis->label->setFont(new $classfontname(7));
$this->yAxis = new awAxis;
$this->yAxis->auto(TRUE);
@ -177,7 +180,7 @@ abstract class awPlot extends awComponent {
$this->yAxis->addTick('minor', new awTick(0, 3));
$this->yAxis->setTickStyle(awTick::OUT);
$this->yAxis->setNumberByTick('minor', 'major', 3);
$this->yAxis->label->setFont(new awTuffy(7));
$this->yAxis->label->setFont(new $classfontname(7));
$this->yAxis->title->setAngle(90);
}
@ -776,19 +779,25 @@ class awPlotAxis {
}
protected function xAxis(awAxis $axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->addTick('major', new awTick(0, 5));
$axis->addTick('minor', new awTick(0, 3));
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
}
protected function yAxis(awAxis $axis) {
// DOL_CHANGE LDR Fix to allow usage of other fonts
global $artichow_defaultfont;
$classfontname='aw'.str_replace('-','_',$artichow_defaultfont);
$axis->addTick('major', new awTick(0, 5));
$axis->addTick('minor', new awTick(0, 3));
$axis->setNumberByTick('minor', 'major', 3);
$axis->label->setFont(new awTuffy(7));
$axis->label->setFont(new $classfontname(7));
$axis->title->setAngle(90);
}

View File

@ -269,8 +269,9 @@ $php = '';
foreach($fonts as $font) {
// DOL_CHANGE LDR Fix to allow - into font names
$php .= '
class aw'.$font.' extends awTTFFont {
class aw'.str_replace('-','_',$font).' extends awTTFFont {
public function __construct($size) {
parent::__construct(\''.(ARTICHOW_FONT.DIRECTORY_SEPARATOR.$font.'.ttf').'\', $size);
@ -281,7 +282,7 @@ foreach($fonts as $font) {
if(ARTICHOW_PREFIX !== 'aw') {
$php .= '
class '.ARTICHOW_PREFIX.$font.' extends aw'.$font.' {
class '.ARTICHOW_PREFIX.str_replace('-','_',$font).' extends aw'.str_replace('-','_',$font).' {
}
';
}

View File

@ -29,7 +29,7 @@
* \ingroup core
* \brief File that defines environment for all Dolibarr process (pages or scripts)
* This script reads the conf file, init $lang, $db and and empty $user
* \version $Id: master.inc.php,v 1.355 2011/08/14 17:17:20 eldy Exp $
* \version $Id: master.inc.php,v 1.356 2011/08/14 18:26:15 eldy Exp $
*/
@ -301,7 +301,9 @@ if (! defined('NUSOAP_PATH')) { define('NUSOAP_PATH', DOL_DOCUME
if (! defined('PHPEXCEL_PATH')) { define('PHPEXCEL_PATH', DOL_DOCUMENT_ROOT .'/includes/phpexcel/'); }
if (! defined('ODTPHP_PATH')) { define('ODTPHP_PATH', empty($dolibarr_lib_ODTPHP_PATH)?DOL_DOCUMENT_ROOT.'/includes/odtphp/':$dolibarr_lib_ODTPHP_PATH.'/'); }
if (! defined('ODTPHP_PATHTOPCLZIP')) { define('ODTPHP_PATHTOPCLZIP', empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP)?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/':$dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/'); }
if (! defined('ARTICHOW_FONT')) { define('ARTICHOW_FONT', empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?DOL_DOCUMENT_ROOT.'/includes/artichow/font':dirname($dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
// Other required path
if (! defined('ARTICHOW_FONT_NAMES')) { define('ARTICHOW_FONT_NAMES', empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?'Tuffy,TuffyBold,TuffyBoldItalic,TuffyItalic':'DejaVuSans,DejaVuSans-Bold,DejaVuSans-BoldOblique,DejaVuSans-Oblique'); }
if (! defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', empty($dolibarr_font_DOL_DEFAULT_TTF)?DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/fonts/Aerial.ttf':$dolibarr_font_DOL_DEFAULT_TTF); }
if (! defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/fonts/AerialBd.ttf':$dolibarr_font_DOL_DEFAULT_TTF_BOLD); }
if (! defined('MAGPIE_DIR')) { define('MAGPIE_DIR', MAGPIERSS_PATH); }