]> git.sesse.net Git - vlc/commitdiff
all: correctly align multiline strings when not left-aligned
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Wed, 9 Mar 2005 12:58:13 +0000 (12:58 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Wed, 9 Mar 2005 12:58:13 +0000 (12:58 +0000)
include/vlc_video.h
modules/misc/freetype.c
src/video_output/vout_subpictures.c

index 68d2e2ec13d17a384c9c83e5f9af3aa0188d67b1..953f6a1d939490c623b651a7dac61001dbf38350 100644 (file)
@@ -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 */
-    /**@}*/
 };
 
 /**
index 5c282074d584b74fa67ce9732669682a4ab1f7c4..057a7db86730e7e77c8f2a4d2e03cc63e169ee54 100644 (file)
@@ -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++ )
             {
index 69cf88db5e1454c81ca3048df54859abe2329538..393d2089828437b4b578d81e68edb0dd92418de3 100644 (file)
@@ -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 ); 
                 }