* video_text.c : text manipulation functions
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
+ * $Id: video_text.c,v 1.28 2001/05/31 03:12:49 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
#include <fcntl.h> /* open() */
-#include <unistd.h> /* read(), close() */
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h> /* read(), close() */
+#elif defined( _MSC_VER ) && defined( _WIN32 )
+# include <io.h>
+#endif
#ifdef SYS_BEOS
-#include "beos_specific.h"
+# include "beos_specific.h"
+#endif
+
+#ifdef SYS_DARWIN1_3
+# include "darwin_specific.h"
+#endif
+
+#if defined( WIN32 )
+# include <io.h>
#endif
#include "config.h"
*****************************************************************************/
vout_font_t *vout_LoadFont( const char *psz_name )
{
- static char * path[] = { "share", DATA_PATH, NULL };
+ static char * path[] = { "share", DATA_PATH, NULL, NULL };
char ** ppsz_path = path;
char * psz_file;
-#ifdef SYS_BEOS
- char * psz_vlcpath = beos_GetProgramPath();
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
+ char * psz_vlcpath = system_GetProgramPath();
int i_vlclen = strlen( psz_vlcpath );
#endif
int i_char, i_line; /* character and line indexes */
for( ; *ppsz_path != NULL ; ppsz_path++ )
{
-#ifdef SYS_BEOS
+#if defined( SYS_BEOS ) || defined( SYS_DARWIN1_3 )
/* Under BeOS, we need to add beos_GetProgramPath() to access
* files under the current directory */
if( strncmp( *ppsz_path, "/", 1 ) )
}
/* Open file */
+#ifndef WIN32
i_file = open( psz_file, O_RDONLY );
+#else
+ i_file = open( psz_file, O_RDONLY | O_BINARY );
+#endif
free( psz_file );
if( i_file != -1 )
*****************************************************************************/
void vout_UnloadFont( vout_font_t *p_font )
{
+ /* If no font was loaded, do nothing */
+ if( p_font == NULL )
+ {
+ return;
+ }
+
intf_DbgMsg( "vout: unloading font %p", p_font );
free( p_font->p_data );
free( p_font );
*****************************************************************************/
void vout_TextSize( vout_font_t *p_font, int i_style, const char *psz_text, int *pi_width, int *pi_height )
{
+ /* If no font was loaded, do nothing */
+ if( p_font == NULL )
+ {
+ *pi_width = *pi_height = 0;
+ return;
+ }
+
switch( p_font->i_type )
{
case VOUT_FIXED_FONT:
break;
#ifdef DEBUG
default:
- intf_DbgMsg("error: unknown font type %d", p_font->i_type );
+ intf_ErrMsg("error: unknown font type %d", p_font->i_type );
break;
#endif
}
int i_position, i_end; /* current position */
vout_put_byte_t *p_PutByte; /* PutByte function */
+ /* If no font was loaded, do nothing */
+ if( p_font == NULL )
+ {
+ return;
+ }
+
/* FIXME: background: can be something else that whole byte ?? */
/* Select output function */
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) / I64C(100));
if(i_end > strlen(psz_text))
i_end = strlen(psz_text);
break;
#ifdef DEBUG
default:
- intf_DbgMsg("error: unknown font type %d", p_font->i_type );
+ intf_ErrMsg("error: unknown font type %d", p_font->i_type );
break;
#endif
}