/usr/share/php/Imlib/class.ImlibText.php is in php-imlib 0.7-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | <?php
/**
* Does everything relevant to text drawing
*
* The routine for dealing text is to load a font, set an image to draw on,
* and draw a string.
*
* @version 0.3
* @author Matt McClanahan <cardinal@dodds.net>
* @package Imlib
* @access public
*/
class ImlibText extends ImlibColor
{
/**
* Resource id# of the currently loaded font
*
* @access private
*/
var $fnt;
/**
* Resource id# of the image to draw on
*
* @access private
*/
var $im;
/**
* ImlibText constructor
*
* @access public
*/
function ImlibText()
{
$this->fnt = 0;
$this->im = 0;
}
/**
* Draw a text string onto the current image
*
* @param int X coordinate of the upper left corner of the string
* @param int Y coordinate of the upper left corner of the string
* @param string Text string to draw
* @param int Direction of the text
* @return bool False if no font is loaded
* @access public
*/
function draw($x,$y,$str,$dir=IMLIB_TEXT_TO_RIGHT)
{
if (!is_resource($this->fnt) || !is_resource($this->im))
return false;
// If we don't have a color set yet, we'll default to white
if (!$this->get_color($r,$g,$b,$a))
list($r,$g,$b,$a) = Array(255,255,255,255);
return imlib_text_draw($this->im,$this->fnt,$x,$y,$str,$dir,
$r,$g,$b,$a);
}
/**
* Free the currently loaded font
*
* @return bool False if no font is loaded
* @access public
*/
function free()
{
if (!is_resource($this->fnt))
return false;
imlib_free_font($this->fnt);
$this->fnt = 0;
}
/**
* Get the current image resource id#
*
* @return integer Image resource id#
* @access public
*/
function get_image()
{
return $this->im;
}
/**
* Get the width and height of a given string if it were drawn
*
* @param string String to measure
* @param int &$w Width the string would be
* @param int &$h Height the string would be
* @param int Direction to measure the string
* @return bool False if no font is loaded
* @access public
*/
function get_size($str,&$w,&$h,$dir=IMLIB_TEXT_TO_RIGHT)
{
if (!is_resource($this->fnt))
return false;
return imlib_get_text_size($this->fnt,$str,$fw,$fh,$dir);
}
/**
* Load a font
*
* If the font is in the font path, it can be referred to by font name,
* and the path does not need to be specified. Otherwise, it must be
* referred to by filename.
*
* @param string Path, or current directory if passed blank
* @param string Font name
* @param int Font size
* @return bool False if no font is loaded
* @access public
*/
function load($path,$font,$size)
{
$fontdata = '';
if (is_resource($this->fnt))
return false;
if ($path)
$fontdata = $path;
$fontdata .= $font . '/' . $size;
return $this->fnt = imlib_load_font($fontdata);
}
/**
* Set the image resource id# to draw on
*
* @param int Image resource id#
* @access public
*/
function set_image($im)
{
$this->im = $im;
}
};
?>
|