Mercurial > mplayer.hg
annotate gui/skin/font.c @ 32790:5c23e57bb0a4
Remove desultory parameter checks.
These functions will only be called with parameters already checked
or the checked parameters don't harm.
author | ib |
---|---|
date | Thu, 10 Feb 2011 13:24:00 +0000 |
parents | 236a95445ebb |
children | ece4313fbf15 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 #include <inttypes.h> | |
22 | |
23 #include "skin.h" | |
24 #include "font.h" | |
25 #include "cut.h" | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
26 #include "mp_msg.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "libavutil/avstring.h" |
23077 | 28 |
32787 | 29 bmpFont * Fonts[MAX_FONTS] = { 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 }; |
23077 | 30 |
31 int fntAddNewFont( char * name ) | |
32 { | |
33 int id; | |
34 int i; | |
35 | |
32787 | 36 for( id=0;id<MAX_FONTS;id++ ) |
23077 | 37 if ( !Fonts[id] ) break; |
38 | |
32786 | 39 if ( id == MAX_FONTS ) return -2; |
23077 | 40 |
41 if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1; | |
42 | |
32786 | 43 av_strlcpy( Fonts[id]->name,name,MAX_FONT_NAME ); |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
44 for ( i=0;i<ASCII_CHRS+EXTRA_CHRS;i++ ) |
23077 | 45 Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1; |
46 | |
47 return id; | |
48 } | |
49 | |
50 void fntFreeFont( void ) | |
51 { | |
52 int i; | |
32786 | 53 for( i=0;i < MAX_FONTS;i++ ) |
23077 | 54 { |
55 if ( Fonts[i] ) | |
56 { | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30405
diff
changeset
|
57 free( Fonts[i]->Bitmap.Image ); |
23077 | 58 free( Fonts[i] ); |
59 Fonts[i]=NULL; | |
60 } | |
61 } | |
62 } | |
63 | |
64 int fntRead( char * path,char * fname ) | |
65 { | |
66 FILE * f; | |
67 unsigned char tmp[512]; | |
68 unsigned char * ptmp; | |
69 unsigned char command[32]; | |
70 unsigned char param[256]; | |
32784 | 71 int c; |
23077 | 72 int id = fntAddNewFont( fname ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
73 |
23077 | 74 if ( id < 0 ) return id; |
75 | |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23077
diff
changeset
|
76 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
|
77 av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
78 if ( ( f=fopen( tmp,"rt" ) ) == NULL ) |
23077 | 79 { free( Fonts[id] ); return -3; } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
80 |
30405
d39acea63f2e
Simplify and correct loop condition, also avoids a compiler warning for unused result.
reimar
parents:
30404
diff
changeset
|
81 while ( fgets( tmp,255,f ) ) |
23077 | 82 { |
30404
5fbb30fa62cc
Fix newline removal code that might read and write out of bounds.
reimar
parents:
29263
diff
changeset
|
83 // remove any kind of newline, if any |
5fbb30fa62cc
Fix newline removal code that might read and write out of bounds.
reimar
parents:
29263
diff
changeset
|
84 tmp[strcspn(tmp, "\n\r")] = 0; |
23077 | 85 for ( c=0;c < (int)strlen( tmp );c++ ) |
86 if ( tmp[c] == ';' ) { tmp[c]=0; break; } | |
87 if ( !tmp[0] ) continue; | |
88 ptmp=trimleft( tmp ); | |
89 if ( !tmp[0] ) continue; | |
90 ptmp=strswap( ptmp,'\t',' ' ); | |
91 ptmp=trim( ptmp ); | |
92 cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 ); | |
93 if ( command[0] == '"' ) | |
94 { | |
95 int i; | |
96 cutItem( command,command,'"',1 ); | |
32789 | 97 if ( !command[0] ) i='"'; |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
98 else if ( command[0] & 0x80 ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
99 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
100 for ( i = 0; i < EXTRA_CHRS; i++ ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
101 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
102 if ( !Fonts[id]->nonASCIIidx[i][0] ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
103 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
104 strncpy( Fonts[id]->nonASCIIidx[i], command, 4 ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
105 break; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
106 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
107 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
108 if ( i == EXTRA_CHRS ) continue; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
109 i += ASCII_CHRS; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
110 } |
32789 | 111 else i=command[0]; |
23077 | 112 cutItem( param,tmp,',',0 ); Fonts[id]->Fnt[i].x=atoi( tmp ); |
113 cutItem( param,tmp,',',1 ); Fonts[id]->Fnt[i].y=atoi( tmp ); | |
114 cutItem( param,tmp,',',2 ); Fonts[id]->Fnt[i].sx=atoi( tmp ); | |
115 cutItem( param,tmp,',',3 ); Fonts[id]->Fnt[i].sy=atoi( tmp ); | |
116 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 ); | |
117 } | |
118 else | |
119 { | |
120 if ( !strcmp( command,"image" ) ) | |
121 { | |
23703
9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents:
23077
diff
changeset
|
122 av_strlcpy( tmp,path,sizeof( tmp ) ); av_strlcat( tmp,param,sizeof( tmp ) ); |
23077 | 123 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp ); |
32712 | 124 if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) |
125 { | |
126 fclose(f); | |
127 return -4; | |
128 } | |
23077 | 129 } |
130 } | |
131 } | |
132 | |
32712 | 133 fclose(f); |
23077 | 134 return 0; |
135 } | |
136 | |
137 int fntFindID( char * name ) | |
138 { | |
139 int i; | |
32786 | 140 for ( i=0;i < MAX_FONTS;i++ ) |
23077 | 141 if ( Fonts[i] ) |
142 if ( !strcmp( name,Fonts[i]->name ) ) return i; | |
143 return -1; | |
144 } | |
145 | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
146 // get Fnt index of character (utf8 or normal one) *str points to, |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
147 // then move pointer to next/previous character |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
148 int fntGetCharIndex( int id, unsigned char **str, gboolean utf8, int direction ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
149 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
150 unsigned char *p, uchar[4] = { 0, 0, 0, 0 }; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
151 int i, c = -1; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
152 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
153 if ( **str & 0x80 ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
154 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
155 if ( utf8 ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
156 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
157 p = *str; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
158 *str = g_utf8_next_char( *str ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
159 strncpy( uchar, p, *str - p ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
160 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
161 if ( direction < 0 ) *str = g_utf8_prev_char( p ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
162 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
163 else |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
164 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
165 uchar[0] = **str; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
166 *str += direction; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
167 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
168 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
169 for ( i = 0; ( i < EXTRA_CHRS ) && Fonts[id]->nonASCIIidx[i][0]; i++ ) |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
170 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
171 if ( strncmp( Fonts[id]->nonASCIIidx[i], uchar, 4 ) == 0 ) return i + ASCII_CHRS; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
172 if ( !utf8 && ( Fonts[id]->nonASCIIidx[i][0] == (*uchar >> 6 | 0xc0) && Fonts[id]->nonASCIIidx[i][1] == (*uchar & 0x3f | 0x80) && Fonts[id]->nonASCIIidx[i][2] == 0 ) ) c = i + ASCII_CHRS; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
173 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
174 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
175 else |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
176 { |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
177 c = **str; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
178 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
179 if ( utf8 && ( direction < 0 ) ) *str = g_utf8_prev_char( *str ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
180 else *str += direction; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
181 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
182 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
183 return c; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
184 } |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
185 |
23077 | 186 int fntTextWidth( int id,char * str ) |
187 { | |
188 int size = 0; | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
189 gboolean utf8; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
190 unsigned char *p; |
23077 | 191 |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
192 utf8 = g_utf8_validate( str, -1, NULL); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
193 p = (unsigned char *) str; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
194 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
195 while ( *p ) |
23077 | 196 { |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
197 int c = fntGetCharIndex( id, &p, utf8, 1 ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
198 if ( c == -1 || Fonts[id]->Fnt[c].sx == -1 ) c = ' '; |
23077 | 199 size+= Fonts[id]->Fnt[ c ].sx; |
200 } | |
201 return size; | |
202 } | |
203 | |
204 int fntTextHeight( int id,char * str ) | |
205 { | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
206 int max = 0; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
207 gboolean utf8; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
208 unsigned char *p; |
23077 | 209 |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
210 utf8 = g_utf8_validate( str, -1, NULL); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
211 p = (unsigned char *) str; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
212 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
213 while ( *p ) |
23077 | 214 { |
215 int h; | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
216 int c = fntGetCharIndex( id, &p, utf8, 1 ); |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
217 if ( c == -1 || Fonts[id]->Fnt[c].sx == -1 ) c = ' '; |
23077 | 218 h = Fonts[id]->Fnt[c].sy; |
219 if ( h > max ) max=h; | |
220 } | |
221 return max; | |
222 } | |
223 | |
32759 | 224 txSample * fntRender( wItem * item,int px,char * txt ) |
23077 | 225 { |
32759 | 226 unsigned char * u; |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
227 int c, i, dx = 0, tw, fbw, iw, id, ofs; |
23077 | 228 int x,y,fh,fw,fyc,yc; |
229 uint32_t * ibuf; | |
230 uint32_t * obuf; | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
231 gboolean utf8; |
23077 | 232 |
233 id=item->fontid; | |
32790 | 234 tw=fntTextWidth( id,txt ); |
23077 | 235 |
32790 | 236 if ( !tw ) return NULL; |
23077 | 237 |
32790 | 238 iw=item->width; |
23077 | 239 fbw=Fonts[id]->Bitmap.Width; |
240 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
241 if ( item->Bitmap.Image == NULL ) |
23077 | 242 { |
32759 | 243 item->Bitmap.Height=item->height=fntTextHeight( id,txt ); |
23077 | 244 item->Bitmap.Width=item->width=iw; |
245 item->Bitmap.ImageSize=item->height * iw * 4; | |
246 if ( !item->Bitmap.ImageSize ) return NULL; | |
247 item->Bitmap.BPP=32; | |
248 item->Bitmap.Image=malloc( item->Bitmap.ImageSize ); | |
249 } | |
250 | |
251 obuf=(uint32_t *)item->Bitmap.Image; | |
252 ibuf=(uint32_t *)Fonts[id]->Bitmap.Image; | |
253 | |
254 for ( i=0;i < item->Bitmap.ImageSize / 4;i++ ) obuf[i]=0xff00ff; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
255 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
256 if ( tw <= iw ) |
23077 | 257 { |
258 switch ( item->align ) | |
259 { | |
260 default: | |
261 case fntAlignLeft: dx=0; break; | |
32759 | 262 case fntAlignCenter: dx=( iw - fntTextWidth( id,txt ) ) / 2; break; |
263 case fntAlignRight: dx=iw - fntTextWidth( id,txt ); break; | |
23077 | 264 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
265 |
23077 | 266 } else dx+=px; |
267 | |
268 ofs=dx; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
269 |
32759 | 270 utf8 = g_utf8_validate( txt, -1, NULL); |
271 u = txt; | |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
272 |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
273 while ( *u ) |
23077 | 274 { |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
275 c = fntGetCharIndex( id, &u, utf8, 1 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
276 |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
277 if ( c != -1 ) fw=Fonts[id]->Fnt[c].sx; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
278 |
32789 | 279 if ( c == -1 || fw == -1 ) { c=' '; fw=Fonts[id]->Fnt[c].sx; } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
280 |
23077 | 281 fh=Fonts[id]->Fnt[c].sy; |
282 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; | |
283 yc=dx; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
284 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
285 if ( dx >= 0 ) |
23077 | 286 for ( y=0;y < fh;y++ ) |
287 { | |
288 for ( x=0; x < fw;x++ ) | |
289 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[ fyc + x ]; | |
290 fyc+=fbw; | |
291 yc+=iw; | |
292 } | |
293 dx+=fw; | |
294 } | |
295 | |
296 if ( ofs > 0 && tw > item->width ) | |
297 { | |
298 dx=ofs; | |
32759 | 299 u = txt + strlen( txt ); |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
300 |
32759 | 301 while ( u > (unsigned char *) txt ) |
23077 | 302 { |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
303 c = fntGetCharIndex( id, &u, utf8, -1 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
304 |
32734
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
305 if ( c != -1) fw=Fonts[id]->Fnt[c].sx; |
cc58a1e919d9
Allow character in the font description file to be in UTF-8.
ib
parents:
32712
diff
changeset
|
306 |
32789 | 307 if ( c == -1 || fw == -1 ) { c=' '; fw=Fonts[id]->Fnt[c].sx; } |
23077 | 308 |
309 fh=Fonts[id]->Fnt[c].sy; | |
310 fyc=Fonts[id]->Fnt[c].y * fbw + Fonts[id]->Fnt[c].x; | |
311 | |
312 dx-=fw; yc=dx; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
313 if ( dx >= 0 ) |
23077 | 314 for ( y=0;y < fh;y++ ) |
315 { | |
316 for ( x=fw - 1;x >= 0;x-- ) | |
317 if ( dx + x >= 0 && dx + x < iw ) obuf[yc + x]=ibuf[fyc + x]; | |
318 fyc+=fbw; | |
319 yc+=iw; | |
320 } | |
321 } | |
322 } | |
323 | |
324 return &item->Bitmap; | |
325 } |