Source for file Font.class.php
Documentation is available at Font.class.php
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
require_once dirname(__FILE__ ). "/../Graph.class.php";
* Common font characteristics and methods.
* Declared abstract only so that it can't be instanciated.
* Users have to call 'new awPHPFont' or 'new awFileFont',
* or any of their inherited classes (awFont1, awTuffy, awTTFFont, etc.)
* @package linea21.externals
* @param $p Draw text at this point
* @param int $width Text box width
function draw($driver, $point, &$text, $width = NULL) {
$driver->string($this, $text, $point, $width);
* Class for fonts that cannot be transformed,
* like the built-in PHP fonts for example.
* @package linea21.externals
* The used font identifier
function awPHPFont($font = NULL) {
$this->font = (int) $font;
* Class for fonts that can be transformed (rotated, skewed, etc.),
* like TTF or FDB fonts for example.
* @package linea21.externals
* The name of the font, without the extension
* The font filename extension
function awFileFont($name, $size) {
* Set the name of the font. The $name variable can contain the full path,
* or just the filename. Artichow will try to do The Right Thing,
* as well as set the extension property correctly if possible.
if(strpos($fontInfo['dirname'], '/') !== 0) {
// Path is not absolute, use ARTICHOW_FONT
$this->name = $fontInfo['dirname']. DIRECTORY_SEPARATOR. $fontInfo['basename'];
if(array_key_exists('extension', $fontInfo) and $fontInfo['extension'] !== '') {
* Return the name of the font, i.e. the absolute path and the filename, without the extension.
* Set the size of the font, in pixels
$this->size = (int) $size;
* Return the size of the font, in pixels
* Set the extension, without the dot
* @param string $extension
* Get the filename extension for that font
* Class representing TTF fonts
* @package linea21.externals
function awTTFFont($name, $size) {
parent::awFileFont($name, $size);
for($i = 1; $i <= 5; $i++ ) {
class awFont'. $i. ' extends awPHPFont {
function awFont'. $i. '() {
parent::awPHPFont('. $i. ');
foreach($fonts as $font) {
class aw'. $font. ' extends awFileFont {
function aw'. $font. '($size) {
parent::awFileFont(\''. $font. '\', $size);
* Environment modification for GD2 and TTF fonts
|