[vlc-commits] freetype: replace baseline usage with vector

Francois Cartegnie git at videolan.org
Mon Aug 17 23:43:08 CEST 2020


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 17 15:21:56 2020 +0200| [d54a46df84b883ff76c08168eebe2cbbde3d240a] | committer: Francois Cartegnie

freetype: replace baseline usage with vector

do not touch glyph left/top to render ruby

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d54a46df84b883ff76c08168eebe2cbbde3d240a
---

 modules/text_renderer/freetype/freetype.c    | 14 ++++++++------
 modules/text_renderer/freetype/text_layout.c | 20 +++++---------------
 modules/text_renderer/freetype/text_layout.h |  2 +-
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
index ca49f147df..c800a8cff2 100644
--- a/modules/text_renderer/freetype/freetype.c
+++ b/modules/text_renderer/freetype/freetype.c
@@ -439,7 +439,7 @@ static int RenderYUVP( filter_t *p_filter, subpicture_region_t *p_region,
             const line_character_t *ch = &p_line->p_character[i];
             FT_BitmapGlyph p_glyph = ch->p_glyph;
 
-            int i_glyph_y = offset.y + p_regionbbox->yMax - p_glyph->top + p_line->i_base_line;
+            int i_glyph_y = offset.y + p_regionbbox->yMax - p_glyph->top + p_line->origin.y;
             int i_glyph_x = offset.x + p_glyph->left - p_regionbbox->xMin;
 
             for( y = 0; y < p_glyph->bitmap.rows; y++ )
@@ -810,12 +810,14 @@ static void RenderCharAXYZ( filter_t *p_filter,
             break;
         }
 
-        if(ch->p_ruby && ch->p_ruby->p_laid)
+        const line_desc_t *p_rubydesc = ch->p_ruby ? ch->p_ruby->p_laid : NULL;
+        if(p_rubydesc)
         {
             RenderCharAXYZ( p_filter,
                             p_picture,
-                            ch->p_ruby->p_laid,
-                            i_offset_x, i_offset_y,
+                            p_rubydesc,
+                            i_offset_x + p_rubydesc->origin.x,
+                            i_offset_y - p_rubydesc->origin.y,
                             2,
                             ExtractComponents,
                             BlendPixel );
@@ -843,7 +845,7 @@ static void RenderCharAXYZ( filter_t *p_filter,
         /* underline/strikethrough are only rendered for the normal glyph */
         if( g == 2 && ch->i_line_thickness > 0 )
             BlendAXYZLine( p_picture,
-                           i_glyph_x, i_glyph_y + p_glyph->top,
+                           i_glyph_x, i_glyph_y + ch->bbox.yMax,
                            i_a, i_x, i_y, i_z,
                            &ch[0],
                            i + 1 < p_line->i_character_count ? &ch[1] : NULL,
@@ -914,7 +916,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
         {
             FT_Vector offset = GetAlignedOffset( p_line, p_textbbox, p_region->i_text_align );
 
-            int i_glyph_offset_y = offset.y + p_regionbbox->yMax + p_line->i_base_line;
+            int i_glyph_offset_y = offset.y + p_regionbbox->yMax + p_line->origin.y;
             int i_glyph_offset_x = offset.x - p_regionbbox->xMin;
 
             RenderCharAXYZ( p_filter, p_picture, p_line,
diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 7adc732a14..c19d46ddc2 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -198,7 +198,8 @@ line_desc_t *NewLine( int i_count )
     p_line->p_next = NULL;
     p_line->i_width = 0;
     p_line->i_height = 0;
-    p_line->i_base_line = 0;
+    p_line->origin.x = 0;
+    p_line->origin.y = 0;
     p_line->i_character_count = 0;
     p_line->i_first_visible_char_index = -1;
     p_line->i_last_visible_char_index = -2;
@@ -214,20 +215,8 @@ line_desc_t *NewLine( int i_count )
     return p_line;
 }
 
-static void ShiftGlyph( FT_BitmapGlyph g, int x, int y )
-{
-    if( g )
-    {
-        g->left += x;
-        g->top += y;
-    }
-}
-
 static void ShiftChar( line_character_t *c, int x, int y )
 {
-    ShiftGlyph( c->p_glyph, x, y );
-    ShiftGlyph( c->p_shadow, x, y );
-    ShiftGlyph( c->p_outline, x, y );
     c->bbox.yMin += y;
     c->bbox.yMax += y;
     c->bbox.xMin += x;
@@ -238,7 +227,8 @@ static void ShiftLine( line_desc_t *p_line, int x, int y )
 {
     for( int i=0; i<p_line->i_character_count; i++ )
         ShiftChar( &p_line->p_character[i], x, y );
-    p_line->i_base_line += y;
+    p_line->origin.y += y;
+    p_line->origin.x += x;
     p_line->bbox.yMin += y;
     p_line->bbox.yMax += y;
     p_line->bbox.xMin += x;
@@ -1790,7 +1780,7 @@ int LayoutTextBlock( filter_t *p_filter,
 
     for( line_desc_t *p_line = p_first_line; p_line; p_line = p_line->p_next )
     {
-        p_line->i_base_line = i_base_line;
+        p_line->origin.y = i_base_line;
         p_line->bbox.yMin -= i_base_line;
         p_line->bbox.yMax -= i_base_line;
         BBoxEnlarge( &bbox, &p_line->bbox );
diff --git a/modules/text_renderer/freetype/text_layout.h b/modules/text_renderer/freetype/text_layout.h
index 3550e65afa..211b8421a2 100644
--- a/modules/text_renderer/freetype/text_layout.h
+++ b/modules/text_renderer/freetype/text_layout.h
@@ -50,9 +50,9 @@ typedef struct
 struct line_desc_t
 {
     line_desc_t      *p_next;
+    FT_Vector        origin; /* line position shift, baseline as y */
     int              i_width;
     int              i_height;
-    int              i_base_line;
     int              i_character_count;
     int              i_first_visible_char_index;
     int              i_last_visible_char_index;



More information about the vlc-commits mailing list