Commit a222da2d authored by Francois Cartegnie's avatar Francois Cartegnie

freetype: directly refer to style from char

parent 5f7d9a68
......@@ -393,8 +393,8 @@ static int RenderYUVP( filter_t *p_filter, subpicture_region_t *p_region,
/* Calculate text color components
* Only use the first color */
int i_alpha = (p_line->p_character[0].i_color >> 24) & 0xff;
YUVFromRGB( p_line->p_character[0].i_color, &i_y, &i_u, &i_v );
const int i_alpha = p_line->p_character[0].p_style->i_font_alpha;
YUVFromRGB( p_line->p_character[0].p_style->i_font_color, &i_y, &i_u, &i_v );
/* Build palette */
fmt.p_palette->i_entries = 16;
......@@ -717,7 +717,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = 0;
/* Setup color for the background */
uint32_t i_prev_color = p_line->p_character[p_line->i_first_visible_char_index].i_background_color;
const text_style_t *p_prev_style = p_line->p_character[p_line->i_first_visible_char_index].p_style;
int i_char_index = p_line->i_first_visible_char_index;
while( i_char_index <= p_line->i_last_visible_char_index )
......@@ -725,7 +725,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
/* find last char having the same style */
int i_seg_end = i_char_index;
while( i_seg_end < p_line->i_last_visible_char_index &&
i_prev_color == p_line->p_character[i_seg_end].i_background_color )
p_prev_style == p_line->p_character[i_seg_end].p_style )
{
i_seg_end++;
}
......@@ -736,8 +736,12 @@ static inline void RenderBackground( subpicture_region_t *p_region,
i_align_left - p_bbox->xMin;
uint8_t i_x, i_y, i_z;
ExtractComponents( p_line->p_character[i_char_index].i_background_color, &i_x, &i_y, &i_z );
const uint8_t i_alpha = (p_line->p_character[i_char_index].i_background_color >> 24) & 0xFF;
const line_character_t *p_char = &p_line->p_character[i_char_index];
ExtractComponents( p_char->b_in_karaoke ? p_char->p_style->i_karaoke_background_color :
p_char->p_style->i_background_color,
&i_x, &i_y, &i_z );
const uint8_t i_alpha = p_char->b_in_karaoke ? p_char->p_style->i_karaoke_background_alpha:
p_char->p_style->i_background_alpha;
/* Render the actual background */
for( int dy = line_top; dy < line_bottom; dy++ )
......@@ -748,7 +752,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = line_end;
i_char_index = i_seg_end + 1;
i_prev_color = p_line->p_character->i_background_color;
p_prev_style = p_line->p_character->p_style;
}
}
......@@ -826,7 +830,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
if( !p_glyph )
continue;
i_a = (ch->i_color >> 24) & 0xff;
i_a = ch->p_style->i_font_alpha;
uint32_t i_color;
switch (g) {
case 0:
......@@ -838,7 +842,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
i_color = p_sys->p_style->i_outline_color;
break;
default:
i_color = ch->i_color;
i_color = ch->p_style->i_font_color;
break;
}
ExtractComponents( i_color, &i_x, &i_y, &i_z );
......
......@@ -922,6 +922,8 @@ static int LayoutLine( filter_t *p_filter,
#endif
line_character_t *p_ch = p_line->p_character + i_line_index;
p_ch->p_style = p_paragraph->pp_styles[ i_paragraph_index ];
glyph_bitmaps_t *p_bitmaps =
p_paragraph->p_glyph_bitmaps + i_paragraph_index;
......@@ -1004,8 +1006,8 @@ static int LayoutLine( filter_t *p_filter,
int i_line_offset = 0;
int i_line_thickness = 0;
const text_style_t *p_glyph_style = p_paragraph->pp_styles[ i_paragraph_index ];
if( p_glyph_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
if( p_ch->p_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
{
i_line_offset =
abs( FT_FLOOR( FT_MulFix( p_face->underline_position,
......@@ -1015,7 +1017,7 @@ static int LayoutLine( filter_t *p_filter,
abs( FT_CEIL( FT_MulFix( p_face->underline_thickness,
p_face->size->metrics.y_scale ) ) );
if( p_glyph_style->i_style_flags & STYLE_STRIKEOUT )
if( p_ch->p_style->i_style_flags & STYLE_STRIKEOUT )
{
/* Move the baseline to make it strikethrough instead of
* underline. That means that strikethrough takes precedence
......@@ -1047,16 +1049,7 @@ static int LayoutLine( filter_t *p_filter,
p_ch->p_glyph = ( FT_BitmapGlyph ) p_bitmaps->p_glyph;
p_ch->p_outline = ( FT_BitmapGlyph ) p_bitmaps->p_outline;
p_ch->p_shadow = ( FT_BitmapGlyph ) p_bitmaps->p_shadow;
bool b_karaoke = p_paragraph->pi_karaoke_bar[ i_paragraph_index ] != 0;
p_ch->i_color = b_karaoke ?
(uint32_t) p_glyph_style->i_karaoke_background_color
| (uint32_t) p_glyph_style->i_karaoke_background_alpha << 24
: (uint32_t) p_glyph_style->i_font_color
| (uint32_t) p_glyph_style->i_font_alpha << 24;
p_ch->i_background_color = ( uint32_t ) p_glyph_style->i_background_color
| p_glyph_style->i_background_alpha << 24;
p_ch->b_in_karaoke = (p_paragraph->pi_karaoke_bar[ i_paragraph_index ] != 0);
p_ch->i_line_thickness = i_line_thickness;
p_ch->i_line_offset = i_line_offset;
......
......@@ -32,10 +32,10 @@ typedef struct
FT_BitmapGlyph p_glyph;
FT_BitmapGlyph p_outline;
FT_BitmapGlyph p_shadow;
uint32_t i_color; /* ARGB color */
uint32_t i_background_color; /* ARGB background color */
const text_style_t *p_style;
int i_line_offset; /* underline/strikethrough offset */
int i_line_thickness; /* underline/strikethrough thickness */
bool b_in_karaoke;
} line_character_t;
typedef struct line_desc_t line_desc_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment