all: correctly align multiline strings when not left-aligned

parent 63ebc6fa
......@@ -199,8 +199,6 @@ struct picture_heap_t
*/
struct subpicture_region_t
{
/** \name Region properties */
/**@{*/
video_format_t fmt; /**< format of the picture */
picture_t picture; /**< picture comprising this region */
......@@ -211,10 +209,10 @@ struct subpicture_region_t
int i_text_color; /**< text color (RGB native endianess) */
int i_text_alpha; /**< text transparency */
int i_text_size; /**< text size */
int i_text_align; /**< horizontal alignment hint for */
subpicture_region_t *p_next; /**< next region in the list */
subpicture_region_t *p_cache; /**< modified version of this region */
/**@}*/
};
/**
......
......@@ -358,20 +358,32 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
for( ; p_line != NULL; p_line = p_line->p_next )
{
int i_glyph_tmax = 0;
int i_bitmap_offset, i_offset;
int i_bitmap_offset, i_offset, i_align_offset = 0;
for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{
FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
i_glyph_tmax = __MAX( i_glyph_tmax, p_glyph->top );
}
if( p_line->i_width < i_width )
{
if( p_region->i_text_align == SUBPICTURE_ALIGN_RIGHT )
{
i_align_offset = i_width - p_line->i_width;
}
else if( p_region->i_text_align != SUBPICTURE_ALIGN_LEFT )
{
i_align_offset = ( i_width - p_line->i_width ) / 2;
}
}
for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{
FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
i_offset = ( p_line->p_glyph_pos[ i ].y +
i_glyph_tmax - p_glyph->top + 1 ) *
i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1;
i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1 +
i_align_offset;
for( y = 0, i_bitmap_offset = 0; y < p_glyph->bitmap.rows; y++ )
{
......@@ -399,7 +411,8 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region,
i_offset = ( p_line->p_glyph_pos[ i ].y +
i_glyph_tmax - p_glyph->top + 1 ) *
i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1;
i_pitch + p_line->p_glyph_pos[ i ].x + p_glyph->left + 1 +
i_align_offset;
for( y = 0, i_bitmap_offset = 0; y < p_glyph->bitmap.rows; y++ )
{
......
......@@ -589,6 +589,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
if( p_spu->p_text && p_spu->p_text->p_module &&
p_spu->p_text->pf_render_text )
{
p_region->i_text_align = p_subpic->i_flags & 0x3;
p_spu->p_text->pf_render_text( p_spu->p_text,
p_region, p_region );
}
......
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