# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_osd.h>
#include <vlc_block.h>
ATSUStyle *pp_styles );
static ATSUStyle CreateStyle( char *psz_fontname, int i_font_size,
uint32_t i_font_color,
- vlc_bool_t b_bold, vlc_bool_t b_italic,
- vlc_bool_t b_uline );
+ bool b_bold, bool b_italic,
+ bool b_uline );
//////////////////////////////////////////////////////////////////////////////
// Module descriptor
//////////////////////////////////////////////////////////////////////////////
// RenderText. This module, unlike Freetype, doesn't provide any options to
// override the fallback font selection used when this style information is
// absent.
+#define FONT_TEXT N_("Font")
+#define FONT_LONGTEXT N_("Name for the font you want to use")
+#define FONTSIZER_TEXT N_("Relative font size")
+#define FONTSIZER_LONGTEXT N_("This is the relative default size of the " \
+ "fonts that will be rendered on the video. If absolute font size is set, "\
+ "relative size will be overriden." )
+#define COLOR_TEXT N_("Text default color")
+#define COLOR_LONGTEXT N_("The color of the text that will be rendered on "\
+ "the video. This must be an hexadecimal (like HTML colors). The first two "\
+ "chars are for red, then green, then blue. #000000 = black, #FF0000 = red,"\
+ " #00FF00 = green, #FFFF00 = yellow (red + green), #FFFFFF = white" )
+
+static const int pi_color_values[] = {
+ 0x00000000, 0x00808080, 0x00C0C0C0, 0x00FFFFFF, 0x00800000,
+ 0x00FF0000, 0x00FF00FF, 0x00FFFF00, 0x00808000, 0x00008000, 0x00008080,
+ 0x0000FF00, 0x00800080, 0x00000080, 0x000000FF, 0x0000FFFF };
+
+static const char *const ppsz_color_descriptions[] = {
+ N_("Black"), N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"),
+ N_("Red"), N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"), N_("Teal"),
+ N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"), N_("Aqua") };
+
+static const int pi_sizes[] = { 20, 18, 16, 12, 6 };
+static const char *const ppsz_sizes_text[] = {
+ N_("Smaller"), N_("Small"), N_("Normal"), N_("Large"), N_("Larger") };
+
vlc_module_begin();
- set_shortname( _("Mac Text renderer"));
- set_description( _("Quartz font renderer") );
+ set_shortname( N_("Mac Text renderer"));
+ set_description( N_("Quartz font renderer") );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_SUBPIC );
+ add_string( "quartztext-font", DEFAULT_FONT, NULL, FONT_TEXT, FONT_LONGTEXT,
+ false );
+ add_integer( "quartztext-rel-fontsize", DEFAULT_REL_FONT_SIZE, NULL, FONTSIZER_TEXT,
+ FONTSIZER_LONGTEXT, false );
+ change_integer_list( pi_sizes, ppsz_sizes_text, 0 );
+ add_integer( "quartztext-color", 0x00FFFFFF, NULL, COLOR_TEXT,
+ COLOR_LONGTEXT, false );
+ change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
set_capability( "text renderer", 120 );
add_shortcut( "text" );
set_callbacks( Create, Destroy );
// Allocate structure
p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
if( !p_sys )
- {
- msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
- }
- p_sys->psz_font_name = strdup( DEFAULT_FONT );
+ p_sys->psz_font_name = var_CreateGetString( p_this, "quartztext-font" );
p_sys->i_font_opacity = 255;
- p_sys->i_font_color = DEFAULT_FONT_COLOR;
+ p_sys->i_font_color = __MAX( __MIN( var_CreateGetInteger( p_this, "quartztext-color" ) , 0xFFFFFF ), 0 );
p_sys->i_font_size = GetFontSize( p_filter );
p_filter->pf_render_text = RenderText;
ATSUStyle p_style = CreateStyle( p_sys->psz_font_name, i_font_size,
(i_font_color & 0xffffff) |
((i_font_alpha & 0xff) << 24),
- VLC_FALSE, VLC_FALSE, VLC_FALSE );
+ false, false, false );
if( p_style )
{
RenderYUVA( p_filter, p_region_out, psz_utf16_str, i_string_length,
static ATSUStyle CreateStyle( char *psz_fontname, int i_font_size, uint32_t i_font_color,
- vlc_bool_t b_bold, vlc_bool_t b_italic, vlc_bool_t b_uline )
+ bool b_bold, bool b_italic, bool b_uline )
{
ATSUStyle p_style;
OSStatus status;
}
static ATSUStyle GetStyleFromFontStack( filter_sys_t *p_sys,
- font_stack_t **p_fonts, vlc_bool_t b_bold, vlc_bool_t b_italic,
- vlc_bool_t b_uline )
+ font_stack_t **p_fonts, bool b_bold, bool b_italic,
+ bool b_uline )
{
ATSUStyle p_style = NULL;
char *psz_node = NULL;
- vlc_bool_t b_italic = VLC_FALSE;
- vlc_bool_t b_bold = VLC_FALSE;
- vlc_bool_t b_uline = VLC_FALSE;
+ bool b_italic = false;
+ bool b_bold = false;
+ bool b_uline = false;
if( VLC_SUCCESS == var_Get( p_filter, "scale", &val ))
i_scale = val.i_int;
((p_font_style->i_font_alpha & 0xff) << 24) );
if( p_font_style->i_style_flags & STYLE_BOLD )
- b_bold = VLC_TRUE;
+ b_bold = true;
if( p_font_style->i_style_flags & STYLE_ITALIC )
- b_italic = VLC_TRUE;
+ b_italic = true;
if( p_font_style->i_style_flags & STYLE_UNDERLINE )
- b_uline = VLC_TRUE;
+ b_uline = true;
}
else
{
if( !strcasecmp( "font", psz_node ) )
PopFont( &p_fonts );
else if( !strcasecmp( "b", psz_node ) )
- b_bold = VLC_FALSE;
+ b_bold = false;
else if( !strcasecmp( "i", psz_node ) )
- b_italic = VLC_FALSE;
+ b_italic = false;
else if( !strcasecmp( "u", psz_node ) )
- b_uline = VLC_FALSE;
+ b_uline = false;
free( psz_node );
}
if( !strcasecmp( "font", psz_node ) )
rv = HandleFontAttributes( p_xml_reader, &p_fonts, i_scale );
else if( !strcasecmp( "b", psz_node ) )
- b_bold = VLC_TRUE;
+ b_bold = true;
else if( !strcasecmp( "i", psz_node ) )
- b_italic = VLC_TRUE;
+ b_italic = true;
else if( !strcasecmp( "u", psz_node ) )
- b_uline = VLC_TRUE;
+ b_uline = true;
else if( !strcasecmp( "br", psz_node ) )
{
uint32_t i_string_length;
p_sub = stream_MemoryNew( VLC_OBJECT(p_filter),
(uint8_t *) p_region_in->psz_html,
strlen( p_region_in->psz_html ),
- VLC_TRUE );
+ true );
if( p_sub )
{
p_xml = xml_Create( p_filter );
if( p_xml )
{
- vlc_bool_t b_karaoke = VLC_FALSE;
+ bool b_karaoke = false;
p_xml_reader = xml_ReaderCreate( p_xml, p_sub );
if( p_xml_reader )
/* We're going to have to render the text a number
* of times to show the progress marker on the text.
*/
- var_SetBool( p_filter, "text-rerender", VLC_TRUE );
- b_karaoke = VLC_TRUE;
+ var_SetBool( p_filter, "text-rerender", true );
+ b_karaoke = true;
}
else if( !strcasecmp( "text", psz_node ) )
{
- b_karaoke = VLC_FALSE;
+ b_karaoke = false;
}
else
{
// you move down the page
y -= ascent;
- // Set the outlining for this line to be dependant on the size of the line -
+ // Set the outlining for this line to be dependent on the size of the line -
// make it about 5% of the ascent, with a minimum at 1.0
float f_thickness = FixedToFloat( ascent ) * 0.05;
CGContextSetLineWidth( p_context, (( f_thickness > 1.0 ) ? 1.0 : f_thickness ));
static int GetFontSize( filter_t *p_filter )
{
- return p_filter->fmt_out.video.i_height / DEFAULT_REL_FONT_SIZE;
+ return p_filter->fmt_out.video.i_height / __MAX(1, var_CreateGetInteger( p_filter, "quartztext-rel-fontsize" ));
}
static int RenderYUVA( filter_t *p_filter, subpicture_region_t *p_region, UniChar *psz_utf16_str,