X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fvideo_output%2Fvideo_text.c;h=62315fed472b2720f26284b5b24cf9ef79ab1607;hb=c4d9a444ff76374c7bf9487bdc95a9fa0a4a6868;hp=ee34bd7615759bf347f69a6b73925be2b5c46953;hpb=730cc399c5a7320cce2999bf035294c075d14370;p=vlc diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index ee34bd7615..62315fed47 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -2,7 +2,7 @@ * video_text.c : text manipulation functions ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: video_text.c,v 1.34 2002/02/19 00:50:20 sam Exp $ + * $Id: video_text.c,v 1.42 2003/01/19 03:16:24 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -22,27 +22,33 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ +/* XXX: unused */ +#if 0 /***************************************************************************** * Preamble *****************************************************************************/ -#include /* errno */ #include /* free() */ #include /* sprintf() */ #include /* strerror() */ -#include /* open() */ -#include +#include -#ifdef HAVE_UNISTD_H -# include /* read(), close() */ -#elif defined( _MSC_VER ) && defined( _WIN32 ) -# include +#ifdef HAVE_ERRNO_H +# include /* errno */ #endif -#if defined( WIN32 ) +#ifdef HAVE_FCNTL_H +# include /* open() */ +#endif + +#ifdef HAVE_UNISTD_H +# include /* read(), close() */ +#elif defined( WIN32 ) && !defined( UNDER_CE ) # include #endif +#include "video.h" +#include "video_output.h" #include "video_text.h" /***************************************************************************** @@ -55,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 */ @@ -66,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 */ @@ -209,14 +215,14 @@ 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_DARWIN ) - char * psz_vlcpath = system_GetProgramPath(); + char * psz_vlcpath = p_this->p_libvlc->psz_vlcpath; int i_vlclen = strlen( psz_vlcpath ); #endif int i_char, i_line; /* character and line indexes */ @@ -251,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 ) @@ -262,26 +270,32 @@ vout_font_t *vout_LoadFont( const char *psz_name ) if( i_file == -1 ) { - intf_ErrMsg( "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 ); } @@ -295,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; @@ -317,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++ ) @@ -353,15 +372,17 @@ 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; } - intf_ErrMsg( "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 ); + 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 ); return( p_font ); } @@ -409,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 } } @@ -426,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 */ @@ -473,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) / I64C(100)); + i_end = (int) (i_percent * strlen(psz_text) / (s64)100); if(i_end > strlen(psz_text)) i_end = strlen(psz_text); @@ -524,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 } } - } } @@ -595,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