From 15dbbbf143e620b41d81130de073894380cb0484 Mon Sep 17 00:00:00 2001 From: mfranz Date: Tue, 6 Jun 2006 15:34:18 +0000 Subject: [PATCH] - use global fontcache - make font/size configurable --- src/Cockpit/hud.cxx | 13 ++++++++----- src/Cockpit/hud.hxx | 15 ++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index 8ddf3bb71..a9e578201 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -80,7 +80,8 @@ fgLineList HUD_LineList; fgLineList HUD_StippleLineList; fntRenderer *HUDtext = 0; -float HUD_TextSize = 0; +fntTexFont *HUD_Font = 0; +float HUD_TextSize = 0; int HUD_style = 0; float HUD_matrix[16]; @@ -763,11 +764,13 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ) delete tmp; } -// HUD_TextSize = fgGetInt("/sim/startup/xsize") / 60; - HUD_TextSize = 10; + FGFontCache *fc = globals->get_fontcache(); + HUD_Font = fc->getTexFont(fgGetString("/sim/hud/font/name", "Helvetica.txf")); + HUD_TextSize = fgGetFloat("/sim/hud/font/size", 10); + HUDtext = new fntRenderer(); - HUDtext -> setFont ( guiFntHandle ) ; - HUDtext -> setPointSize ( HUD_TextSize ) ; + HUDtext->setFont(HUD_Font); + HUDtext->setPointSize(HUD_TextSize); HUD_TextList.setFont( HUDtext ); return 0; // For now. Later we may use this for an error code. diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index 4f37c905f..f87b66faf 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -267,6 +267,7 @@ class DrawLineSeg2D { #define USE_HUD_TextList +extern fntTexFont *HUD_Font; extern float HUD_TextSize; extern fntRenderer *HUDtext; extern float HUD_matrix[16]; @@ -297,7 +298,7 @@ public: { if ( HUDtext && str ) { 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 0 ; @@ -307,7 +308,7 @@ public: { if ( HUDtext && strlen( msg )) { 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 0 ; @@ -335,7 +336,7 @@ public: i++; } if(c>p) { - fnt->setPointSize(8); + fnt->setPointSize(HUD_TextSize * 0.8); int p1=c-3; char *tmp1=msg+p1; int p2=p1*8; @@ -343,7 +344,7 @@ public: fnt->start2f(x+p2,y); fnt->puts(tmp1); - fnt->setPointSize(12); + fnt->setPointSize(HUD_TextSize * 1.2); char tmp2[64]; strncpy(tmp2,msg,p1); tmp2[p1]='\0'; @@ -351,13 +352,13 @@ public: fnt->start2f(x,y); fnt->puts(tmp2); } else { - fnt->setPointSize(12); + fnt->setPointSize(HUD_TextSize * 1.2); fnt->start2f( x, y ); fnt->puts(tmp); } } else { //if digits not equal to 1 - fnt->setPointSize(8); + fnt->setPointSize(HUD_TextSize * 0.8); fnt->start2f( x, y ); fnt->puts( msg ) ; } @@ -523,7 +524,7 @@ public: { if ( HUDtext && str ) { 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 0 ;