annotate Gui/skin/font.c @ 9913:88fe89b46786

Add suffix support to the object list type. So now -vf-clr destroy the list -vf-add filer1=blah,filter append these 2 filters, -vf-pre ... will 'prepend' them. Finnaly -vf-del 2,3,-1 will delete the filters at at given indexs It start from 0, negative number start from the end of the list (so -1 is the last one).
author albeu
date Sat, 12 Apr 2003 13:45:43 +0000
parents bc24dd70c6e2
children 9a495bdc3a1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
2 #include <stdlib.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 #include <stdio.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
4 #include <stdarg.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5 #include <string.h>
6166
82f770634c5b inttypes gui patch from Bjrn Sandell <biorn@dce.chalmers.se>
pontscho
parents: 6159
diff changeset
6 #include <inttypes.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
7
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
8 #include "../app.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 #include "skin.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 #include "font.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
11 #include "cut.h"
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
12 #include "../../mp_msg.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14 int items;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
16 bmpFont * Fonts[26] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18 int fntAddNewFont( char * name )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20 int id;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
21 int i;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
22
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
23 for( id=0;id<26;id++ )
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
24 if ( !Fonts[id] ) break;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
25
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
26 if ( id == 25 ) return -2;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
27
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
28 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
29
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30 strcpy( Fonts[id]->name,name );
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
31 for ( i=0;i<256;i++ )
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
32 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
33
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 return id;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
36
1829
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
37 void fntFreeFont( void )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
38 {
1829
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
39 int i;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
40 for( i=0;i < 25;i++ )
1829
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
41 {
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
42 if ( Fonts[i] )
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
43 {
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
44 if ( Fonts[i]->Bitmap.Image ) free( Fonts[i]->Bitmap.Image );
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
45 free( Fonts[i] );
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
46 Fonts[i]=NULL;
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
47 }
a4156c8cdd57 add font free func.
pontscho
parents: 1693
diff changeset
48 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
51 int fntRead( char * path,char * fname )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 FILE * f;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 unsigned char tmp[512];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 unsigned char * ptmp;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 unsigned char command[32];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 unsigned char param[256];
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
58 int c,linenumber = 0;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
59 int id = fntAddNewFont( fname );
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
60
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
61 if ( id < 0 ) return id;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 strcpy( tmp,path ); strcat( tmp,fname ); strcat( tmp,".fnt" );
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
64 if ( ( f=fopen( tmp,"rt" ) ) == NULL )
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
65 { free( Fonts[id] ); return -3; }
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
66
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 while ( !feof( f ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
69 fgets( tmp,255,f ); linenumber++;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
73 for ( c=0;c < (int)strlen( tmp );c++ )
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
74 if ( tmp[c] == ';' ) { tmp[c]=0; break; }
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
75 if ( !tmp[0] ) continue;
8973
0a665389cf2b - add playbar
pontscho
parents: 8883
diff changeset
76 ptmp=trimleft( tmp );
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
77 if ( !tmp[0] ) continue;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 ptmp=strswap( ptmp,'\t',' ' );
8973
0a665389cf2b - add playbar
pontscho
parents: 8883
diff changeset
79 ptmp=trim( ptmp );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 if ( command[0] == '"' )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
84 cutItem( command,command,'"',1 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 i=(int)command[0];
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 cutItem( param,tmp,',',0 ); Fonts[id]->Fnt[i].x=atoi( tmp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87 cutItem( param,tmp,',',1 ); Fonts[id]->Fnt[i].y=atoi( tmp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 cutItem( param,tmp,',',2 ); Fonts[id]->Fnt[i].sx=atoi( tmp );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 cutItem( param,tmp,',',3 ); Fonts[id]->Fnt[i].sy=atoi( tmp );
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
90 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] char: '%s' params: %d,%d %dx%d\n",command,Fonts[id]->Fnt[i].x,Fonts[id]->Fnt[i].y,Fonts[id]->Fnt[i].sx,Fonts[id]->Fnt[i].sy );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 else
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 if ( !strcmp( command,"image" ) )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96 strcpy( tmp,path ); strcat( tmp,param );
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
97 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp );
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
98 if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -4;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100 }
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
101 }
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
102
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103 return 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
105
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106 int fntFindID( char * name )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 int i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
109 for ( i=0;i < 25;i++ )
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
110 if ( Fonts[i] )
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
111 if ( !strcmp( name,Fonts[i]->name ) ) return i;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
113 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
114
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
115 int fntTextWidth( int id,char * str )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
116 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
117 int size = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 int i;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
119
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
120 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
121
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
122 for ( i=0;i < (int)strlen( str );i++ )
7353
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
123 {
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
124 unsigned char c = (unsigned char)str[i];
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
125 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
126 size+= Fonts[id]->Fnt[ c ].sx;
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
127 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 return size;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131 int fntTextHeight( int id,char * str )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 int max = 0,i;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
134
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
135 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
136
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
137 for ( i=0;i < (int)strlen( str );i++ )
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
138 {
7353
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
139 int h;
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
140 unsigned char c = (unsigned char)str[i];
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
141 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
0cb951ac0133 Use the character substitution code from fntRender() / fntTextWidth()
jkeil
parents: 6218
diff changeset
142 h = Fonts[id]->Fnt[c].sy;
6218
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
143 if ( h > max ) max=h;
8cfddba867b4 fix text render chrash ...
pontscho
parents: 6166
diff changeset
144 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 return max;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
146 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
148 txSample * fntRender( wItem * item,int px,char * fmt,... )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
149 {
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
150 txSample * tmp = NULL;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
151 va_list ap;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
152 unsigned char p[512];
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
153 unsigned int c;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
154 int i, dx = 0, s, tw, fbw, iw, id, ofs;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
155 int x,y,fh,fw,fyc,yc;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
156 uint32_t * ibuf;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
157 uint32_t * obuf;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
158
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
159 va_start( ap,fmt );
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
160 vsnprintf( p,512,fmt,ap );
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
161 va_end( ap );
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
162
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
163 iw=item->width;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
164 id=item->fontid;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
165
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
166 if ( ( !item )||
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
167 ( !Fonts[id] )||
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
168 ( !p[0] )||
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
169 ( !fntTextWidth( id,p ) ) ) return NULL;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
170
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
171 tw=fntTextWidth( id,p );
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
172 fbw=Fonts[id]->Bitmap.Width;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
173
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
174 if ( item->Bitmap.Image == NULL )
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
175 {
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
176 item->Bitmap.Height=item->height=fntTextHeight( id,p );
9625
bc24dd70c6e2 many 10l for me ...
pontscho
parents: 8978
diff changeset
177 item->Bitmap.Width=item->width=iw;
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
178 item->Bitmap.ImageSize=item->height * iw * 4;
8978
pontscho
parents: 8973
diff changeset
179 if ( !item->Bitmap.ImageSize ) return NULL;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
180 item->Bitmap.BPP=32;
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
181 item->Bitmap.Image=malloc( item->Bitmap.ImageSize );
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
182 }
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
183
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
184 obuf=(uint32_t *)item->Bitmap.Image;
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
185 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
186
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
187 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff;
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
188
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
189 if ( tw <= iw )
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
190 {
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
191 switch ( item->align )
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
192 {
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
193 default:
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
194 case fntAlignLeft: dx=0; break;
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
195 case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
196 case fntAlignRight: dx=iw - fntTextWidth( id,p ); break;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
197 }
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
198
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
199 } else dx+=px;
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
200
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
201 ofs=dx;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
202
4818
3473ca9ef158 new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents: 1907
diff changeset
203 for ( i=0;i < (int)strlen( p );i++ )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
204 {
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
205 c=(unsigned int)p[i];
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
206 fw=Fonts[id]->Fnt[c].sx;
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
207
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
208 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
8864
b8c271750450 - sync with x11_common
pontscho
parents: 7353
diff changeset
209
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
210 fh=Fonts[id]->Fnt[c].sy;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
211 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
212 yc=dx;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
213
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
214 if ( dx >= 0 )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
215 for ( y=0;y < fh;y++ )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
216 {
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
217 for ( x=0; x < fw;x++ )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
218 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ];
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
219 fyc+=fbw;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
220 yc+=iw;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
221 }
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
222 dx+=fw;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
223 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
224
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
225 if ( ofs > 0 && tw > item->width )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
226 {
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
227 dx=ofs;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
228 for ( i=(int)strlen( p );i > 0;i-- )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
229 {
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
230 c=(unsigned int)p[i];
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
231 fw=Fonts[id]->Fnt[c].sx;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
232
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
233 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
234
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
235 fh=Fonts[id]->Fnt[c].sy;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
236 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
237
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
238 dx-=fw; yc=dx;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
239 if ( dx >= 0 )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
240 for ( y=0;y < fh;y++ )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
241 {
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
242 for ( x=fw - 1;x >= 0;x-- )
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
243 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x];
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
244 fyc+=fbw;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
245 yc+=iw;
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
246 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
247 }
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
248 }
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
249
8883
d6d999a9fc41 - new font render finished
pontscho
parents: 8864
diff changeset
250 return &item->Bitmap;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
251 }