Commit c6b1e382 authored by Francois Cartegnie's avatar Francois Cartegnie

freetype: use style inheritance

parent 782de7d7
This diff is collapsed.
...@@ -50,12 +50,13 @@ struct filter_sys_t ...@@ -50,12 +50,13 @@ struct filter_sys_t
FT_Face p_face; /* handle to face object */ FT_Face p_face; /* handle to face object */
FT_Stroker p_stroker; /* handle to path stroker object */ FT_Stroker p_stroker; /* handle to path stroker object */
text_style_t style; /* Current Style */ text_style_t *p_default_style;
text_style_t *p_style; /* Current Style */
text_style_t *p_forced_style;/* Renderer overridings */
/* More styles... */ /* More styles... */
float f_shadow_vector_x; float f_shadow_vector_x;
float f_shadow_vector_y; float f_shadow_vector_y;
int i_default_font_size;
/* Attachments */ /* Attachments */
input_attachment_t **pp_font_attachments; input_attachment_t **pp_font_attachments;
......
...@@ -69,7 +69,7 @@ typedef struct run_desc_t ...@@ -69,7 +69,7 @@ typedef struct run_desc_t
int i_start_offset; int i_start_offset;
int i_end_offset; int i_end_offset;
FT_Face p_face; FT_Face p_face;
text_style_t *p_style; const text_style_t *p_style;
#ifdef HAVE_HARFBUZZ #ifdef HAVE_HARFBUZZ
hb_script_t script; hb_script_t script;
...@@ -104,7 +104,7 @@ typedef struct paragraph_t ...@@ -104,7 +104,7 @@ typedef struct paragraph_t
{ {
uni_char_t *p_code_points; //Unicode code points uni_char_t *p_code_points; //Unicode code points
int *pi_glyph_indices; //Glyph index values within the run's font face int *pi_glyph_indices; //Glyph index values within the run's font face
text_style_t **pp_styles; const text_style_t **pp_styles;
int *pi_run_ids; //The run to which each glyph belongs int *pi_run_ids; //The run to which each glyph belongs
glyph_bitmaps_t *p_glyph_bitmaps; glyph_bitmaps_t *p_glyph_bitmaps;
uint8_t *pi_karaoke_bar; uint8_t *pi_karaoke_bar;
...@@ -208,7 +208,7 @@ static void BBoxEnlarge( FT_BBox *p_max, const FT_BBox *p ) ...@@ -208,7 +208,7 @@ static void BBoxEnlarge( FT_BBox *p_max, const FT_BBox *p )
static paragraph_t *NewParagraph( filter_t *p_filter, static paragraph_t *NewParagraph( filter_t *p_filter,
int i_size, int i_size,
const uni_char_t *p_code_points, const uni_char_t *p_code_points,
text_style_t **pp_styles, const text_style_t **pp_styles,
uint32_t *pi_k_dates, uint32_t *pi_k_dates,
int i_runs_size ) int i_runs_size )
{ {
...@@ -444,7 +444,7 @@ static int ItemizeParagraph( filter_t *p_filter, paragraph_t *p_paragraph ) ...@@ -444,7 +444,7 @@ static int ItemizeParagraph( filter_t *p_filter, paragraph_t *p_paragraph )
} }
int i_last_run_start = 0; int i_last_run_start = 0;
text_style_t *p_last_style = p_paragraph->pp_styles[ 0 ]; const text_style_t *p_last_style = p_paragraph->pp_styles[ 0 ];
#ifdef HAVE_HARFBUZZ #ifdef HAVE_HARFBUZZ
hb_script_t last_script = p_paragraph->p_scripts[ 0 ]; hb_script_t last_script = p_paragraph->p_scripts[ 0 ];
...@@ -513,7 +513,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter, ...@@ -513,7 +513,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
for( int i = 0; i < p_paragraph->i_runs_count; ++i ) for( int i = 0; i < p_paragraph->i_runs_count; ++i )
{ {
run_desc_t *p_run = p_paragraph->p_runs + i; run_desc_t *p_run = p_paragraph->p_runs + i;
text_style_t *p_style = p_run->p_style; const text_style_t *p_style = p_run->p_style;
/* /*
* When using HarfBuzz, this is where font faces are loaded. * When using HarfBuzz, this is where font faces are loaded.
...@@ -527,7 +527,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter, ...@@ -527,7 +527,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
if( !p_face ) if( !p_face )
{ {
p_face = p_sys->p_face; p_face = p_sys->p_face;
p_style = &p_sys->style; p_style = p_sys->p_style;
p_run->p_style = p_style; p_run->p_style = p_style;
} }
p_run->p_face = p_face; p_run->p_face = p_face;
...@@ -774,7 +774,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, ...@@ -774,7 +774,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
for( int i = 0; i < p_paragraph->i_runs_count; ++i ) for( int i = 0; i < p_paragraph->i_runs_count; ++i )
{ {
run_desc_t *p_run = p_paragraph->p_runs + i; run_desc_t *p_run = p_paragraph->p_runs + i;
text_style_t *p_style = p_run->p_style; const text_style_t *p_style = p_run->p_style;
FT_Face p_face = 0; FT_Face p_face = 0;
if( !p_run->p_face ) if( !p_run->p_face )
...@@ -783,7 +783,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, ...@@ -783,7 +783,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
if( !p_face ) if( !p_face )
{ {
p_face = p_sys->p_face; p_face = p_sys->p_face;
p_style = &p_sys->style; p_style = p_sys->p_style;
p_run->p_style = p_style; p_run->p_style = p_style;
} }
p_run->p_face = p_face; p_run->p_face = p_face;
...@@ -851,7 +851,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, ...@@ -851,7 +851,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
p_bitmaps->p_outline = 0; p_bitmaps->p_outline = 0;
} }
if( p_filter->p_sys->style.i_shadow_alpha > 0 ) if( p_filter->p_sys->p_style->i_shadow_alpha > 0 )
p_bitmaps->p_shadow = p_bitmaps->p_outline ? p_bitmaps->p_shadow = p_bitmaps->p_outline ?
p_bitmaps->p_outline : p_bitmaps->p_glyph; p_bitmaps->p_outline : p_bitmaps->p_glyph;
...@@ -892,7 +892,7 @@ static int LayoutLine( filter_t *p_filter, ...@@ -892,7 +892,7 @@ static int LayoutLine( filter_t *p_filter,
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
int i_last_run = -1; int i_last_run = -1;
run_desc_t *p_run = 0; run_desc_t *p_run = 0;
text_style_t *p_style = 0; const text_style_t *p_style = 0;
FT_Face p_face = 0; FT_Face p_face = 0;
FT_Vector pen = { .x = 0, .y = 0 }; FT_Vector pen = { .x = 0, .y = 0 };
int i_line_index = 0; int i_line_index = 0;
...@@ -1001,7 +1001,7 @@ static int LayoutLine( filter_t *p_filter, ...@@ -1001,7 +1001,7 @@ static int LayoutLine( filter_t *p_filter,
int i_line_offset = 0; int i_line_offset = 0;
int i_line_thickness = 0; int i_line_thickness = 0;
text_style_t *p_glyph_style = p_paragraph->pp_styles[ i_paragraph_index ]; 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_glyph_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
{ {
i_line_offset = i_line_offset =
...@@ -1206,7 +1206,7 @@ error: ...@@ -1206,7 +1206,7 @@ error:
int LayoutText( filter_t *p_filter, line_desc_t **pp_lines, int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
FT_BBox *p_bbox, int *pi_max_face_height, FT_BBox *p_bbox, int *pi_max_face_height,
const uni_char_t *psz_text, text_style_t **pp_styles, const uni_char_t *psz_text, const text_style_t **pp_styles,
uint32_t *pi_k_dates, int i_len ) uint32_t *pi_k_dates, int i_len )
{ {
line_desc_t *p_first_line = 0; line_desc_t *p_first_line = 0;
...@@ -1271,7 +1271,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines, ...@@ -1271,7 +1271,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
* and any extra width caused by visual reordering * and any extra width caused by visual reordering
*/ */
int i_max_width = ( int ) p_filter->fmt_out.video.i_visible_width int i_max_width = ( int ) p_filter->fmt_out.video.i_visible_width
- 2 * p_filter->p_sys->style.i_font_size; - 2 * p_filter->p_sys->p_style->i_font_size;
if( LayoutParagraph( p_filter, p_paragraph, if( LayoutParagraph( p_filter, p_paragraph,
i_max_width, pp_line ) ) i_max_width, pp_line ) )
goto error; goto error;
......
...@@ -55,5 +55,5 @@ line_desc_t *NewLine( int i_count ); ...@@ -55,5 +55,5 @@ line_desc_t *NewLine( int i_count );
int LayoutText(filter_t *p_filter, line_desc_t **pp_lines, int LayoutText(filter_t *p_filter, line_desc_t **pp_lines,
FT_BBox *p_bbox, int *pi_max_face_height, FT_BBox *p_bbox, int *pi_max_face_height,
const uni_char_t *psz_text, text_style_t **pp_styles, const uni_char_t *psz_text, const text_style_t **pp_styles,
uint32_t *pi_k_dates, int i_len ); uint32_t *pi_k_dates, int i_len );
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