[vlc-commits] [Git][videolan/vlc][master] freetype: fix first glyph non zero bearing alignment offset

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Wed Apr 13 08:33:08 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
7ae7c53c by Francois Cartegnie at 2022-04-13T08:02:44+00:00
freetype: fix first glyph non zero bearing alignment offset

When box xMin is 0, lines starting with non 0 bearing can't
be aligned properly due to wrong offset

- - - - -


1 changed file:

- modules/text_renderer/freetype/freetype.c


Changes:

=====================================
modules/text_renderer/freetype/freetype.c
=====================================
@@ -209,20 +209,22 @@ static FT_Vector GetAlignedOffset( const line_desc_t *p_line,
                                    int i_align )
 {
     FT_Vector offsets = { 0, 0 };
+
+    /* aligns left to textbbox's min first */
+    offsets.x = p_textbbox->xMin - p_line->bbox.xMin;
+
     const int i_text_width = p_textbbox->xMax - p_textbbox->xMin;
     if ( p_line->i_width < i_text_width &&
         (i_align & SUBPICTURE_ALIGN_LEFT) == 0 )
     {
         /* Left offset to take into account alignment */
         if( i_align & SUBPICTURE_ALIGN_RIGHT )
-            offsets.x = ( i_text_width - p_line->i_width );
+            offsets.x += ( i_text_width - p_line->i_width );
         else /* center */
-            offsets.x = ( i_text_width - p_line->i_width ) / 2;
-    }
-    else
-    {
-        offsets.x = p_textbbox->xMin - p_line->bbox.xMin;
+            offsets.x += ( i_text_width - p_line->i_width ) / 2;
     }
+    /* else already left aligned */
+
     return offsets;
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ae7c53c5d6495a54ba1f6cf2a2007b9cee4d7f2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7ae7c53c5d6495a54ba1f6cf2a2007b9cee4d7f2
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list