vlc | branch: master | Francois Cartegnie <[email protected]> | Fri Jun 2 20:02:26 2017 +0200| [ea861ea7e444c5c86a2afd8b126d20f1af0486d6] | committer: Francois Cartegnie
text_renderer: freetype: parametrize TextLayout max width > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea861ea7e444c5c86a2afd8b126d20f1af0486d6 --- modules/text_renderer/freetype/freetype.c | 5 +++-- modules/text_renderer/freetype/text_layout.c | 19 ++++++++----------- modules/text_renderer/freetype/text_layout.h | 13 +++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c index 823dbd0dbb..ae3a652d3e 100644 --- a/modules/text_renderer/freetype/freetype.c +++ b/modules/text_renderer/freetype/freetype.c @@ -1134,8 +1134,9 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out, uint32_t *pi_k_durations = NULL; rv = LayoutText( p_filter, - &p_lines, &bbox, &i_max_face_height, - psz_text, pp_styles, pi_k_durations, i_text_length, p_region_in->b_gridmode ); + psz_text, pp_styles, pi_k_durations, i_text_length, p_region_in->b_gridmode, + p_filter->fmt_out.video.i_visible_width, + &p_lines, &bbox, &i_max_face_height ); p_region_out->i_x = p_region_in->i_x; p_region_out->i_y = p_region_in->i_y; diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c index d0d0f60aea..15b8e93007 100644 --- a/modules/text_renderer/freetype/text_layout.c +++ b/modules/text_renderer/freetype/text_layout.c @@ -920,7 +920,7 @@ static int ZeroNsmAdvance( paragraph_t *p_paragraph ) */ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, bool b_use_glyph_indices, bool b_overwrite_advance, - int *pi_max_advance_x ) + unsigned *pi_max_advance_x ) { if( p_paragraph->i_size <= 0 || p_paragraph->i_runs_count <= 0 ) { @@ -1443,18 +1443,17 @@ error: return VLC_EGENERIC; } -int LayoutText( filter_t *p_filter, line_desc_t **pp_lines, - FT_BBox *p_bbox, int *pi_max_face_height, - +int LayoutText( filter_t *p_filter, const uni_char_t *psz_text, text_style_t **pp_styles, - uint32_t *pi_k_dates, int i_len, bool b_grid ) + uint32_t *pi_k_dates, int i_len, bool b_grid, unsigned i_max_width, + line_desc_t **pp_lines, FT_BBox *p_bbox, int *pi_max_face_height ) { line_desc_t *p_first_line = 0; line_desc_t **pp_line = &p_first_line; paragraph_t *p_paragraph = 0; int i_paragraph_start = 0; int i_max_height = 0; - int i_max_advance_x = 0; + unsigned i_max_advance_x = 0; for( int i = 0; i <= i_len; ++i ) { @@ -1508,19 +1507,17 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines, #endif /* - * Set max line width to allow for outline and shadow glyphs, + * Check max line width to allow for outline and shadow glyphs, * and any extra width caused by visual reordering */ - int i_max_width = ( int ) p_filter->fmt_out.video.i_visible_width - i_max_advance_x; - - if( i_max_width <= 0 ) + if( i_max_width <= i_max_advance_x ) { msg_Err( p_filter, "LayoutText(): Invalid max width" ); goto error; } if( LayoutParagraph( p_filter, p_paragraph, - i_max_width, pp_line, b_grid ) ) + i_max_width - i_max_advance_x, pp_line, b_grid ) ) goto error; FreeParagraph( p_paragraph ); diff --git a/modules/text_renderer/freetype/text_layout.h b/modules/text_renderer/freetype/text_layout.h index 34e1e83884..8834488de6 100644 --- a/modules/text_renderer/freetype/text_layout.h +++ b/modules/text_renderer/freetype/text_layout.h @@ -66,16 +66,17 @@ line_desc_t *NewLine( int i_count ); * Layout the text with shaping, bidirectional support, and font fallback if available. * * \param p_filter the FreeType module object [IN] - * \param pp_lines the list of line_desc_t's with rendered glyphs [OUT] - * \param p_bbox the bounding box of all the lines [OUT] - * \param pi_max_face_height maximum line height [OUT] * \param psz_text array of size \p i_len containing character codepoints [IN] * \param pp_styles array of size \p i_len containing character styles [IN] * \param pi_k_dates array of size \p i_len containing karaoke timestamps for characters [IN] * \param i_len length of the arrays \p psz_text, \p pp_styles, and \p pi_k_dates [IN] * \param b_grid true for grid-mode text [IN] + * \param i_max_width maximum available width to layout text [IN] + * \param pp_lines the list of line_desc_t's with rendered glyphs [OUT] + * \param p_bbox the bounding box of all the lines [OUT] + * \param pi_max_face_height maximum line height [OUT] */ -int LayoutText(filter_t *p_filter, line_desc_t **pp_lines, - FT_BBox *p_bbox, int *pi_max_face_height, +int LayoutText( filter_t *p_filter, const uni_char_t *psz_text, text_style_t **pp_styles, - uint32_t *pi_k_dates, int i_len, bool b_grid ); + uint32_t *pi_k_dates, int i_len, bool b_grid, unsigned i_max_width, + line_desc_t **pp_lines, FT_BBox *p_bbox, int *pi_max_face_height ); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
