FlightGear folks: I just checked in a nice Helvetica.txf into the base
package.  Before you can use this, you need two things.  The first is
a trivial patch to gui.cxx that allows for setting the default font
via properties (while leaving the original default in place).  In
src/GUI/gui.cxx, line 995, replace this:

   fntpath.append( "typewriter.txf" );

With this:

   fntpath.append(fgGetString("/sim/font", "typewriter.txf"));

The second thing you need is a patched plib.  There is a patch
attached to the current plib CVS that fixes a bug that this font file
needs.  If you don't apply it, you will see the new font rendered with
far too much space between characters.

Plib folks: this patch supersedes the one I sent yesterday.  My first
one missed a spot.  The calculation of string width needs to use the
new width metrics too, otherwise the strings themselves will print
acceptably, but be laid out with too much space.

Andy

-- 
Andrew J. Ross                NextBus Information Systems
Senior Software Engineer      Emeryville, CA
[EMAIL PROTECTED]              http://www.nextbus.com
"Men go crazy in conflagrations.  They only get better one by one."
 - Sting (misquoted)
Index: src/fnt/fnt.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/fnt/fnt.cxx,v
retrieving revision 1.7
diff -u -r1.7 fnt.cxx
--- src/fnt/fnt.cxx     12 Dec 2001 23:49:36 -0000      1.7
+++ src/fnt/fnt.cxx     29 Jun 2002 06:05:33 -0000
@@ -102,14 +102,14 @@
                    curpos[2] ) ;
   glEnd () ;
 
-  float ww = ( gap + ( fixed_pitch ? width : v_right[cc] ) ) * pointsize ;
+  float ww = ( gap + ( fixed_pitch ? width : widths[cc] ) ) * pointsize ;
   curpos[0] += ww ;
   return ww ;
 }
 
 
 
-void fntTexFont::setGlyph ( char c,
+void fntTexFont::setGlyph ( char c, float wid,
         float tex_left, float tex_right,
         float tex_bot , float tex_top  ,
         float vtx_left, float vtx_right,
@@ -119,6 +119,8 @@
 
   exists[cc] = FNT_TRUE ;
 
+  widths[cc] = wid;
+
   t_left[cc] = tex_left ; t_right[cc] = tex_right ;
   t_bot [cc] = tex_bot  ; t_top  [cc] = tex_top   ;
 
@@ -127,7 +129,7 @@
 }
 
 
-int fntTexFont::getGlyph ( char c,
+int fntTexFont::getGlyph ( char c, float* wid,
         float *tex_left, float *tex_right,
         float *tex_bot , float *tex_top  ,
         float *vtx_left, float *vtx_right,
@@ -137,6 +139,8 @@
 
   if ( ! exists[cc] ) return FNT_FALSE ;
 
+  if ( wid       != NULL ) *wid       = widths [cc] ;
+
   if ( tex_left  != NULL ) *tex_left  = t_left [cc] ;
   if ( tex_right != NULL ) *tex_right = t_right[cc] ;
   if ( tex_bot   != NULL ) *tex_bot   = t_bot  [cc] ;
@@ -209,7 +213,7 @@
     if ( b > v_pos + v_bot [cc] ) b = v_pos + v_bot [cc] ;
     if ( t < v_pos + v_top [cc] ) t = v_pos + v_top [cc] ;
 
-    h_pos += gap + ( fixed_pitch ? width : v_right[cc] ) ;
+    h_pos += gap + ( fixed_pitch ? width : widths[cc] ) ;
   }
 
   if ( left  != NULL ) *left  = l * pointsize ;
Index: src/fnt/fnt.h
===================================================================
RCS file: /cvsroot/plib/plib/src/fnt/fnt.h,v
retrieving revision 1.5
diff -u -r1.5 fnt.h
--- src/fnt/fnt.h       7 Nov 2001 23:51:09 -0000       1.5
+++ src/fnt/fnt.h       29 Jun 2002 06:05:33 -0000
@@ -90,6 +90,10 @@
     v_bot==0.0 and v_top==1.0.
   */
 
+  /* Nominal baseline widths */
+
+  float widths  [ FNTMAX_CHAR ] ;
+
   /* Texture coordinates */
 
   float t_top   [ FNTMAX_CHAR ] ; /* Top    edge of each character [0..1] */
@@ -171,19 +175,19 @@
   float getGap       () const { return gap       ; } 
 
 
-  void setGlyph ( char c,
+  void setGlyph ( char c, float wid,
                   float tex_left, float tex_right,
                   float tex_bot , float tex_top  ,
                   float vtx_left, float vtx_right,
                   float vtx_bot , float vtx_top  ) ;
   
-  int  getGlyph ( char c,
+  int  getGlyph ( char c, float* wid,
                   float *tex_left = NULL, float *tex_right = NULL,
                   float *tex_bot  = NULL, float *tex_top   = NULL,
                   float *vtx_left = NULL, float *vtx_right = NULL,
                   float *vtx_bot  = NULL, float *vtx_top   = NULL) ;
 
-  int hasGlyph ( char c ) { return getGlyph ( c ) ; }
+  int hasGlyph ( char c ) { return exists[ c ] ; }
 
   void getBBox ( const char *s, float pointsize, float italic,
                  float *left, float *right,
Index: src/fnt/fntTXF.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/fnt/fntTXF.cxx,v
retrieving revision 1.14
diff -u -r1.14 fntTXF.cxx
--- src/fnt/fntTXF.cxx  21 Apr 2002 03:53:15 -0000      1.14
+++ src/fnt/fntTXF.cxx  29 Jun 2002 06:05:34 -0000
@@ -246,6 +246,7 @@
     glyph . y       = _fnt_readShort () ;
 
     setGlyph ( (char) glyph.ch,
+          (float)  glyph.step              / (float) max_height,
           (float)  glyph.x                 / (float) w + xstep,
           (float)( glyph.x + glyph.w )     / (float) w + xstep,
           (float)  glyph.y                 / (float) h + ystep,

Reply via email to