/*****************************************************************************
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
- * Copyright (C) 2002 - 2011 the VideoLAN team
+ * Copyright (C) 2002 - 2012 VLC authors and VideoLAN
* $Id$
*
* Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
* Gildas Bazin <gbazin@videolan.org>
* Bernie Purcell <bitmap@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
+ * Felix Paul Kühne <fkuehne@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
/* Default fonts */
#ifdef __APPLE__
-# define DEFAULT_FONT_FILE "/Library/Fonts/Arial Black.ttf"
-# define DEFAULT_FAMILY "Arial Black"
+# define DEFAULT_FONT_FILE "/Library/Fonts/Arial Unicode.ttf"
+# define DEFAULT_FAMILY "Arial Unicode MS"
#elif defined( WIN32 )
# define DEFAULT_FONT_FILE "arial.ttf" /* Default path font found at run-time */
# define DEFAULT_FAMILY "Arial"
+#elif defined( __OS2__ )
+# define DEFAULT_FONT_FILE "/psfonts/tnrwt_k.ttf"
+# define DEFAULT_FAMILY "Times New Roman WT K"
#elif defined( HAVE_MAEMO )
# define DEFAULT_FONT_FILE "/usr/share/fonts/nokia/nosnb.ttf"
# define DEFAULT_FAMILY "Nokia Sans Bold"
+#elif defined( __ANDROID__ )
+# define DEFAULT_FONT_FILE "/system/fonts/DroidSans-Bold.ttf"
+# define DEFAULT_FAMILY "Droid Sans Bold"
#else
# define DEFAULT_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf"
# define DEFAULT_FAMILY "Serif Bold"
#define FT_MulFix(v, s) (((v)*(s))>>16)
#endif
+/* apple stuff */
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+#include <sys/param.h> /* for MAXPATHLEN */
+#undef HAVE_FONTCONFIG
+#define HAVE_STYLES
+#endif
+
/* RTL */
#if defined(HAVE_FRIBIDI)
# include <fribidi/fribidi.h>
#include <assert.h>
+#ifdef __OS2__
+typedef uint16_t uni_char_t;
+# define FREETYPE_TO_UCS "UCS-2LE"
+#else
+typedef uint32_t uni_char_t;
+# if defined(WORDS_BIGENDIAN)
+# define FREETYPE_TO_UCS "UCS-4BE"
+# else
+# define FREETYPE_TO_UCS "UCS-4LE"
+# endif
+#endif
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
"that will be rendered on the video. " \
"If set to something different than 0 this option will override the " \
"relative font size." )
-#define OPACITY_TEXT N_("Opacity")
+#define OPACITY_TEXT N_("Text opacity")
#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of the " \
"text that will be rendered on the video. 0 = transparent, " \
"255 = totally opaque. " )
add_integer( "freetype-fontsize", 0, FONTSIZE_TEXT,
FONTSIZE_LONGTEXT, true )
+ change_integer_range( 0, 4096)
change_safe()
add_integer( "freetype-rel-fontsize", 16, FONTSIZER_TEXT,
change_safe()
/* hook to the color values list, with default 0x00ffffff = white */
- add_integer( "freetype-color", 0x00FFFFFF, COLOR_TEXT,
+ add_rgb( "freetype-color", 0x00FFFFFF, COLOR_TEXT,
COLOR_LONGTEXT, false )
change_integer_list( pi_color_values, ppsz_color_descriptions )
change_safe()
- add_bool( "freetype-bold", false, BOLD_TEXT, "", false )
+ add_bool( "freetype-bold", false, BOLD_TEXT, NULL, false )
change_safe()
add_integer_with_range( "freetype-background-opacity", 0, 0, 255,
- BG_OPACITY_TEXT, "", false )
+ BG_OPACITY_TEXT, NULL, false )
change_safe()
- add_integer( "freetype-background-color", 0x00000000, BG_COLOR_TEXT,
- "", false )
+ add_rgb( "freetype-background-color", 0x00000000, BG_COLOR_TEXT,
+ NULL, false )
change_integer_list( pi_color_values, ppsz_color_descriptions )
change_safe()
add_integer_with_range( "freetype-outline-opacity", 255, 0, 255,
- OUTLINE_OPACITY_TEXT, "", false )
+ OUTLINE_OPACITY_TEXT, NULL, false )
change_safe()
- add_integer( "freetype-outline-color", 0x00000000, OUTLINE_COLOR_TEXT,
- "", false )
+ add_rgb( "freetype-outline-color", 0x00000000, OUTLINE_COLOR_TEXT,
+ NULL, false )
change_integer_list( pi_color_values, ppsz_color_descriptions )
change_safe()
add_integer_with_range( "freetype-outline-thickness", 4, 0, 50, OUTLINE_THICKNESS_TEXT,
- "", false )
+ NULL, false )
change_integer_list( pi_outline_thickness, ppsz_outline_thickness )
change_safe()
add_integer_with_range( "freetype-shadow-opacity", 128, 0, 255,
- SHADOW_OPACITY_TEXT, "", false )
+ SHADOW_OPACITY_TEXT, NULL, false )
change_safe()
- add_integer( "freetype-shadow-color", 0x00000000, SHADOW_COLOR_TEXT,
- "", false )
+ add_rgb( "freetype-shadow-color", 0x00000000, SHADOW_COLOR_TEXT,
+ NULL, false )
change_integer_list( pi_color_values, ppsz_color_descriptions )
change_safe()
add_float_with_range( "freetype-shadow-angle", -45, -360, 360,
- SHADOW_ANGLE_TEXT, "", false )
+ SHADOW_ANGLE_TEXT, NULL, false )
change_safe()
add_float_with_range( "freetype-shadow-distance", 0.06, 0.0, 1.0,
- SHADOW_DISTANCE_TEXT, "", false )
+ SHADOW_DISTANCE_TEXT, NULL, false )
change_safe()
add_obsolete_integer( "freetype-effect" );
int i_default_font_size;
int i_display_height;
char* psz_fontfamily;
-#ifdef HAVE_STYLES
xml_reader_t *p_xml;
#ifdef WIN32
char* psz_win_fonts_path;
-#endif
#endif
input_attachment_t **pp_font_attachments;
mtime_t t1, t2;
t1 = mdate();
-#ifdef WIN32
+#ifdef __OS2__
+ FcInit();
+#endif
+
+#if defined( WIN32 ) || defined( __APPLE__ )
dialog_progress_bar_t *p_dialog = NULL;
FcConfig *fcConfig = FcInitLoadConfig();
dialog_ProgressSet( p_dialog, NULL, 0.5 ); */
FcConfigBuildFonts( fcConfig );
+#if defined( __APPLE__ )
+ // By default, scan only the directory /System/Library/Fonts.
+ // So build the set of available fonts under another directories,
+ // and add the set to the current configuration.
+ FcConfigAppFontAddDir( NULL, "~/Library/Fonts" );
+ FcConfigAppFontAddDir( NULL, "/Library/Fonts" );
+ FcConfigAppFontAddDir( NULL, "/Network/Library/Fonts" );
+ //FcConfigAppFontAddDir( NULL, "/System/Library/Fonts" );
+#endif
if( p_dialog )
{
// dialog_ProgressSet( p_dialog, NULL, 1.0 );
FcPattern *pat, *p_pat;
FcChar8* val_s;
FcBool val_b;
+ char *ret = NULL;
/* Create a pattern and fills it */
pat = FcPatternCreate();
"the requested one: '%s' != '%s'\n",
(const char*)val_s, family ); */
- if( FcResultMatch != FcPatternGetString( p_pat, FC_FILE, 0, &val_s ) )
- {
- FcPatternDestroy( p_pat );
- return NULL;
- }
+ if( FcResultMatch == FcPatternGetString( p_pat, FC_FILE, 0, &val_s ) )
+ ret = strdup( (const char*)val_s );
FcPatternDestroy( p_pat );
- return strdup( (const char*)val_s );
+ return ret;
}
#endif
#ifdef WIN32
-#define UNICODE
#define FONT_DIR_NT "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
static int GetFileFontByName( const char *font_name, char **psz_filename )
wchar_t vbuffer[MAX_PATH];
wchar_t dbuffer[256];
- if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey) != ERROR_SUCCESS )
+ if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey)
+ != ERROR_SUCCESS )
return 1;
+ MultiByteToWideChar( CP_ACP, 0, font_name, -1, dbuffer, 256 );
+ char *font_name_temp = FromWide( dbuffer );
+ size_t fontname_len = strlen( font_name_temp );
+
for( int index = 0;; index++ )
{
DWORD vbuflen = MAX_PATH - 1;
DWORD dbuflen = 255;
- if( RegEnumValueW( hKey, index, vbuffer, &vbuflen,
- NULL, NULL, (LPBYTE)dbuffer, &dbuflen) != ERROR_SUCCESS )
- return 2;
+ LONG i_result = RegEnumValueW( hKey, index, vbuffer, &vbuflen,
+ NULL, NULL, (LPBYTE)dbuffer, &dbuflen);
+ if( i_result != ERROR_SUCCESS )
+ {
+ RegCloseKey( hKey );
+ return i_result;
+ }
char *psz_value = FromWide( vbuffer );
/* Manage concatenated font names */
if( strchr( psz_value, '&') ) {
- if( strcasestr( psz_value, font_name ) != NULL )
+ if( strcasestr( psz_value, font_name_temp ) != NULL )
+ {
+ free( psz_value );
break;
+ }
}
else {
- if( strcasecmp( psz_value, font_name ) == 0 )
+ if( strncasecmp( psz_value, font_name_temp, fontname_len ) == 0 )
+ {
+ free( psz_value );
break;
+ }
}
+
+ free( psz_value );
}
*psz_filename = FromWide( dbuffer );
+ free( font_name_temp );
+ RegCloseKey( hKey );
return 0;
}
bool b_bold, bool b_italic, int i_size, int *i_idx )
{
VLC_UNUSED( i_size );
- // msg_Dbg( p_filter, "Here in Win32_Select, asking for %s", family );
+
+ if( !family || strlen( family ) < 1 )
+ goto fail;
/* */
LOGFONT lf;
lf.lfItalic = true;
if( b_bold )
lf.lfWeight = FW_BOLD;
- strncpy( (LPSTR)&lf.lfFaceName, family, 32);
+
+ char facename[32];
+ wchar_t* psz_fbuffer = ToWide( family );
+ WideCharToMultiByte( CP_ACP, 0, psz_fbuffer, -1, facename, 32, " ", 0 );
+ strncpy( (LPSTR)&lf.lfFaceName, facename, 32 );
+ free( psz_fbuffer );
/* */
char *psz_filename = NULL;
EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)&EnumFontCallback, (LPARAM)&psz_filename, 0);
ReleaseDC(NULL, hDC);
- if( psz_filename == NULL )
+ /* */
+ if( psz_filename != NULL )
+ {
+ /* FIXME: increase i_idx, when concatenated strings */
+ i_idx = 0;
+
+ /* Prepend the Windows Font path, when only a filename was provided */
+ if( strchr( psz_filename, DIR_SEP_CHAR ) )
+ return psz_filename;
+ else
+ {
+ char *psz_tmp;
+ if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, psz_filename ) == -1 )
+ {
+ free( psz_filename );
+ return NULL;
+ }
+ free( psz_filename );
+ return psz_tmp;
+ }
+ }
+ else /* Let's take any font we can */
+fail:
+ {
+ char *psz_tmp;
+ if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, "arial.ttf" ) == -1 )
+ return NULL;
+ else
+ return psz_tmp;
+ }
+}
+#endif /* HAVE_WIN32 */
+
+#ifdef __APPLE__
+static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
+ bool b_bold, bool b_italic, int i_size, int *i_idx )
+{
+ VLC_UNUSED( b_bold );
+ VLC_UNUSED( b_italic );
+ VLC_UNUSED( i_size );
+ FSRef ref;
+ unsigned char path[MAXPATHLEN];
+ char * psz_path;
+
+ CFStringRef cf_fontName;
+ ATSFontRef ats_font_id;
+
+ *i_idx = 0;
+
+ if( psz_fontname == NULL )
return NULL;
- /* FIXME: increase i_idx, when concatenated strings */
- i_idx = 0;
+ msg_Dbg( p_filter, "looking for %s", psz_fontname );
+ cf_fontName = CFStringCreateWithCString( kCFAllocatorDefault, psz_fontname, kCFStringEncodingUTF8 );
- /* */
- char *psz_tmp;
- if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, psz_filename ) == -1 )
+ ats_font_id = ATSFontFindFromName( cf_fontName, kATSOptionFlagsIncludeDisabledMask );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Dbg( p_filter, "ATS couldn't find %s by name, checking family", psz_fontname );
+ ats_font_id = ATSFontFamilyFindFromName( cf_fontName, kATSOptionFlagsDefault );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Dbg( p_filter, "ATS couldn't find either %s nor its family, checking PS name", psz_fontname );
+ ats_font_id = ATSFontFindFromPostScriptName( cf_fontName, kATSOptionFlagsDefault );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Err( p_filter, "ATS couldn't find %s (no font name, family or PS name)", psz_fontname );
+ CFRelease( cf_fontName );
+ return NULL;
+ }
+ }
+ }
+ CFRelease( cf_fontName );
+
+ if ( noErr != ATSFontGetFileReference( ats_font_id, &ref ) )
+ {
+ msg_Err( p_filter, "ATS couldn't get file ref for %s", psz_fontname );
return NULL;
- return psz_tmp;
+ }
+
+ /* i_idx calculation by searching preceding fontIDs */
+ /* with same FSRef */
+ {
+ ATSFontRef id2 = ats_font_id - 1;
+ FSRef ref2;
+
+ while ( id2 > 0 )
+ {
+ if ( noErr != ATSFontGetFileReference( id2, &ref2 ) )
+ break;
+ if ( noErr != FSCompareFSRefs( &ref, &ref2 ) )
+ break;
+
+ id2 --;
+ }
+ *i_idx = ats_font_id - ( id2 + 1 );
+ }
+
+ if ( noErr != FSRefMakePath( &ref, path, sizeof(path) ) )
+ {
+ msg_Err( p_filter, "failure when getting path from FSRef" );
+ return NULL;
+ }
+ msg_Dbg( p_filter, "found %s", path );
+
+ psz_path = strdup( (char *)path );
+
+ return psz_path;
}
#endif
-#endif
+#endif /* HAVE_STYLES */
/*****************************************************************************
&i_karaoke_bg_color ))
{
psz_fontname = strdup( psz_fontname );
- i_font_size = i_font_size;
}
i_font_alpha = (i_font_color >> 24) & 0xff;
i_font_color &= 0x00ffffff;
}
static unsigned SetupText( filter_t *p_filter,
- uint32_t *psz_text_out,
+ uni_char_t *psz_text_out,
text_style_t **pp_styles,
uint32_t *pi_k_dates,
size_t i_string_length;
size_t i_string_bytes;
-#if defined(WORDS_BIGENDIAN)
- uint32_t *psz_tmp = ToCharset( "UCS-4BE", psz_text_in, &i_string_bytes );
-#else
- uint32_t *psz_tmp = ToCharset( "UCS-4LE", psz_text_in, &i_string_bytes );
-#endif
+ uni_char_t *psz_tmp = ToCharset( FREETYPE_TO_UCS, psz_text_in, &i_string_bytes );
if( psz_tmp )
{
memcpy( psz_text_out, psz_tmp, i_string_bytes );
- i_string_length = i_string_bytes / 4;
+ i_string_length = i_string_bytes / sizeof( *psz_tmp );
free( psz_tmp );
}
else
}
static int ProcessNodes( filter_t *p_filter,
- uint32_t *psz_text,
+ uni_char_t *psz_text,
text_style_t **pp_styles,
uint32_t *pi_k_dates,
int *pi_len,
STYLE_UNDERLINE |
STYLE_STRIKEOUT);
}
-#ifdef HAVE_STYLES
else
{
rv = PushFont( &p_fonts,
((p_sys->i_font_opacity & 0xff) << 24),
0x00ffffff );
}
-#endif
if( p_sys->b_font_bold )
i_style_flags |= STYLE_BOLD;
int i_style_received = ((p_face->style_flags & FT_STYLE_FLAG_BOLD) ? STYLE_BOLD : 0) |
((p_face->style_flags & FT_STYLE_FLAG_ITALIC ) ? STYLE_ITALIC : 0);
if( !strcasecmp( p_face->family_name, p_style->psz_fontname ) &&
- (p_style->i_style_flags & (STYLE_BOLD | STYLE_BOLD)) == i_style_received )
+ (p_style->i_style_flags & (STYLE_BOLD | STYLE_ITALIC)) == i_style_received )
return p_face;
FT_Done_Face( p_face );
if( !p_face )
{
int i_idx = 0;
- char *psz_fontfile;
+ char *psz_fontfile = NULL;
#ifdef HAVE_FONTCONFIG
psz_fontfile = FontConfig_Select( NULL,
p_style->psz_fontname,
(p_style->i_style_flags & STYLE_ITALIC) != 0,
-1,
&i_idx );
+#elif defined( __APPLE__ )
+ psz_fontfile = MacLegacy_Select( p_filter, p_style->psz_fontname, false, false, -1, &i_idx );
#elif defined( WIN32 )
psz_fontfile = Win32_Select( p_filter,
p_style->psz_fontname,
FT_BBox *p_bbox,
int *pi_max_face_height,
- uint32_t *psz_text,
+ uni_char_t *psz_text,
text_style_t **pp_styles,
uint32_t *pi_k_dates,
int i_len )
{
filter_sys_t *p_sys = p_filter->p_sys;
- uint32_t *p_fribidi_string = NULL;
+ uni_char_t *p_fribidi_string = NULL;
text_style_t **pp_fribidi_styles = NULL;
int *p_new_positions = NULL;
while( i_part_length > 0 )
{
const text_style_t *p_glyph_style = pp_styles[i_index];
- uint32_t character = psz_text[i_index];
+ uni_char_t character = psz_text[i_index];
int i_glyph_index = FT_Get_Char_Index( p_current_face, character );
/* Get kerning vector */
const size_t i_text_max = strlen( b_html ? p_region_in->psz_html
: p_region_in->psz_text );
- uint32_t *psz_text = calloc( i_text_max, sizeof( *psz_text ) );
+ uni_char_t *psz_text = calloc( i_text_max, sizeof( *psz_text ) );
text_style_t **pp_styles = calloc( i_text_max, sizeof( *pp_styles ) );
if( !psz_text || !pp_styles )
{
uint32_t *pi_k_durations = NULL;
-#ifdef HAVE_STYLES
if( b_html )
{
stream_t *p_sub = stream_MemoryNew( VLC_OBJECT(p_filter),
stream_Delete( p_sub );
}
else
-#endif
{
text_style_t *p_style;
if( p_region_in->p_style )
return RenderCommon( p_filter, p_region_out, p_region_in, false, p_chroma_list );
}
-#ifdef HAVE_STYLES
-
static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
subpicture_region_t *p_region_in,
const vlc_fourcc_t *p_chroma_list )
return RenderCommon( p_filter, p_region_out, p_region_in, true, p_chroma_list );
}
-#endif
-
/*****************************************************************************
* Create: allocates osd-text video thread output method
*****************************************************************************
return VLC_ENOMEM;
p_sys->psz_fontfamily = NULL;
-#ifdef HAVE_STYLES
p_sys->p_xml = NULL;
-#endif
p_sys->p_face = 0;
p_sys->p_library = 0;
p_sys->i_font_size = 0;
psz_fontfamily = var_InheritString( p_filter, "freetype-font" );
p_sys->i_default_font_size = var_InheritInteger( p_filter, "freetype-fontsize" );
p_sys->i_font_opacity = var_InheritInteger( p_filter,"freetype-opacity" );
- p_sys->i_font_opacity = __MAX( __MIN( p_sys->i_font_opacity, 255 ), 0 );
+ p_sys->i_font_opacity = VLC_CLIP( p_sys->i_font_opacity, 0, 255 );
p_sys->i_font_color = var_InheritInteger( p_filter, "freetype-color" );
- p_sys->i_font_color = __MAX( __MIN( p_sys->i_font_color , 0xFFFFFF ), 0 );
+ p_sys->i_font_color = VLC_CLIP( p_sys->i_font_color, 0, 0xFFFFFF );
p_sys->b_font_bold = var_InheritBool( p_filter, "freetype-bold" );
p_sys->i_background_opacity = var_InheritInteger( p_filter,"freetype-background-opacity" );;
- p_sys->i_background_opacity = __MAX( __MIN( p_sys->i_background_opacity, 255 ), 0 );
+ p_sys->i_background_opacity = VLC_CLIP( p_sys->i_background_opacity, 0, 255 );
p_sys->i_background_color = var_InheritInteger( p_filter, "freetype-background-color" );
- p_sys->i_background_color = __MAX( __MIN( p_sys->i_background_color, 0xFFFFFF ), 0 );
+ p_sys->i_background_color = VLC_CLIP( p_sys->i_background_color, 0, 0xFFFFFF );
p_sys->f_outline_thickness = var_InheritInteger( p_filter, "freetype-outline-thickness" ) / 100.0;
- p_sys->f_outline_thickness = __MAX( __MIN( p_sys->f_outline_thickness, 0.5 ), 0.0 );
+ p_sys->f_outline_thickness = VLC_CLIP( p_sys->f_outline_thickness, 0.0, 0.5 );
p_sys->i_outline_opacity = var_InheritInteger( p_filter, "freetype-outline-opacity" );
- p_sys->i_outline_opacity = __MAX( __MIN( p_sys->i_outline_opacity, 255 ), 0 );
+ p_sys->i_outline_opacity = VLC_CLIP( p_sys->i_outline_opacity, 0, 255 );
p_sys->i_outline_color = var_InheritInteger( p_filter, "freetype-outline-color" );
- p_sys->i_outline_color = __MAX( __MIN( p_sys->i_outline_color, 0xFFFFFF ), 0 );
+ p_sys->i_outline_color = VLC_CLIP( p_sys->i_outline_color, 0, 0xFFFFFF );
p_sys->i_shadow_opacity = var_InheritInteger( p_filter, "freetype-shadow-opacity" );
- p_sys->i_shadow_opacity = __MAX( __MIN( p_sys->i_shadow_opacity, 255 ), 0 );
+ p_sys->i_shadow_opacity = VLC_CLIP( p_sys->i_shadow_opacity, 0, 255 );
p_sys->i_shadow_color = var_InheritInteger( p_filter, "freetype-shadow-color" );
- p_sys->i_shadow_color = __MAX( __MIN( p_sys->i_shadow_color, 0xFFFFFF ), 0 );
+ p_sys->i_shadow_color = VLC_CLIP( p_sys->i_shadow_color, 0, 0xFFFFFF );
float f_shadow_angle = var_InheritFloat( p_filter, "freetype-shadow-angle" );
float f_shadow_distance = var_InheritFloat( p_filter, "freetype-shadow-distance" );
- f_shadow_distance = __MAX( __MIN( f_shadow_distance, 1 ), 0 );
+ f_shadow_distance = VLC_CLIP( f_shadow_distance, 0, 1 );
p_sys->f_shadow_vector_x = f_shadow_distance * cos(2 * M_PI * f_shadow_angle / 360);
p_sys->f_shadow_vector_y = f_shadow_distance * sin(2 * M_PI * f_shadow_angle / 360);
/* */
psz_fontfile = FontConfig_Select( NULL, psz_fontfamily, false, false,
p_sys->i_default_font_size, &fontindex );
+#elif defined(__APPLE__)
+ psz_fontfile = MacLegacy_Select( p_filter, psz_fontfamily, false, false, 0, &fontindex );
#elif defined(WIN32)
psz_fontfile = Win32_Select( p_filter, psz_fontfamily, false, false,
p_sys->i_default_font_size, &fontindex );
psz_fontfile ? psz_fontfile : "(null)" );
goto error;
}
-#ifdef HAVE_STYLES
- free( psz_fontfile );
-#endif
i_error = FT_Select_Charmap( p_sys->p_face, ft_encoding_unicode );
if( i_error )
p_sys->i_font_attachments = 0;
p_filter->pf_render_text = RenderText;
-#ifdef HAVE_STYLES
p_filter->pf_render_html = RenderHtml;
-#else
- p_filter->pf_render_html = NULL;
-#endif
LoadFontsFromAttachments( p_filter );
+#ifdef HAVE_STYLES
+ free( psz_fontfile );
+#endif
+
return VLC_SUCCESS;
error:
free( p_sys->pp_font_attachments );
}
-#ifdef HAVE_STYLES
if( p_sys->p_xml ) xml_ReaderDelete( p_sys->p_xml );
-#endif
free( p_sys->psz_fontfamily );
+#ifdef WIN32
+ free( p_sys->psz_win_fonts_path );
+#endif
+
/* FcFini asserts calling the subfunction FcCacheFini()
* even if no other library functions have been made since FcInit(),
* so don't call it. */