ftmulti.c: Will now accept any filename. It will no longer append `.ttf'

or `.ttc'.  Reformatted.

ftcalc.c, ftdebug.c: Minor formatting stuff.
This commit is contained in:
Werner Lemberg 2000-05-30 05:13:30 +00:00
parent 5b401bb918
commit 026bd17b41
3 changed files with 307 additions and 221 deletions

View File

@ -2,7 +2,7 @@
/* */ /* */
/* The FreeType project -- a free and portable quality TrueType renderer. */ /* The FreeType project -- a free and portable quality TrueType renderer. */
/* */ /* */
/* Copyright 1996-1999 by */ /* Copyright 1996-2000 by */
/* D. Turner, R.Wilhelm, and W. Lemberg */ /* D. Turner, R.Wilhelm, and W. Lemberg */
/* */ /* */
/* */ /* */
@ -30,8 +30,8 @@
#define DIM_X 500 #define DIM_X 500
#define DIM_Y 400 #define DIM_Y 400
#define CENTER_X (bit.width/2) #define CENTER_X ( bit.width / 2 )
#define CENTER_Y (bit.rows/2) #define CENTER_Y ( bit.rows / 2 )
#define MAXPTSIZE 500 /* dtp */ #define MAXPTSIZE 500 /* dtp */
@ -39,37 +39,38 @@
char* new_header = 0; char* new_header = 0;
const unsigned char* Text = (unsigned char*) const unsigned char* Text = (unsigned char*)
"The quick brown fox jumped over the lazy dog 0123456789 \ "The quick brown fox jumped over the lazy dog 0123456789 "
\342\352\356\373\364\344\353\357\366\374\377\340\371\351\350\347 \ "\342\352\356\373\364\344\353\357\366\374\377\340\371\351\350\347 "
&#~\"\'(-`_^@)=+\260 ABCDEFGHIJKLMNOPQRSTUVWXYZ \ "&#~\"\'(-`_^@)=+\260 ABCDEFGHIJKLMNOPQRSTUVWXYZ "
$\243^\250*\265\371%!\247:/;.,?<>"; "$\243^\250*\265\371%!\247:/;.,?<>";
FT_Library library; /* the FreeType library */
FT_Face face; /* the font face */
FT_Size size; /* the font size */
FT_GlyphSlot glyph; /* the glyph slot */
FT_Error error; /* error returned by FreeType ? */ FT_Library library; /* the FreeType library */
FT_Face face; /* the font face */
FT_Size size; /* the font size */
FT_GlyphSlot glyph; /* the glyph slot */
grSurface* surface; /* current display surface */ FT_Error error; /* error returned by FreeType? */
grBitmap bit; /* current display bitmap */
grSurface* surface; /* current display surface */
grBitmap bit; /* current display bitmap */
int num_glyphs; /* number of glyphs */ int num_glyphs; /* number of glyphs */
int ptsize; /* current point size */ int ptsize; /* current point size */
int hinted = 1; /* is glyph hinting active ? */ int hinted = 1; /* is glyph hinting active? */
int antialias = 1; /* is anti-aliasing active ? */ int antialias = 1; /* is anti-aliasing active? */
int use_sbits = 1; /* do we use embedded bitmaps ? */ int use_sbits = 1; /* do we use embedded bitmaps? */
int low_prec = 0; /* force low precision */ int low_prec = 0; /* force low precision */
int Num; /* current first glyph index */ int Num; /* current first glyph index */
int res = 72; int res = 72;
static grColor fore_color = { 255 }; static grColor fore_color = { 255 };
int Fail; int Fail;
unsigned char autorun; unsigned char autorun;
int graph_init = 0; int graph_init = 0;
int render_mode = 1; int render_mode = 1;
int use_grays = 1; int use_grays = 1;
@ -78,90 +79,100 @@ $\243^\250*\265\371%!\247:/;.,?<>";
FT_Raster_Funcs std_raster; FT_Raster_Funcs std_raster;
FT_Multi_Master multimaster; FT_Multi_Master multimaster;
FT_Long design_pos[ T1_MAX_MM_AXIS ]; FT_Long design_pos[T1_MAX_MM_AXIS];
#define RASTER_BUFF_SIZE 32768 #define RASTER_BUFF_SIZE 32768
char raster_buff[ RASTER_BUFF_SIZE ]; char raster_buff[RASTER_BUFF_SIZE];
#define DEBUGxxx #define DEBUGxxx
#ifdef DEBUG #ifdef DEBUG
#define LOG(x) LogMessage##x #define LOG( x ) LogMessage##x
#else #else
#define LOG(x) /* rien */ #define LOG( x ) /* empty */
#endif #endif
#ifdef DEBUG #ifdef DEBUG
static void LogMessage( const char* fmt, ... ) static
void LogMessage( const char* fmt, ... )
{ {
va_list ap; va_list ap;
va_start( ap, fmt ); va_start( ap, fmt );
vfprintf( stderr, fmt, ap ); vfprintf( stderr, fmt, ap );
va_end( ap ); va_end( ap );
} }
#endif #endif
/* PanicZ */ /* PanicZ */
static void PanicZ( const char* message ) static
void PanicZ( const char* message )
{ {
fprintf( stderr, "%s\n error = 0x%04x\n", message, error ); fprintf( stderr, "%s\n error = 0x%04x\n", message, error );
exit(1); exit( 1 );
} }
/* Clears the Bit bitmap/pixmap */ /* Clears the Bit bitmap/pixmap */
static void Clear_Display( void ) static
void Clear_Display( void )
{ {
long size = (long)bit.pitch * bit.rows; long size = (long)bit.pitch * bit.rows;
if (size < 0) size = -size;
if ( size < 0 )
size = -size;
memset( bit.buffer, 0, size ); memset( bit.buffer, 0, size );
} }
/* Initialize the display bitmap named Bit */ /* Initialize the display bitmap named `bit' */
static int Init_Display() static
void Init_Display( void )
{ {
grInitDevices(); grInitDevices();
bit.mode = gr_pixel_mode_gray; bit.mode = gr_pixel_mode_gray;
bit.width = DIM_X; bit.width = DIM_X;
bit.rows = DIM_Y; bit.rows = DIM_Y;
bit.grays = 256; bit.grays = 256;
surface = grNewSurface( 0, &bit ); surface = grNewSurface( 0, &bit );
if (!surface) if ( !surface )
PanicZ( "could not allocate display surface\n" ); PanicZ( "could not allocate display surface\n" );
graph_init = 1; graph_init = 1;
return 0;
} }
#define MAX_BUFFER 300000 #define MAX_BUFFER 300000
#define FLOOR(x) ((x) & -64) #define FLOOR( x ) ( (x) & -64 )
#define CEIL(x) (((x)+63) & -64) #define CEIL( x ) ( ( (x) + 63 ) & -64 )
#define TRUNC(x) ((x) >> 6) #define TRUNC( x ) ( (x) >> 6 )
static static
char bit_buffer[ MAX_BUFFER ]; char bit_buffer[MAX_BUFFER];
/* Render a single glyph with the "grays" component */ /* Render a single glyph with the "grays" component */
static FT_Error Render_Glyph( int x_offset, static
int y_offset ) FT_Error Render_Glyph( int x_offset,
int y_offset )
{ {
/* first, render the glyph into an intermediate buffer */
FT_Bitmap bit2; FT_Bitmap bit2;
grBitmap bit3; grBitmap bit3;
int width, height, pitch, size; int width, height, pitch, size;
int left, right, top, bottom; int left, right, top, bottom;
int x_top, y_top; int x_top, y_top;
/* first, render the glyph into an intermediate buffer */
left = FLOOR( glyph->metrics.horiBearingX ); left = FLOOR( glyph->metrics.horiBearingX );
right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width ); right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
width = TRUNC(right - left); width = TRUNC( right - left );
top = CEIL( glyph->metrics.horiBearingY ); top = CEIL( glyph->metrics.horiBearingY );
bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height ); bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
@ -169,10 +180,11 @@ $\243^\250*\265\371%!\247:/;.,?<>";
if ( glyph->format == ft_glyph_format_outline ) if ( glyph->format == ft_glyph_format_outline )
{ {
pitch = ( antialias ? (width+3) & -4 : (width+7) >> 3 ); pitch = antialias ? ( width + 3 ) & -4
size = pitch*height; : ( width + 7 ) >> 3;
size = pitch * height;
if (size > MAX_BUFFER) if ( size > MAX_BUFFER )
return FT_Err_Out_Of_Memory; return FT_Err_Out_Of_Memory;
bit2.width = width; bit2.width = width;
@ -191,7 +203,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
FT_Outline_Translate( &glyph->outline, -left, -bottom ); FT_Outline_Translate( &glyph->outline, -left, -bottom );
memset( bit_buffer, 0, size ); memset( bit_buffer, 0, size );
if (low_prec) if ( low_prec )
glyph->outline.flags &= ~ft_outline_high_precision; glyph->outline.flags &= ~ft_outline_high_precision;
error = FT_Outline_Get_Bitmap( library, &glyph->outline, &bit2 ); error = FT_Outline_Get_Bitmap( library, &glyph->outline, &bit2 );
@ -206,37 +218,48 @@ $\243^\250*\265\371%!\247:/;.,?<>";
bit3.grays = 0; bit3.grays = 0;
} }
/* Then, blit the image to the target surface */ /* then, blit the image to the target surface */
x_top = x_offset + TRUNC(left);
y_top = y_offset - TRUNC(top);
/* x_top = x_offset + TRUNC( left );
if (bit.pitch < 0) y_top = y_offset - TRUNC( top );
#if 0
if ( bit.pitch < 0 )
y_top = bit.rows - y_top; y_top = bit.rows - y_top;
*/ #endif
grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color ); grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color );
return 0;
return FT_Err_Ok;
} }
static FT_Error Reset_Scale( int pointSize )
static
FT_Error Reset_Scale( int pointSize )
{ {
FT_Error error; FT_Error error;
error = FT_Set_Char_Size( face, pointSize << 6, error = FT_Set_Char_Size( face, pointSize << 6,
pointSize << 6, pointSize << 6,
res, res,
res ); res );
if ( error ) if ( error )
{ {
/* to be written */
} }
return FT_Err_Ok; return FT_Err_Ok;
} }
static FT_Error LoadChar( int idx, int hint ) static
FT_Error LoadChar( int idx,
int hint )
{ {
int flags; int flags;
flags = FT_LOAD_DEFAULT; flags = FT_LOAD_DEFAULT;
if ( !hint ) if ( !hint )
@ -249,16 +272,18 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
static
static FT_Error Render_All( int first_glyph, int ptsize ) FT_Error Render_All( int first_glyph,
int ptsize )
{ {
FT_F26Dot6 start_x, start_y, step_x, step_y, x, y; FT_F26Dot6 start_x, start_y, step_x, step_y, x, y;
int i; int i;
FT_Error error; FT_Error error;
start_x = 4; start_x = 4;
start_y = 36 + ptsize ; start_y = 36 + ptsize;
step_x = size->metrics.x_ppem + 4; step_x = size->metrics.x_ppem + 4;
step_y = size->metrics.y_ppem + 10; step_y = size->metrics.y_ppem + 10;
@ -269,25 +294,25 @@ $\243^\250*\265\371%!\247:/;.,?<>";
i = first_glyph; i = first_glyph;
#if 0 #if 0
while ( i < first_glyph+1 ) while ( i < first_glyph + 1 )
#else #else
while ( i < num_glyphs ) while ( i < num_glyphs )
#endif #endif
{ {
if ( !(error = LoadChar( i, hinted )) ) if ( !( error = LoadChar( i, hinted ) ) )
{ {
#ifdef DEBUG #ifdef DEBUG
if (i <= first_glyph+6) if ( i <= first_glyph + 6 )
{ {
LOG(( "metrics[%02d] = [%x %x]\n", LOG(( "metrics[%02d] = [%x %x]\n",
i, i,
glyph->metrics.horiBearingX, glyph->metrics.horiBearingX,
glyph->metrics.horiAdvance )); glyph->metrics.horiAdvance ));
if (i == first_glyph+6) if ( i == first_glyph + 6 )
LOG(( "-------------------------\n")); LOG(( "-------------------------\n" ));
} }
#endif #endif
Render_Glyph( x, y ); Render_Glyph( x, y );
@ -312,7 +337,9 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
static FT_Error Render_Text( int first_glyph, int ptsize ) static
FT_Error Render_Text( int first_glyph,
int ptsize )
{ {
FT_F26Dot6 start_x, start_y, step_x, step_y, x, y; FT_F26Dot6 start_x, start_y, step_x, step_y, x, y;
int i; int i;
@ -320,6 +347,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
FT_Error error; FT_Error error;
const unsigned char* p; const unsigned char* p;
start_x = 4; start_x = 4;
start_y = 32 + size->metrics.y_ppem; start_y = 32 + size->metrics.y_ppem;
@ -331,24 +359,30 @@ $\243^\250*\265\371%!\247:/;.,?<>";
i = first_glyph; i = first_glyph;
p = Text; p = Text;
while (i > 0 && *p) { p++; i--; } while ( i > 0 && *p )
{
p++;
i--;
}
while ( *p ) while ( *p )
{ {
if ( !(error = LoadChar( FT_Get_Char_Index( face, (unsigned char)*p ), hinted )) ) if ( !( error = LoadChar( FT_Get_Char_Index( face,
(unsigned char)*p ),
hinted ) ) )
{ {
#ifdef DEBUG #ifdef DEBUG
if (i <= first_glyph+6) if ( i <= first_glyph + 6 )
{ {
LOG(( "metrics[%02d] = [%x %x]\n", LOG(( "metrics[%02d] = [%x %x]\n",
i, i,
glyph->metrics.horiBearingX, glyph->metrics.horiBearingX,
glyph->metrics.horiAdvance )); glyph->metrics.horiAdvance ));
if (i == first_glyph+6) if ( i == first_glyph + 6 )
LOG(( "-------------------------\n")); LOG(( "-------------------------\n" ));
} }
#endif #endif
Render_Glyph( x, y ); Render_Glyph( x, y );
@ -374,11 +408,14 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
static void Help( ) static
void Help( void )
{ {
grEvent dummy_event; grEvent dummy_event;
Clear_Display(); Clear_Display();
grGotoxy( 0, 0 ); grGotoxy( 0, 0 );
grSetMargin( 2, 1 ); grSetMargin( 2, 1 );
grGotobitmap( &bit ); grGotobitmap( &bit );
@ -388,14 +425,14 @@ $\243^\250*\265\371%!\247:/;.,?<>";
grWriteln("This program is used to display all glyphs from one or" ); grWriteln("This program is used to display all glyphs from one or" );
grWriteln("several font files, with the FreeType library."); grWriteln("several font files, with the FreeType library.");
grLn(); grLn();
grWriteln("Use the following keys :"); grWriteln("Use the following keys:");
grLn(); grLn();
grWriteln(" F1 or ? : display this help screen" ); grWriteln(" F1 or ? : display this help screen" );
grWriteln(" a : toggle anti-aliasing" ); grWriteln(" a : toggle anti-aliasing" );
grWriteln(" h : toggle outline hinting" ); grWriteln(" h : toggle outline hinting" );
grWriteln(" b : toggle embedded bitmaps" ); grWriteln(" b : toggle embedded bitmaps" );
grWriteln(" l : toggle low precision rendering" ); grWriteln(" l : toggle low precision rendering" );
grWriteln(" g : toggle between 'smooth' and 'standard' anti-aliaser" ); grWriteln(" g : toggle between `smooth' and `standard' anti-aliaser" );
grWriteln(" space : toggle rendering mode" ); grWriteln(" space : toggle rendering mode" );
grLn(); grLn();
grWriteln(" Up : increase pointsize by 1 unit" ); grWriteln(" Up : increase pointsize by 1 unit" );
@ -419,7 +456,9 @@ $\243^\250*\265\371%!\247:/;.,?<>";
grListenSurface( surface, gr_event_key, &dummy_event ); grListenSurface( surface, gr_event_key, &dummy_event );
} }
static void reset_raster( void )
static
void reset_raster( void )
{ {
if ( antialias && use_grays ) if ( antialias && use_grays )
FT_Set_Raster( library, &ft_grays_raster ); FT_Set_Raster( library, &ft_grays_raster );
@ -428,101 +467,157 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
static int Process_Event( grEvent* event ) static
int Process_Event( grEvent* event )
{ {
int i, axis; int i, axis;
switch ( event->key ) switch ( event->key )
{ {
case grKeyEsc: /* ESC or q */ case grKeyEsc: /* ESC or q */
case grKEY('q'): case grKEY( 'q' ):
return 0; return 0;
case grKEY('a'):
antialias = !antialias;
new_header = ( antialias
? "anti-aliasing is now on"
: "anti-aliasing is now off" );
reset_raster();
return 1;
case grKEY('b'):
use_sbits = !use_sbits;
new_header = ( use_sbits
? "embedded bitmaps are now used when available"
: "embedded bitmaps are now ignored" );
return 1;
case grKEY('n'):
case grKEY('p'):
return (int)event->key;
case grKEY('g'):
use_grays = !use_grays;
new_header = ( use_grays
? "now using the smooth anti-aliaser"
: "now using the standard anti-aliaser" );
reset_raster();
break;
case grKEY('l'):
low_prec = !low_prec;
new_header = ( low_prec
? "rendering precision is now forced to low"
: "rendering precision is now normal" );
break;
case grKEY('h'):
hinted = !hinted;
new_header = ( hinted
? "glyph hinting is now active"
: "glyph hinting is now ignored" );
break;
case grKEY(' '):
render_mode ^= 1;
new_header = ( render_mode
? "rendering all glyphs in font"
: "rendering test text string" );
break;
case grKeyF1: case grKeyF1:
case grKEY('?'): case grKEY( '?' ):
Help(); Help();
return 1; return 1;
case grKeyF3: i = -20; axis = 0; goto Do_Axis; /* mode keys */
case grKeyF4: i = 20; axis = 0; goto Do_Axis;
case grKeyF5: i = -20; axis = 1; goto Do_Axis;
case grKeyF6: i = 20; axis = 1; goto Do_Axis;
case grKeyF7: i = -20; axis = 2; goto Do_Axis;
case grKeyF8: i = 20; axis = 2; goto Do_Axis;
case grKeyPageUp: i = 10; goto Do_Scale; case grKEY( 'a' ):
case grKeyPageDown: i = -10; goto Do_Scale; antialias = !antialias;
case grKeyUp: i = 1; goto Do_Scale; new_header = antialias ? "anti-aliasing is now on"
case grKeyDown: i = -1; goto Do_Scale; : "anti-aliasing is now off";
reset_raster();
return 1;
case grKEY( 'b' ):
use_sbits = !use_sbits;
new_header = use_sbits ? "embedded bitmaps are now used if available"
: "embedded bitmaps are now ignored";
return 1;
case grKEY( 'n' ):
case grKEY( 'p' ):
return (int)event->key;
case grKEY( 'g' ):
use_grays = !use_grays;
new_header = use_grays ? "now using the smooth anti-aliaser"
: "now using the standard anti-aliaser";
reset_raster();
break;
case grKEY( 'l' ):
low_prec = !low_prec;
new_header = low_prec ? "rendering precision is now forced to low"
: "rendering precision is now normal";
break;
case grKEY( 'h' ):
hinted = !hinted;
new_header = hinted ? "glyph hinting is now active"
: "glyph hinting is now ignored";
break;
case grKEY( ' ' ):
render_mode ^= 1;
new_header = render_mode ? "rendering all glyphs in font"
: "rendering test text string";
break;
/* MM related keys */
case grKeyF3:
i = -20;
axis = 0;
goto Do_Axis;
case grKeyF4:
i = 20;
axis = 0;
goto Do_Axis;
case grKeyF5:
i = -20;
axis = 1;
goto Do_Axis;
case grKeyF6:
i = 20;
axis = 1;
goto Do_Axis;
case grKeyF7:
i = -20;
axis = 2;
goto Do_Axis;
case grKeyF8:
i = 20;
axis = 2;
goto Do_Axis;
/* scaling related keys */
case grKeyPageUp:
i = 10;
goto Do_Scale;
case grKeyPageDown:
i = -10;
goto Do_Scale;
case grKeyUp:
i = 1;
goto Do_Scale;
case grKeyDown:
i = -1;
goto Do_Scale;
/* glyph index related keys */
case grKeyLeft:
i = -1;
goto Do_Glyph;
case grKeyRight:
i = 1;
goto Do_Glyph;
case grKeyF9:
i = -100;
goto Do_Glyph;
case grKeyF10:
i = 100;
goto Do_Glyph;
case grKeyF11:
i = -1000;
goto Do_Glyph;
case grKeyF12:
i = 1000;
goto Do_Glyph;
case grKeyLeft: i = -1; goto Do_Glyph;
case grKeyRight: i = 1; goto Do_Glyph;
case grKeyF9: i = -100; goto Do_Glyph;
case grKeyF10: i = 100; goto Do_Glyph;
case grKeyF11: i = -1000; goto Do_Glyph;
case grKeyF12: i = 1000; goto Do_Glyph;
default: default:
; ;
} }
return 1; return 1;
Do_Axis: Do_Axis:
if (axis < multimaster.num_axis) if ( axis < multimaster.num_axis )
{ {
FT_MM_Axis* a = multimaster.axis + axis; FT_MM_Axis* a = multimaster.axis + axis;
FT_Long pos = design_pos[axis]; FT_Long pos = design_pos[axis];
pos += i; pos += i;
if (pos < a->minimum) pos = a->minimum; if ( pos < a->minimum ) pos = a->minimum;
if (pos > a->maximum) pos = a->maximum; if ( pos > a->maximum ) pos = a->maximum;
design_pos[axis] = pos; design_pos[axis] = pos;
@ -532,20 +627,20 @@ $\243^\250*\265\371%!\247:/;.,?<>";
Do_Scale: Do_Scale:
ptsize += i; ptsize += i;
if (ptsize < 1) ptsize = 1; if ( ptsize < 1 ) ptsize = 1;
if (ptsize > MAXPTSIZE) ptsize = MAXPTSIZE; if ( ptsize > MAXPTSIZE ) ptsize = MAXPTSIZE;
return 1; return 1;
Do_Glyph: Do_Glyph:
Num += i; Num += i;
if (Num < 0) Num = 0; if ( Num < 0 ) Num = 0;
if (Num >= num_glyphs) Num = num_glyphs-1; if ( Num >= num_glyphs ) Num = num_glyphs - 1;
return 1; return 1;
} }
static
static void usage( char* execname ) void usage( char* execname )
{ {
fprintf( stderr, "\n" ); fprintf( stderr, "\n" );
fprintf( stderr, "ftmulti: multiple masters font viewer - part of FreeType\n" ); fprintf( stderr, "ftmulti: multiple masters font viewer - part of FreeType\n" );
@ -562,13 +657,13 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
int main( int argc, char** argv ) int
main( int argc,
char* argv[] )
{ {
int i, old_ptsize, orig_ptsize, file; int old_ptsize, orig_ptsize, file;
int first_glyph = 0; int first_glyph = 0;
int XisSetup = 0; int XisSetup = 0;
char filename[128 + 4];
char alt_filename[128 + 4];
char* execname; char* execname;
int option; int option;
int file_loaded; int file_loaded;
@ -616,7 +711,8 @@ $\243^\250*\265\371%!\247:/;.,?<>";
/* Initialize engine */ /* Initialize engine */
error = FT_Init_FreeType( &library ); error = FT_Init_FreeType( &library );
if (error) PanicZ( "Could not initialise FreeType library" ); if ( error )
PanicZ( "Could not initialize FreeType library" );
/* retrieve the standard raster's interface */ /* retrieve the standard raster's interface */
(void)FT_Get_Raster( library, ft_glyph_format_outline, &std_raster ); (void)FT_Get_Raster( library, ft_glyph_format_outline, &std_raster );
@ -627,61 +723,44 @@ $\243^\250*\265\371%!\247:/;.,?<>";
hinted = 1; hinted = 1;
file_loaded = 0; file_loaded = 0;
#ifndef macintosh
i = strlen( argv[file] );
while ( i > 0 && argv[file][i] != '\\' && argv[file][i] != '/' )
{
if ( argv[file][i] == '.' )
i = 0;
i--;
}
#endif
filename[128] = '\0';
alt_filename[128] = '\0';
strncpy( filename, argv[file], 128 );
strncpy( alt_filename, argv[file], 128 );
#ifndef macintosh
if ( i >= 0 )
{
strncpy( filename + strlen( filename ), ".ttf", 4 );
strncpy( alt_filename + strlen( alt_filename ), ".ttc", 4 );
}
#endif
/* Load face */ /* Load face */
error = FT_New_Face( library, filename, 0, &face ); error = FT_New_Face( library, argv[file], 0, &face );
if (error) goto Display_Font; if ( error )
goto Display_Font;
/* retrieve multiple master information */ /* retrieve multiple master information */
error = FT_Get_Multi_Master( face, &multimaster ); error = FT_Get_Multi_Master( face, &multimaster );
if (error) goto Display_Font; if ( error )
goto Display_Font;
/* set the current position to the minimum of each axis */ /* set the current position to the median of each axis */
{ {
int n; int n;
for ( n = 0; n < multimaster.num_axis; n++ ) for ( n = 0; n < multimaster.num_axis; n++ )
design_pos[n] = design_pos[n] =
(multimaster.axis[n].minimum + multimaster.axis[n].maximum)/2; ( multimaster.axis[n].minimum + multimaster.axis[n].maximum ) / 2;
} }
error = FT_Set_MM_Design_Coordinates( face, multimaster.num_axis, design_pos ); error = FT_Set_MM_Design_Coordinates( face,
if (error) goto Display_Font; multimaster.num_axis,
design_pos );
if ( error )
goto Display_Font;
file_loaded++; file_loaded++;
error = Reset_Scale( ptsize ); error = Reset_Scale( ptsize );
if (error) goto Display_Font; if ( error )
goto Display_Font;
num_glyphs = face->num_glyphs; num_glyphs = face->num_glyphs;
glyph = face->glyph; glyph = face->glyph;
size = face->size; size = face->size;
Display_Font: Display_Font:
/* initialise graphics if needed */ /* initialize graphics if needed */
if ( !XisSetup ) if ( !XisSetup )
{ {
XisSetup = 1; XisSetup = 1;
@ -697,7 +776,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
Num = first_glyph; Num = first_glyph;
if ( Num >= num_glyphs ) if ( Num >= num_glyphs )
Num = num_glyphs-1; Num = num_glyphs - 1;
if ( Num < 0 ) if ( Num < 0 )
Num = 0; Num = 0;
@ -707,26 +786,27 @@ $\243^\250*\265\371%!\247:/;.,?<>";
{ {
int key; int key;
Clear_Display(); Clear_Display();
if ( file_loaded >= 1 ) if ( file_loaded >= 1 )
{ {
switch (render_mode) switch ( render_mode )
{ {
case 0: case 0:
Render_Text( Num, ptsize ); Render_Text( Num, ptsize );
break; break;
default: default:
Render_All( Num, ptsize ); Render_All( Num, ptsize );
} }
sprintf( Header, "%s %s (file %s)", sprintf( Header, "%s %s (file %s)",
face->family_name, face->family_name,
face->style_name, face->style_name,
ft_basename( filename ) ); ft_basename( argv[file] ) );
if (!new_header) if ( !new_header )
new_header = Header; new_header = Header;
grWriteCellString( &bit, 0, 0, new_header, fore_color ); grWriteCellString( &bit, 0, 0, new_header, fore_color );
@ -735,10 +815,16 @@ $\243^\250*\265\371%!\247:/;.,?<>";
sprintf( Header, "axis: " ); sprintf( Header, "axis: " );
{ {
int n; int n;
for ( n = 0; n < multimaster.num_axis; n++ ) for ( n = 0; n < multimaster.num_axis; n++ )
{ {
char temp[32]; char temp[32];
sprintf( temp, " %s:%ld", multimaster.axis[n].name, design_pos[n] );
sprintf( temp, " %s:%ld",
multimaster.axis[n].name,
design_pos[n] );
strcat( Header, temp ); strcat( Header, temp );
} }
} }
@ -750,8 +836,8 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
else else
{ {
sprintf( Header, "%s : is not a multiple masters font file or could not be opened", sprintf( Header, "%s : not an MM font file, or could not be opened",
ft_basename(filename) ); ft_basename( argv[file] ) );
} }
grWriteCellString( &bit, 0, 8, Header, fore_color ); grWriteCellString( &bit, 0, 8, Header, fore_color );
@ -759,11 +845,11 @@ $\243^\250*\265\371%!\247:/;.,?<>";
grListenSurface( surface, 0, &event ); grListenSurface( surface, 0, &event );
if ( !( key = Process_Event( &event ) ) ) if ( !( key = Process_Event( &event ) ) )
goto Fin; goto End;
if ( key == 'n' ) if ( key == 'n' )
{ {
if (file_loaded >= 1) if ( file_loaded >= 1 )
FT_Done_Face( face ); FT_Done_Face( face );
if ( file < argc - 1 ) if ( file < argc - 1 )
@ -774,7 +860,7 @@ $\243^\250*\265\371%!\247:/;.,?<>";
if ( key == 'p' ) if ( key == 'p' )
{ {
if (file_loaded >= 1) if ( file_loaded >= 1 )
FT_Done_Face( face ); FT_Done_Face( face );
if ( file > 1 ) if ( file > 1 )
@ -792,11 +878,12 @@ $\243^\250*\265\371%!\247:/;.,?<>";
} }
} }
Fin: End:
#if 0 #if 0
grDoneSurface(surface); grDoneSurface( surface );
grDone(); grDone();
#endif #endif
printf( "Execution completed successfully.\n" ); printf( "Execution completed successfully.\n" );
printf( "Fails = %d\n", Fail ); printf( "Fails = %d\n", Fail );
@ -806,4 +893,3 @@ $\243^\250*\265\371%!\247:/;.,?<>";
/* End */ /* End */

View File

@ -645,7 +645,7 @@
lo = x->lo; lo = x->lo;
if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */ if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */
return ( s < 0 ) ? 0x80000001L : 0x7FFFFFFFL; return ( s < 0 ) ? 0x80000001UL : 0x7FFFFFFFUL;
/* Return Max/Min Int32 if division overflow. */ /* Return Max/Min Int32 if division overflow. */
/* This includes division by zero! */ /* This includes division by zero! */
q = 0; q = 0;

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
FT_EXPORT_FUNC(void) FT_Message( const char* fmt, ... ) FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... )
{ {
va_list ap; va_list ap;
@ -42,7 +42,7 @@
} }
FT_EXPORT_FUNC(void) FT_Panic( const char* fmt, ... ) FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... )
{ {
va_list ap; va_list ap;
@ -72,8 +72,8 @@
/* components will be traced. */ /* components will be traced. */
/* level :: The tracing level. */ /* level :: The tracing level. */
/* */ /* */
FT_EXPORT_FUNC(void) FT_SetTraceLevel( FT_Trace component, FT_EXPORT_FUNC( void ) FT_SetTraceLevel( FT_Trace component,
char level ) char level )
{ {
if ( component >= trace_max ) if ( component >= trace_max )
return; return;