1
0
Fork 0

- use global fontcache

- make font/size configurable
This commit is contained in:
mfranz 2006-06-06 15:34:18 +00:00
parent db86d15c5f
commit 15dbbbf143
2 changed files with 16 additions and 12 deletions

View file

@ -80,6 +80,7 @@ fgLineList HUD_LineList;
fgLineList HUD_StippleLineList; fgLineList HUD_StippleLineList;
fntRenderer *HUDtext = 0; fntRenderer *HUDtext = 0;
fntTexFont *HUD_Font = 0;
float HUD_TextSize = 0; float HUD_TextSize = 0;
int HUD_style = 0; int HUD_style = 0;
@ -763,11 +764,13 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
delete tmp; delete tmp;
} }
// HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60; FGFontCache *fc = globals->get_fontcache();
HUD_TextSize = 10; HUD_Font = fc->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf"));
HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10);
HUDtext = new fntRenderer(); HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ; HUDtext->setFont(HUD_Font);
HUDtext -> setPointSize ( HUD_TextSize ) ; HUDtext->setPointSize(HUD_TextSize);
HUD_TextList.setFont( HUDtext ); HUD_TextList.setFont( HUDtext );
return 0; // For now. Later we may use this for an error code. return 0; // For now. Later we may use this for an error code.

View file

@ -267,6 +267,7 @@ class DrawLineSeg2D {
#define USE_HUD_TextList #define USE_HUD_TextList
extern fntTexFont *HUD_Font;
extern float HUD_TextSize; extern float HUD_TextSize;
extern fntRenderer *HUDtext; extern fntRenderer *HUDtext;
extern float HUD_matrix[16]; extern float HUD_matrix[16];
@ -297,7 +298,7 @@ public:
{ {
if ( HUDtext && str ) { if ( HUDtext && str ) {
float r, l ; float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l ); return FloatToInt( r - l );
} }
return 0 ; return 0 ;
@ -307,7 +308,7 @@ public:
{ {
if ( HUDtext && strlen( msg )) { if ( HUDtext && strlen( msg )) {
float r, l ; float r, l ;
guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; HUD_Font->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l ); return FloatToInt( r - l );
} }
return 0 ; return 0 ;
@ -335,7 +336,7 @@ public:
i++; i++;
} }
if(c>p) { if(c>p) {
fnt->setPointSize(8); fnt->setPointSize(HUD_TextSize * 0.8);
int p1=c-3; int p1=c-3;
char *tmp1=msg+p1; char *tmp1=msg+p1;
int p2=p1*8; int p2=p1*8;
@ -343,7 +344,7 @@ public:
fnt->start2f(x+p2,y); fnt->start2f(x+p2,y);
fnt->puts(tmp1); fnt->puts(tmp1);
fnt->setPointSize(12); fnt->setPointSize(HUD_TextSize * 1.2);
char tmp2[64]; char tmp2[64];
strncpy(tmp2,msg,p1); strncpy(tmp2,msg,p1);
tmp2[p1]='\0'; tmp2[p1]='\0';
@ -351,13 +352,13 @@ public:
fnt->start2f(x,y); fnt->start2f(x,y);
fnt->puts(tmp2); fnt->puts(tmp2);
} else { } else {
fnt->setPointSize(12); fnt->setPointSize(HUD_TextSize * 1.2);
fnt->start2f( x, y ); fnt->start2f( x, y );
fnt->puts(tmp); fnt->puts(tmp);
} }
} else { } else {
//if digits not equal to 1 //if digits not equal to 1
fnt->setPointSize(8); fnt->setPointSize(HUD_TextSize * 0.8);
fnt->start2f( x, y ); fnt->start2f( x, y );
fnt->puts( msg ) ; fnt->puts( msg ) ;
} }
@ -523,7 +524,7 @@ public:
{ {
if ( HUDtext && str ) { if ( HUDtext && str ) {
float r, l ; float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l ); return FloatToInt( r - l );
} }
return 0 ; return 0 ;