X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideo_output%2Fvideo_text.c;h=438e0e1bb4720266f85178b813907d7eaf4a89cb;hb=bf66a55e059f6750a78b77195f3697520568559f;hp=fcd4bc4b8a805f5d3a6aebb704c535a6031eb11d;hpb=3d727062959d67e50acea7df103872b0db9c0dba;p=vlc diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index fcd4bc4b8a..438e0e1bb4 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -1,8 +1,8 @@ /***************************************************************************** * video_text.c : text manipulation functions ***************************************************************************** - * Copyright (C) 1999, 2000 VideoLAN - * $Id: video_text.c,v 1.25 2001/04/27 19:29:11 massiot Exp $ + * Copyright (C) 1999-2001 VideoLAN + * $Id: video_text.c,v 1.41 2002/12/06 10:10:40 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -22,31 +22,34 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ +/* XXX: unused */ +#if 0 /***************************************************************************** * Preamble *****************************************************************************/ -#include "defs.h" - -#include /* errno */ #include /* free() */ #include /* sprintf() */ #include /* strerror() */ -#include /* open() */ -#include /* read(), close() */ -#ifdef SYS_BEOS -# include "beos_specific.h" +#include + +#ifdef HAVE_ERRNO_H +# include /* errno */ #endif -#ifdef SYS_DARWIN1_3 -# include "darwin_specific.h" +#ifdef HAVE_FCNTL_H +# include /* open() */ #endif -#include "config.h" -#include "common.h" -#include "video_text.h" +#ifdef HAVE_UNISTD_H +# include /* read(), close() */ +#elif defined( WIN32 ) && !defined( UNDER_CE ) +# include +#endif -#include "intf_msg.h" +#include "video.h" +#include "video_output.h" +#include "video_text.h" /***************************************************************************** * vout_font_t: bitmap font @@ -58,7 +61,7 @@ * Therefore the border masks can't be complete if the font has pixels on the * border. *****************************************************************************/ -typedef struct vout_font_s +struct vout_font_t { int i_type; /* font type */ int i_width; /* character width in pixels */ @@ -69,7 +72,7 @@ typedef struct vout_font_s u16 i_first; /* first character */ u16 i_last; /* last character */ byte_t * p_data; /* font character data */ -} vout_font_t; +}; /* Font types */ #define VOUT_FIXED_FONT 0 /* simple fixed font */ @@ -212,13 +215,13 @@ static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, * This function will try to open a .psf font and load it. It will return * NULL on error. *****************************************************************************/ -vout_font_t *vout_LoadFont( const char *psz_name ) +vout_font_t *vout_LoadFont( vout_thread_t *p_vout, const char *psz_name ) { static char * path[] = { "share", DATA_PATH, NULL, NULL }; char ** ppsz_path = path; char * psz_file; -#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 ) +#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) char * psz_vlcpath = system_GetProgramPath(); int i_vlclen = strlen( psz_vlcpath ); #endif @@ -229,7 +232,7 @@ vout_font_t *vout_LoadFont( const char *psz_name ) for( ; *ppsz_path != NULL ; ppsz_path++ ) { -#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 ) +#if defined( SYS_BEOS ) || defined( SYS_DARWIN ) /* Under BeOS, we need to add beos_GetProgramPath() to access * files under the current directory */ if( strncmp( *ppsz_path, "/", 1 ) ) @@ -254,7 +257,9 @@ vout_font_t *vout_LoadFont( const char *psz_name ) } /* Open file */ +#ifndef UNDER_CE /* FIXME */ i_file = open( psz_file, O_RDONLY ); +#endif free( psz_file ); if( i_file != -1 ) @@ -265,26 +270,32 @@ vout_font_t *vout_LoadFont( const char *psz_name ) if( i_file == -1 ) { - intf_DbgMsg( "vout error: can't open file '%s' (%s)", - psz_name, strerror(errno) ); +#ifdef HAVE_ERRNO_H + msg_Err( p_vout, "cannot open '%s' (%s)", psz_name, strerror(errno) ); +#else + msg_Err( p_vout, "cannot open '%s'", psz_name ); +#endif return( NULL ); } - /* Read magick number */ + /* Read magic number */ +#ifndef UNDER_CE /* FIXME */ if( read( i_file, pi_buffer, 2 ) != 2 ) { - intf_ErrMsg("vout error: unexpected end of file '%s'", psz_name ); + msg_Err( p_vout, "unexpected end of file in '%s'", psz_name ); close( i_file ); return( NULL ); } +#endif /* Allocate font descriptor */ p_font = malloc( sizeof( vout_font_t ) ); if( p_font == NULL ) { - intf_ErrMsg( "vout error: cannot allocate vout_font_t (%s)", - strerror(ENOMEM) ); + msg_Err( p_vout, "out of memory" ); +#ifndef UNDER_CE /* FIXME */ close( i_file ); +#endif return( NULL ); } @@ -298,13 +309,15 @@ vout_font_t *vout_LoadFont( const char *psz_name ) */ /* Read font header - two bytes indicate the font properties */ +#ifndef UNDER_CE /* FIXME */ if( read( i_file, pi_buffer, 2 ) != 2) { - intf_ErrMsg( "vout error: unexpected end of file '%s'", psz_name ); + msg_Err( p_vout, "unexpected end of file in '%s'", psz_name ); free( p_font ); close( i_file ); return( NULL ); } +#endif /* Copy font properties */ p_font->i_type = VOUT_FIXED_FONT; @@ -320,26 +333,29 @@ vout_font_t *vout_LoadFont( const char *psz_name ) p_font->p_data = malloc( 2 * 256 * pi_buffer[1] ); if( p_font->p_data == NULL ) { - intf_ErrMsg( "vout error: cannot allocate font space (%s)", - strerror(ENOMEM) ); + msg_Err( p_vout, "out of memory" ); free( p_font ); +#ifndef UNDER_CE /* FIXME */ close( i_file ); +#endif return( NULL ); } /* Copy raw data */ +#ifndef UNDER_CE /* FIXME */ if( read( i_file, p_font->p_data, 256 * pi_buffer[1] ) != 256 * pi_buffer[1] ) { - intf_ErrMsg("vout error: unexpected end of file '%s'", psz_name ); + msg_Err( p_vout, "unexpected end of file in '%s'", psz_name ); free( p_font->p_data ); free( p_font ); close( i_file ); return( NULL ); } +#endif - /* Computes border masks - remember that masks have the same matrix as - * characters, so an empty character border is required to have a complete - * border mask. */ + /* Compute border masks - remember that masks have the same matrix as + * characters, so an empty character border is required to have a + * complete border mask. */ for( i_char = 0; i_char <= 255; i_char++ ) { for( i_line = 0; i_line < pi_buffer[1]; i_line++ ) @@ -356,16 +372,18 @@ vout_font_t *vout_LoadFont( const char *psz_name ) break; default: - intf_ErrMsg("vout error: file '%s' has an unknown format", psz_name ); + msg_Err( p_vout, "file '%s' has an unknown format", psz_name ); free( p_font ); +#ifndef UNDER_CE /* FIXME */ close( i_file ); +#endif return( NULL ); break; } + msg_Err( p_vout, "loaded %s, type %d, %d-%dx%d", psz_name, p_font->i_type, + p_font->i_width, p_font->i_interspacing, p_font->i_height ); - intf_DbgMsg( "loaded %s: type %d, %d-%dx%d", psz_name, p_font->i_type, - p_font->i_width, p_font->i_interspacing, p_font->i_height ); return( p_font ); } @@ -382,7 +400,6 @@ void vout_UnloadFont( vout_font_t *p_font ) return; } - intf_DbgMsg( "vout: unloading font %p", p_font ); free( p_font->p_data ); free( p_font ); } @@ -413,11 +430,6 @@ void vout_TextSize( vout_font_t *p_font, int i_style, const char *psz_text, int *pi_width = *pi_height / 3; } break; -#ifdef DEBUG - default: - intf_ErrMsg("error: unknown font type %d", p_font->i_type ); - break; -#endif } } @@ -430,13 +442,13 @@ void vout_TextSize( vout_font_t *p_font, int i_style, const char *psz_text, int void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int i_bytes_per_line, u32 i_char_color, u32 i_border_color, u32 i_bg_color, int i_style, const char *psz_text, int i_percent) { - byte_t *p_char, *p_border; /* character and border mask data */ - int i_char_mask, i_border_mask, i_bg_mask; /* masks */ - int i_line; /* current line in character */ - int i_byte; /* current byte in character */ - int i_interspacing; /* offset between two chars */ - int i_font_bytes_per_line, i_font_height; /* font properties */ - int i_position, i_end; /* current position */ + byte_t *p_char, *p_border; /* character and border mask data */ + int i_char_mask, i_border_mask, i_bg_mask; /* masks */ + int i_line; /* current line in character */ + int i_byte; /* current byte in character */ + int i_interspacing; /* offset between two chars */ + int i_font_bytes_per_line, i_font_height; /* font properties */ + unsigned int i_position, i_end; /* current position */ vout_put_byte_t *p_PutByte; /* PutByte function */ /* If no font was loaded, do nothing */ @@ -477,7 +489,7 @@ void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int p_font->i_interspacing); /* compute where to stop... */ - i_end = (int) (i_percent * strlen(psz_text) / 100LL); + i_end = (int) (i_percent * strlen(psz_text) / (s64)100); if(i_end > strlen(psz_text)) i_end = strlen(psz_text); @@ -528,14 +540,8 @@ void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int /* Jump to next character */ p_pic += i_interspacing; break; -#ifdef DEBUG - default: - intf_ErrMsg("error: unknown font type %d", p_font->i_type ); - break; -#endif } } - } } @@ -599,4 +605,4 @@ static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, b PUT_BYTE_MASK(i_border, i_border_color); PUT_BYTE_MASK(i_bg, i_bg_color); } - +#endif