Roxen.git/
server/
font_handlers/
imagedir.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2000-09-04
2000-09-04 06:49:35 by Per Hedbor <ph@opera.com>
e89226b4c0453cf32719e5c0acd1b2354c1f15a8 (
34
lines) (+
27
/-
7
)
[
Show
|
Annotate
]
Branch:
5.2
Here be threads
Rev: server/font_handlers/imagedir.pike:1.3
Rev: server/font_handlers/ttf.pike:1.4
1:
#include <config.h> #include <stat.h>
-
constant cvs_version = "$Id: imagedir.pike,v 1.
2
2000/09/04
05
:
22
:
01
per Exp $";
+
constant cvs_version = "$Id: imagedir.pike,v 1.
3
2000/09/04
06
:
49
:
34
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)
");
+
"named after the character they will represent
.
Characters
"
+
"
with
codes
larger
than
127
or
less
than
48
are
encoded like
"
+
"0xHEX where HEX is the code in hexadecimal"
);
inherit FontHandler;
-
+
#ifdef THREADS
+
Thread.Mutex lock = Thread.Mutex();
+
#endif
+
static mapping nullchar = ([ "image":Image.Image(1,1), "alpha":Image.Image(1,1) ]); static mapping spacechar = ([ "image":Image.Image(10,1),
30:
static string encode_char( string c ) {
-
return
replace(
string_to_utf8(
c
),
-
(
{
"
.
",
"/"
}
)
,
-
({ "0x2e", "0x2f" }) )
;
+
int
cc
=
c
[0];
+
if(
(cc
<
48)
||
(cc
>
127)
)
return
sprintf
( "
0x%x
",
cc
)
;
+
return
c
;
} static mapping(string:Image.Image) load_char( string c )
41:
if(!files) files = get_dir( path ) - ({ "fontname" });
-
array possible = glob(encode_char( c )+"*", files);
+
array possible =
({ encode_char(c) })+
+
glob(encode_char( c )+"
.
*", files);
+
sort( map(possible,strlen), possible );
foreach( possible, string pf ) if( mapping r = Image._load( path+pf ) ) return r;
133:
array available_fonts() {
+
#ifdef THREADS
+
object key = lock->lock();
+
#endif
array res = ({}); if( !font_list ) update_font_list(); return indices( font_list );
140:
array(mapping) font_information( string fnt ) {
+
#ifdef THREADS
+
object key = lock->lock();
+
#endif
if( !font_list ) update_font_list(); if( font_list[ fnt ] ) return ({ ([
154:
array has_font( string name, int size ) {
+
#ifdef THREADS
+
object key = lock->lock();
+
#endif
if( !font_list ) update_font_list(); if( font_list[ name ] ) return ({ "nn" });
161:
Font open( string name, int size, int bold, int italic ) {
+
#ifdef THREADS
+
object key = lock->lock();
+
#endif
if( !font_list ) update_font_list(); if( font_list[ name ] ) return myFont( font_list[name], size );