annotate gui/skin/font.c @ 24515:c5c0cb0e90d2

getch2: Fix incorrect test Keycode length wasn't checked in one case because of missing parentheses. This was accidentally broken in my previous commit to the file. Most likely the error had no practical effect; the length checks are unreliable in any case as they can be satisfied by unrelated data corresponding to other keypresses.
author uau
date Sat, 15 Sep 2007 18:13:56 +0000
parents 9fb716ab06a3
children 10dfbc523184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
2 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
3 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
4 #include <stdarg.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
5 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
6 #include <inttypes.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
7
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
8 #include "app.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
9 #include "skin.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
10 #include "font.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
11 #include "cut.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
12 #include "../mp_msg.h"
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
13 #include "../libavutil/avstring.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
14
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
15 int items;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
16
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
17 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 };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 int fntAddNewFont( char * name )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21 int id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 for( id=0;id<26;id++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 if ( !Fonts[id] ) break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 if ( id == 25 ) return -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
31 av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 for ( i=0;i<256;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35 return id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
37
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38 void fntFreeFont( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
39 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 for( i=0;i < 25;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43 if ( Fonts[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
44 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45 if ( Fonts[i]->Bitmap.Image ) free( Fonts[i]->Bitmap.Image );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 free( Fonts[i] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 Fonts[i]=NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 int fntRead( char * path,char * fname )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54 FILE * f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 unsigned char tmp[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 unsigned char * ptmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 unsigned char command[32];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 unsigned char param[256];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 int c,linenumber = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 int id = fntAddNewFont( fname );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 if ( id < 0 ) return id;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
64 av_strlcpy( tmp,path,sizeof( tmp ) );
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
65 av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 if ( ( f=fopen( tmp,"rt" ) ) == NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 { free( Fonts[id] ); return -3; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 while ( !feof( f ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 fgets( tmp,255,f ); linenumber++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 for ( c=0;c < (int)strlen( tmp );c++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 if ( tmp[c] == ';' ) { tmp[c]=0; break; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 if ( !tmp[0] ) continue;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 ptmp=trimleft( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 if ( !tmp[0] ) continue;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 ptmp=strswap( ptmp,'\t',' ' );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 ptmp=trim( ptmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 if ( command[0] == '"' )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 cutItem( command,command,'"',1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 i=(int)command[0];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 cutItem( param,tmp,',',0 ); Fonts[id]->Fnt[i].x=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 cutItem( param,tmp,',',1 ); Fonts[id]->Fnt[i].y=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 cutItem( param,tmp,',',2 ); Fonts[id]->Fnt[i].sx=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 cutItem( param,tmp,',',3 ); Fonts[id]->Fnt[i].sy=atoi( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 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 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 if ( !strcmp( command,"image" ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 {
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23077
diff changeset
98 av_strlcpy( tmp,path,sizeof( tmp ) ); av_strlcat( tmp,param,sizeof( tmp ) );
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 int fntFindID( char * name )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 for ( i=0;i < 25;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 if ( Fonts[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 if ( !strcmp( name,Fonts[i]->name ) ) return i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 int fntTextWidth( int id,char * str )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 int size = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 for ( i=0;i < (int)strlen( str );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 unsigned char c = (unsigned char)str[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 size+= Fonts[id]->Fnt[ c ].sx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 return size;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 int fntTextHeight( int id,char * str )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 int max = 0,i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 for ( i=0;i < (int)strlen( str );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 int h;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 unsigned char c = (unsigned char)str[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 if ( Fonts[id]->Fnt[c].sx == -1 ) c = ' ';
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 h = Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 if ( h > max ) max=h;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 return max;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 txSample * fntRender( wItem * item,int px,const char * fmt,... )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 va_list ap;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 unsigned char p[512];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 unsigned int c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 int i, dx = 0, tw, fbw, iw, id, ofs;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 int x,y,fh,fw,fyc,yc;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 uint32_t * ibuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 uint32_t * obuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 va_start( ap,fmt );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 vsnprintf( p,512,fmt,ap );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 va_end( ap );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 iw=item->width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 id=item->fontid;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 if ( ( !item )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 ( !Fonts[id] )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 ( !p[0] )||
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 ( !fntTextWidth( id,p ) ) ) return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 tw=fntTextWidth( id,p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 fbw=Fonts[id]->Bitmap.Width;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 if ( item->Bitmap.Image == NULL )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 item->Bitmap.Height=item->height=fntTextHeight( id,p );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 item->Bitmap.Width=item->width=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 item->Bitmap.ImageSize=item->height * iw * 4;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 if ( !item->Bitmap.ImageSize ) return NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 item->Bitmap.BPP=32;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 item->Bitmap.Image=malloc( item->Bitmap.ImageSize );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 obuf=(uint32_t *)item->Bitmap.Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 if ( tw <= iw )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192 switch ( item->align )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 default:
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 case fntAlignLeft: dx=0; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 case fntAlignRight: dx=iw - fntTextWidth( id,p ); break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 } else dx+=px;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 ofs=dx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 for ( i=0;i < (int)strlen( p );i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 c=(unsigned int)p[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 fw=Fonts[id]->Fnt[c].sx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 fh=Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 yc=dx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 if ( dx >= 0 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 for ( y=0;y < fh;y++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218 for ( x=0; x < fw;x++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
219 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
220 fyc+=fbw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221 yc+=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 dx+=fw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
224 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
225
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 if ( ofs > 0 && tw > item->width )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 dx=ofs;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 for ( i=(int)strlen( p );i > 0;i-- )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 c=(unsigned int)p[i];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 fw=Fonts[id]->Fnt[c].sx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 if ( fw == -1 ) { c=32; fw=Fonts[id]->Fnt[c].sx; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 fh=Fonts[id]->Fnt[c].sy;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 dx-=fw; yc=dx;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 if ( dx >= 0 )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 for ( y=0;y < fh;y++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243 for ( x=fw - 1;x >= 0;x-- )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
244 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
245 fyc+=fbw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 yc+=iw;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
250
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251 return &item->Bitmap;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
252 }