Mercurial > mplayer.hg
comparison gui/skin/font.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | b0a7b35b78d2 |
children | 5fbb30fa62cc |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
44 if ( id == 25 ) return -2; | 44 if ( id == 25 ) return -2; |
45 | 45 |
46 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1; | 46 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1; |
47 | 47 |
48 av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h | 48 av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h |
49 for ( i=0;i<256;i++ ) | 49 for ( i=0;i<256;i++ ) |
50 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1; | 50 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1; |
51 | 51 |
52 return id; | 52 return id; |
53 } | 53 } |
54 | 54 |
73 unsigned char * ptmp; | 73 unsigned char * ptmp; |
74 unsigned char command[32]; | 74 unsigned char command[32]; |
75 unsigned char param[256]; | 75 unsigned char param[256]; |
76 int c,linenumber = 0; | 76 int c,linenumber = 0; |
77 int id = fntAddNewFont( fname ); | 77 int id = fntAddNewFont( fname ); |
78 | 78 |
79 if ( id < 0 ) return id; | 79 if ( id < 0 ) return id; |
80 | 80 |
81 av_strlcpy( tmp,path,sizeof( tmp ) ); | 81 av_strlcpy( tmp,path,sizeof( tmp ) ); |
82 av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) ); | 82 av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) ); |
83 if ( ( f=fopen( tmp,"rt" ) ) == NULL ) | 83 if ( ( f=fopen( tmp,"rt" ) ) == NULL ) |
84 { free( Fonts[id] ); return -3; } | 84 { free( Fonts[id] ); return -3; } |
85 | 85 |
86 while ( !feof( f ) ) | 86 while ( !feof( f ) ) |
87 { | 87 { |
88 fgets( tmp,255,f ); linenumber++; | 88 fgets( tmp,255,f ); linenumber++; |
89 | 89 |
90 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0; | 90 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0; |
187 ( !fntTextWidth( id,p ) ) ) return NULL; | 187 ( !fntTextWidth( id,p ) ) ) return NULL; |
188 | 188 |
189 tw=fntTextWidth( id,p ); | 189 tw=fntTextWidth( id,p ); |
190 fbw=Fonts[id]->Bitmap.Width; | 190 fbw=Fonts[id]->Bitmap.Width; |
191 | 191 |
192 if ( item->Bitmap.Image == NULL ) | 192 if ( item->Bitmap.Image == NULL ) |
193 { | 193 { |
194 item->Bitmap.Height=item->height=fntTextHeight( id,p ); | 194 item->Bitmap.Height=item->height=fntTextHeight( id,p ); |
195 item->Bitmap.Width=item->width=iw; | 195 item->Bitmap.Width=item->width=iw; |
196 item->Bitmap.ImageSize=item->height * iw * 4; | 196 item->Bitmap.ImageSize=item->height * iw * 4; |
197 if ( !item->Bitmap.ImageSize ) return NULL; | 197 if ( !item->Bitmap.ImageSize ) return NULL; |
201 | 201 |
202 obuf=(uint32_t *)item->Bitmap.Image; | 202 obuf=(uint32_t *)item->Bitmap.Image; |
203 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image; | 203 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image; |
204 | 204 |
205 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff; | 205 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff; |
206 | 206 |
207 if ( tw <= iw ) | 207 if ( tw <= iw ) |
208 { | 208 { |
209 switch ( item->align ) | 209 switch ( item->align ) |
210 { | 210 { |
211 default: | 211 default: |
212 case fntAlignLeft: dx=0; break; | 212 case fntAlignLeft: dx=0; break; |
213 case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break; | 213 case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break; |
214 case fntAlignRight: dx=iw - fntTextWidth( id,p ); break; | 214 case fntAlignRight: dx=iw - fntTextWidth( id,p ); break; |
215 } | 215 } |
216 | 216 |
217 } else dx+=px; | 217 } else dx+=px; |
218 | 218 |
219 ofs=dx; | 219 ofs=dx; |
220 | 220 |
221 for ( i=0;i < (int)strlen( p );i++ ) | 221 for ( i=0;i < (int)strlen( p );i++ ) |
222 { | 222 { |
223 c=(unsigned int)p[i]; | 223 c=(unsigned int)p[i]; |
224 fw=Fonts[id]->Fnt[c].sx; | 224 fw=Fonts[id]->Fnt[c].sx; |
225 | 225 |
226 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; } | 226 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; } |
227 | 227 |
228 fh=Fonts[id]->Fnt[c].sy; | 228 fh=Fonts[id]->Fnt[c].sy; |
229 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; | 229 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; |
230 yc=dx; | 230 yc=dx; |
231 | 231 |
232 if ( dx >= 0 ) | 232 if ( dx >= 0 ) |
233 for ( y=0;y < fh;y++ ) | 233 for ( y=0;y < fh;y++ ) |
234 { | 234 { |
235 for ( x=0; x < fw;x++ ) | 235 for ( x=0; x < fw;x++ ) |
236 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ]; | 236 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ]; |
237 fyc+=fbw; | 237 fyc+=fbw; |
245 dx=ofs; | 245 dx=ofs; |
246 for ( i=(int)strlen( p );i > 0;i-- ) | 246 for ( i=(int)strlen( p );i > 0;i-- ) |
247 { | 247 { |
248 c=(unsigned int)p[i]; | 248 c=(unsigned int)p[i]; |
249 fw=Fonts[id]->Fnt[c].sx; | 249 fw=Fonts[id]->Fnt[c].sx; |
250 | 250 |
251 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; } | 251 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; } |
252 | 252 |
253 fh=Fonts[id]->Fnt[c].sy; | 253 fh=Fonts[id]->Fnt[c].sy; |
254 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; | 254 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; |
255 | 255 |
256 dx-=fw; yc=dx; | 256 dx-=fw; yc=dx; |
257 if ( dx >= 0 ) | 257 if ( dx >= 0 ) |
258 for ( y=0;y < fh;y++ ) | 258 for ( y=0;y < fh;y++ ) |
259 { | 259 { |
260 for ( x=fw - 1;x >= 0;x-- ) | 260 for ( x=fw - 1;x >= 0;x-- ) |
261 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x]; | 261 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x]; |
262 fyc+=fbw; | 262 fyc+=fbw; |