Roxen.git
/
server
/
font_handlers
/
imagedir.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/font_handlers/imagedir.pike:1:
#include <config.h> #include <stat.h>
-
constant cvs_version = "$Id: imagedir.pike,v 1.
1
2000/09/04 05:
09
:
13
per Exp $";
+
constant cvs_version = "$Id: imagedir.pike,v 1.
2
2000/09/04 05:
22
:
01
per Exp $";
constant name = "Image directory fonts"; constant doc = ("Handles a directory with images (in almost any format), each " "named after the character they will represent (encoded with " "UTF8, and . replaced with 0x2e and / replaced with 0x2f)"); inherit FontHandler;
-
+
static mapping nullchar = ([ "image":Image.Image(1,1),
+
"alpha":Image.Image(1,1) ]);
+
static mapping spacechar = ([ "image":Image.Image(10,1),
+
"alpha":Image.Image(10,1) ]);
+
static mapping smallspacechar = ([ "image":Image.Image(2,1),
+
"alpha":Image.Image(2,1) ]);
class myFont { inherit Font; static string path; static int size, rsize;
-
static mapping nullchar = ([ "image":Image.Image(1,1),
-
"alpha":Image.Image(1,1) ]);
+
static array files; static string _sprintf() { return sprintf( "FontDir(%O,%d)", path, height() ); } static string encode_char( string c ) { return replace( string_to_utf8( c ), ({ ".", "/" }), ({ "0x2e", "0x2f" }) ); } static mapping(string:Image.Image) load_char( string c ) {
-
+
if( c[0] == 0x120 ) return smallspacechar;
if(!files) files = get_dir( path ) - ({ "fontname" }); array possible = glob(encode_char( c )+"*", files); foreach( possible, string pf ) if( mapping r = Image._load( path+pf ) ) return r;
-
+
if( c == " " ) return spacechar;
return nullchar; } mapping(string:mapping(string:Image.Image)) char_cache = ([]); static mapping(string:Image.Image) write_char( string c ) { if( char_cache[ c ] ) return char_cache[ c ]; return char_cache[ c ] = load_char( c ); } static Image.Image write_row( string text )