+ if( psz_name && psz_value )
+ {
+ if( !strcasecmp( "face", psz_name ) )
+ {
+ free( psz_fontname );
+ psz_fontname = strdup( psz_value );
+ }
+ else if( !strcasecmp( "size", psz_name ) )
+ {
+ if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
+ {
+ int i_value = atoi( psz_value );
+
+ if( ( i_value >= -5 ) && ( i_value <= 5 ) )
+ i_font_size += ( i_value * i_font_size ) / 10;
+ else if( i_value < -5 )
+ i_font_size = - i_value;
+ else if( i_value > 5 )
+ i_font_size = i_value;
+ }
+ else
+ i_font_size = atoi( psz_value );
+ }
+ else if( !strcasecmp( "color", psz_name ) &&
+ ( psz_value[0] == '#' ) )
+ {
+ i_font_color = strtol( psz_value + 1, NULL, 16 );
+ i_font_color &= 0x00ffffff;
+ }
+ else if( !strcasecmp( "alpha", psz_name ) &&
+ ( psz_value[0] == '#' ) )
+ {
+ i_font_alpha = strtol( psz_value + 1, NULL, 16 );
+ i_font_alpha &= 0xff;
+ }
+ free( psz_name );
+ free( psz_value );
+ }
+ }
+ rv = PushFont( p_fonts,
+ psz_fontname,
+ i_font_size * i_scale / 1000,
+ (i_font_color & 0xffffff) | ((i_font_alpha & 0xff) << 24) );
+
+ free( psz_fontname );
+
+ return rv;
+}
+
+static void setFontAttibutes( char *psz_fontname, int i_font_size, uint32_t i_font_color,
+ bool b_bold, bool b_italic, bool b_underline,
+ CFRange p_range, CFMutableAttributedStringRef p_attrString )
+{
+ CFStringRef p_cfString;
+ CTFontRef p_font;
+
+ // Handle font name and size
+ p_cfString = CFStringCreateWithCString( NULL,
+ psz_fontname,
+ kCFStringEncodingUTF8 );
+ p_font = CTFontCreateWithName( p_cfString,
+ (float)i_font_size,
+ NULL );
+ CFRelease( p_cfString );
+ CFAttributedStringSetAttribute( p_attrString,
+ p_range,
+ kCTFontAttributeName,
+ p_font );
+ CFRelease( p_font );
+
+ // Handle Underline
+ SInt32 _uline;
+ if( b_underline )
+ _uline = kCTUnderlineStyleSingle;
+ else
+ _uline = kCTUnderlineStyleNone;
+
+ CFNumberRef underline = CFNumberCreate(NULL, kCFNumberSInt32Type, &_uline);
+ CFAttributedStringSetAttribute( p_attrString,
+ p_range,
+ kCTUnderlineStyleAttributeName,
+ underline );
+ CFRelease( underline );
+
+ // Handle Bold
+ float _weight;
+ if( b_bold )
+ _weight = 0.5;
+ else
+ _weight = 0.0;
+
+ CFNumberRef weight = CFNumberCreate(NULL, kCFNumberFloatType, &_weight);
+ CFAttributedStringSetAttribute( p_attrString,
+ p_range,
+ kCTFontWeightTrait,
+ weight );
+ CFRelease( weight );
+
+ // Handle Italic
+ float _slant;
+ if( b_italic )
+ _slant = 1.0;
+ else
+ _slant = 0.0;
+
+ CFNumberRef slant = CFNumberCreate(NULL, kCFNumberFloatType, &_slant);
+ CFAttributedStringSetAttribute( p_attrString,
+ p_range,
+ kCTFontSlantTrait,
+ slant );
+ CFRelease( slant );
+
+ // Handle foreground colour
+ CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
+ CGFloat components[] = { (float)((i_font_color & 0x00ff0000) >> 16) / 255.0,
+ (float)((i_font_color & 0x0000ff00) >> 8) / 255.0,
+ (float)((i_font_color & 0x000000ff) ) / 255.0,
+ (float)(255-((i_font_color & 0xff000000) >> 24)) / 255.0 };
+ CGColorRef fg_text = CGColorCreate(rgbColorSpace, components);
+ CGColorSpaceRelease(rgbColorSpace);
+
+ CFAttributedStringSetAttribute( p_attrString,
+ p_range,
+ kCTForegroundColorAttributeName,
+ fg_text );
+ CFRelease( fg_text );
+
+}
+
+static void GetAttrStrFromFontStack( font_stack_t **p_fonts,
+ bool b_bold, bool b_italic, bool b_uline,
+ CFRange p_range, CFMutableAttributedStringRef p_attrString )
+{
+ char *psz_fontname = NULL;
+ int i_font_size = 0;
+ uint32_t i_font_color = 0;
+
+ if( VLC_SUCCESS == PeekFont( p_fonts, &psz_fontname, &i_font_size,
+ &i_font_color ))