@@ -25,7 +25,7 @@ CBaseFont::CBaseFont()
25
25
m_iEllipsisWide( 0 ),
26
26
m_glyphs(0 , 0 ), m_ABCCache( 0 , 0 )
27
27
{
28
- m_szName[0 ] = 0 ;
28
+ m_szTextureName[ 0 ] = m_szName[0 ] = 0 ;
29
29
SetDefLessFunc ( m_glyphs );
30
30
SetDefLessFunc ( m_ABCCache );
31
31
}
@@ -38,7 +38,7 @@ CBaseFont::GetTextureName
38
38
Mangle texture name, so using same font names with different attributes will not confuse engine or font renderer
39
39
=========================
40
40
+*/
41
- void CBaseFont::GetTextureName (char *dst, size_t len) const
41
+ void CBaseFont::GetTextureName ( char *dst, size_t len ) const
42
42
{
43
43
char attribs[256 ];
44
44
int i = 0 ;
@@ -64,13 +64,13 @@ void CBaseFont::GetTextureName(char *dst, size_t len) const
64
64
// faster loading: don't query filesystem, tell engine to skip everything and load only from buffer
65
65
if ( i == 0 )
66
66
{
67
- snprintf ( dst, len - 1 , " #%s_%i_%i_font .bmp" , GetName (), GetTall (), GetWeight () );
67
+ snprintf ( dst, len - 1 , " #%s_%i_%i_%s_font .bmp" , GetName (), GetTall (), GetWeight (), GetBackendName ( ) );
68
68
dst[len - 1 ] = 0 ;
69
69
}
70
70
else
71
71
{
72
72
attribs[i] = 0 ;
73
- snprintf ( dst, len - 1 , " #%s_%i_%i_%s_font.bmp" , GetName (), GetTall (), GetWeight (), attribs );
73
+ snprintf ( dst, len - 1 , " #%s_%i_%i_%s_% s_font.bmp" , GetName (), GetTall (), GetWeight (), attribs, GetBackendName ( ) );
74
74
dst[len - 1 ] = 0 ;
75
75
}
76
76
}
@@ -83,11 +83,10 @@ void CBaseFont::UploadGlyphsForRanges(charRange_t *range, int rangeSize)
83
83
const int height = GetHeight ();
84
84
const int tempSize = maxWidth * height * 4 ; // allocate temporary buffer for max possible glyph size
85
85
const Point nullPt ( 0 , 0 );
86
- char name[256 ];
87
86
88
- GetTextureName ( name , sizeof ( name ));
87
+ GetTextureName ( m_szTextureName , sizeof ( m_szTextureName ));
89
88
90
- if ( ReadFromCache ( name , range, rangeSize ))
89
+ if ( ReadFromCache ( m_szTextureName , range, rangeSize ))
91
90
{
92
91
int dotWideA, dotWideB, dotWideC;
93
92
GetCharABCWidths ( ' .' , dotWideA, dotWideB, dotWideC );
@@ -207,9 +206,9 @@ void CBaseFont::UploadGlyphsForRanges(charRange_t *range, int rangeSize)
207
206
}
208
207
}
209
208
210
- HIMAGE hImage = EngFuncs::PIC_Load ( name , bmp.GetBitmap (), bmp.GetBitmapHdr ()->fileSize , 0 );
209
+ HIMAGE hImage = EngFuncs::PIC_Load ( m_szTextureName , bmp.GetBitmap (), bmp.GetBitmapHdr ()->fileSize , 0 );
211
210
212
- SaveToCache ( name , range, rangeSize, &bmp );
211
+ SaveToCache ( m_szTextureName , range, rangeSize, &bmp );
213
212
214
213
delete[] temp;
215
214
@@ -228,9 +227,8 @@ void CBaseFont::UploadGlyphsForRanges(charRange_t *range, int rangeSize)
228
227
229
228
CBaseFont::~CBaseFont ()
230
229
{
231
- char name[256 ];
232
- GetTextureName ( name, sizeof ( name ) );
233
- EngFuncs::PIC_Free ( name );
230
+ if ( m_szTextureName[0 ] != 0 )
231
+ EngFuncs::PIC_Free ( m_szTextureName );
234
232
}
235
233
236
234
void CBaseFont::GetCharABCWidths ( int ch, int &a, int &b, int &c )
@@ -283,53 +281,41 @@ bool CBaseFont::IsEqualTo(const char *name, int tall, int weight, int blur, int
283
281
284
282
void CBaseFont::DebugDraw ()
285
283
{
286
- HIMAGE hImage;
287
- char name[256 ];
284
+ HIMAGE const hImage = EngFuncs::PIC_Load ( m_szTextureName );
285
+ const int w = EngFuncs::PIC_Width ( hImage );
286
+ const int h = EngFuncs::PIC_Height ( hImage );
288
287
289
- {
290
- GetTextureName ( name, sizeof ( name ) );
291
-
292
- hImage = EngFuncs::PIC_Load ( name );
293
- int w, h;
294
- w = EngFuncs::PIC_Width ( hImage );
295
- h = EngFuncs::PIC_Height ( hImage );
296
- int x = 0 ;
297
- EngFuncs::PIC_Set ( hImage, 255 , 255 , 255 );
298
- EngFuncs::PIC_DrawTrans ( Point (x, 0 ), Size ( w, h ) );
288
+ int x = 0 ;
289
+ EngFuncs::PIC_Set ( hImage, 255 , 255 , 255 );
290
+ EngFuncs::PIC_DrawTrans ( Point ( x, 0 ), Size ( w, h ));
299
291
300
- for ( int i = m_glyphs.FirstInorder ();; i = m_glyphs.NextInorder ( i ) )
292
+ for ( int i = m_glyphs.FirstInorder ();; i = m_glyphs.NextInorder ( i ) )
293
+ {
294
+ if ( m_glyphs[i].texture == hImage )
301
295
{
302
- if ( m_glyphs[i].texture == hImage )
303
- {
304
- Point pt;
305
- Size sz;
306
- pt.x = x + m_glyphs[i].rect .left ;
307
- pt.y = m_glyphs[i].rect .top ;
308
-
309
- sz.w = m_glyphs[i].rect .right - m_glyphs[i].rect .left ;
310
- sz.h = m_glyphs[i].rect .bottom - pt.y ;
311
-
312
- UI_DrawRectangleExt ( pt, sz, PackRGBA ( 255 , 0 , 0 , 255 ), 1 );
313
-
314
- int a, b, c;
315
- GetCharABCWidths ( m_glyphs[i].ch , a, b, c );
316
-
317
- pt.x -= a;
318
- sz.w += c + a;
319
-
320
- UI_DrawRectangleExt ( pt, sz, PackRGBA ( 0 , 255 , 0 , 255 ), 1 , QM_LEFT | QM_RIGHT );
321
-
322
- int ascender = GetAscent ();
323
-
324
- pt.y += ascender;
325
- UI_DrawRectangleExt ( pt, sz, PackRGBA ( 0 , 0 , 255 , 255 ), 1 , QM_TOP );
326
- }
327
-
328
- if ( i == m_glyphs.LastInorder () )
329
- break ;
296
+ Point pt;
297
+ Size sz;
298
+ pt.x = x + m_glyphs[i].rect .left ;
299
+ pt.y = m_glyphs[i].rect .top ;
300
+ sz.w = m_glyphs[i].rect .right - m_glyphs[i].rect .left ;
301
+ sz.h = m_glyphs[i].rect .bottom - pt.y ;
302
+ UI_DrawRectangleExt ( pt, sz, PackRGBA ( 255 , 0 , 0 , 255 ), 1 );
303
+
304
+ int a, b, c;
305
+ GetCharABCWidths ( m_glyphs[i].ch , a, b, c );
306
+
307
+ pt.x -= a;
308
+ sz.w += c + a;
309
+ UI_DrawRectangleExt ( pt, sz, PackRGBA ( 0 , 255 , 0 , 255 ), 1 , QM_LEFT | QM_RIGHT );
310
+
311
+ const int ascender = GetAscent ();
312
+ pt.y += ascender;
313
+ UI_DrawRectangleExt ( pt, sz, PackRGBA ( 0 , 0 , 255 , 255 ), 1 , QM_TOP );
330
314
}
331
- }
332
315
316
+ if ( i == m_glyphs.LastInorder () )
317
+ break ;
318
+ }
333
319
}
334
320
335
321
void CBaseFont::ApplyBlur (Size rgbaSz, byte *rgba)
0 commit comments