Skip to content
Snippets Groups Projects
Commit 7ae7c53c authored by François Cartegnie's avatar François Cartegnie :fingers_crossed: Committed by Hugo Beauzée-Luyssen
Browse files

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
parent c50ab587
No related branches found
No related tags found
Loading
Pipeline #210391 passed with stage
in 28 minutes and 6 seconds
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment