Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a438983

Browse files
committed
Handle trailing whitespace in text.
svn path=/trunk/matplotlib/; revision=7838
1 parent 2313791 commit a438983

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/ft2font.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,13 +894,16 @@ FT2Font::compute_string_bbox( ) {
894894
bbox.xMin = bbox.yMin = 32000;
895895
bbox.xMax = bbox.yMax = -32000;
896896

897+
int right_side = 0;
897898
for ( size_t n = 0; n < glyphs.size(); n++ ) {
898899
FT_BBox glyph_bbox;
899900
FT_Glyph_Get_CBox( glyphs[n], ft_glyph_bbox_subpixels, &glyph_bbox );
900901
if ( glyph_bbox.xMin < bbox.xMin ) bbox.xMin = glyph_bbox.xMin;
901902
if ( glyph_bbox.yMin < bbox.yMin ) bbox.yMin = glyph_bbox.yMin;
902903
if ( glyph_bbox.xMax > bbox.xMax ) bbox.xMax = glyph_bbox.xMax;
903904
if ( glyph_bbox.yMax > bbox.yMax ) bbox.yMax = glyph_bbox.yMax;
905+
right_side += glyphs[n]->advance.x >> 10;
906+
if ( right_side > bbox.xMax ) bbox.xMax = right_side;
904907
}
905908
/* check that we really grew the string bbox */
906909
if ( bbox.xMin > bbox.xMax ) {

0 commit comments

Comments
 (0)