/*
- * freeglut_font.c
+ * fg_font.c
*
* Bitmap and stroke fonts displaying.
*
/* -- IMPORT DECLARATIONS -------------------------------------------------- */
/*
- * These are the font faces defined in freeglut_font_data.c file:
+ * These are the font faces defined in fg_font_data.c file:
*/
extern SFG_Font fgFontFixed8x13;
extern SFG_Font fgFontFixed9x15;
* Matches a font ID with a SFG_Font structure pointer.
* This was changed to match the GLUT header style.
*/
-static SFG_Font* fghFontByID( void* font )
+SFG_Font* fghFontByID( void* font )
{
if( font == GLUT_BITMAP_8_BY_13 )
return &fgFontFixed8x13;
if( font == GLUT_BITMAP_TIMES_ROMAN_24 )
return &fgFontTimesRoman24;
- fgWarning( "font 0x%08x not found", font );
return 0;
}
if( font == GLUT_STROKE_MONO_ROMAN )
return &fgStrokeMonoRoman;
- fgWarning( "stroke font 0x%08x not found", font );
return 0;
}
SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" );
font = fghFontByID( fontID );
+ if (!font)
+ {
+ fgWarning("glutBitmapCharacter: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID);
+ return;
+ }
freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) );
- freeglut_return_if_fail( font );
/*
* Find the character we want to draw (???)
SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
font = fghFontByID( fontID );
- freeglut_return_if_fail( font );
+ if (!font)
+ {
+ fgWarning("glutBitmapString: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID);
+ return;
+ }
if ( !string || ! *string )
return;
{
SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" );
- font = fghFontByID( fontID );
freeglut_return_val_if_fail( character > 0 && character < 256, 0 );
- freeglut_return_val_if_fail( font, 0 );
+ font = fghFontByID( fontID );
+ if (!font)
+ {
+ fgWarning("glutBitmapWidth: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID);
+ return 0;
+ }
return *( font->Characters[ character ] );
}
SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" );
font = fghFontByID( fontID );
- freeglut_return_val_if_fail( font, 0 );
+ if (!font)
+ {
+ fgWarning("glutBitmapLength: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID);
+ return 0;
+ }
if ( !string || ! *string )
return 0;
SFG_Font* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" );
font = fghFontByID( fontID );
- freeglut_return_val_if_fail( font, 0 );
+ if (!font)
+ {
+ fgWarning("glutBitmapHeight: bitmap font 0x%08x not found. Make sure you're not passing a stroke font.\n",fontID);
+ return 0;
+ }
return font->Height;
}
SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" );
font = fghStrokeByID( fontID );
+ if (!font)
+ {
+ fgWarning("glutStrokeCharacter: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID);
+ return;
+ }
freeglut_return_if_fail( character >= 0 );
freeglut_return_if_fail( character < font->Quantity );
- freeglut_return_if_fail( font );
schar = font->Characters[ character ];
freeglut_return_if_fail( schar );
for( j = 0; j < strip->Number; j++ )
glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
glEnd( );
- glBegin( GL_POINTS );
- for( j = 0; j < strip->Number; j++ )
- glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
- glEnd( );
+
+ if (fgState.StrokeFontDrawJoinDots)
+ {
+ glBegin( GL_POINTS );
+ for( j = 0; j < strip->Number; j++ )
+ glVertex2f( strip->Vertices[ j ].X, strip->Vertices[ j ].Y );
+ glEnd( );
+ }
}
glTranslatef( schar->Right, 0.0, 0.0 );
}
SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" );
font = fghStrokeByID( fontID );
- freeglut_return_if_fail( font );
+ if (!font)
+ {
+ fgWarning("glutStrokeString: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID);
+ return;
+ }
if ( !string || ! *string )
return;
/*
* Return the width in pixels of a stroke character
*/
-int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
+GLfloat FGAPIENTRY glutStrokeWidthf( void* fontID, int character )
{
const SFG_StrokeChar *schar;
SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" );
font = fghStrokeByID( fontID );
+ if (!font)
+ {
+ fgWarning("glutStrokeWidth: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID);
+ return 0;
+ }
freeglut_return_val_if_fail( ( character >= 0 ) &&
( character < font->Quantity ),
0
);
- freeglut_return_val_if_fail( font, 0 );
schar = font->Characters[ character ];
freeglut_return_val_if_fail( schar, 0 );
- return ( int )( schar->Right + 0.5 );
+ return schar->Right;
+}
+int FGAPIENTRY glutStrokeWidth(void* fontID, int character)
+{
+ return ( int )( glutStrokeWidthf(fontID,character) + 0.5f );
}
/*
* Return the width of a string drawn using a stroke font
*/
-int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
+GLfloat FGAPIENTRY glutStrokeLengthf( void* fontID, const unsigned char* string )
{
unsigned char c;
- float length = 0.0;
- float this_line_length = 0.0;
+ GLfloat length = 0.0;
+ GLfloat this_line_length = 0.0;
SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" );
font = fghStrokeByID( fontID );
- freeglut_return_val_if_fail( font, 0 );
+ if (!font)
+ {
+ fgWarning("glutStrokeLength: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID);
+ return 0;
+ }
if ( !string || ! *string )
return 0;
}
if( length < this_line_length )
length = this_line_length;
- return( int )( length + 0.5 );
+ return length;
+}
+int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
+{
+ return( int )( glutStrokeLengthf(fontID,string) + 0.5f );
}
/*
SFG_StrokeFont* font;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" );
font = fghStrokeByID( fontID );
- freeglut_return_val_if_fail( font, 0.0 );
+ if (!font)
+ {
+ fgWarning("glutStrokeHeight: stroke font 0x%08x not found. Make sure you're not passing a bitmap font.\n",fontID);
+ return 0.f;
+ }
return font->Height;
}