* 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 <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+/* XXX: unused */
+#if 0
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <errno.h> /* errno */
#include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
-#include <fcntl.h> /* open() */
-#include <videolan/vlc.h>
+#include <vlc/vlc.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h> /* read(), close() */
-#elif defined( _MSC_VER ) && defined( _WIN32 )
-# include <io.h>
+#ifdef HAVE_ERRNO_H
+# include <errno.h> /* errno */
#endif
-#if defined( WIN32 )
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h> /* open() */
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h> /* read(), close() */
+#elif defined( WIN32 ) && !defined( UNDER_CE )
# include <io.h>
#endif
+#include "video.h"
+#include "video_output.h"
#include "video_text.h"
/*****************************************************************************
* 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 */
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 */
* 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 */
}
/* Open file */
+#ifndef UNDER_CE /* FIXME */
i_file = open( psz_file, O_RDONLY );
+#endif
free( psz_file );
if( i_file != -1 )
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 );
}
*/
/* 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;
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++ )
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 );
}
*pi_width = *pi_height / 3;
}
break;
-#ifdef DEBUG
- default:
- intf_ErrMsg("error: unknown font type %d", p_font->i_type );
- break;
-#endif
}
}
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 */
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);
/* 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
}
}
-
}
}
PUT_BYTE_MASK(i_border, i_border_color);
PUT_BYTE_MASK(i_bg, i_bg_color);
}
-
+#endif