diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index c51b97772b..ce93291971 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -409,7 +409,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a double aGlyphThickness, double* aTopLimit, double* aBottomLimit ) const { - VECTOR2D result = VECTOR2D( 0.0, m_gal->GetGlyphSize().y ); + VECTOR2D string_bbox; double ymax = 0.0; double ymin = 0.0; @@ -434,7 +434,7 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a const BOX2D& box = m_glyphBoundingBoxes[dd]; - result.x += box.GetEnd().x; + string_bbox.x += box.GetEnd().x; // Calculate Y min and Y max if( aTopLimit ) @@ -450,12 +450,13 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a } } - result.x *= aGlyphSize.x; - result.x += aGlyphThickness; + string_bbox.x *= aGlyphSize.x; + string_bbox.x += aGlyphThickness; + string_bbox.y = aGlyphSize.y + aGlyphThickness; // For italic correction, take in account italic tilt if( m_gal->IsFontItalic() ) - result.x += result.y * STROKE_FONT::ITALIC_TILT; + string_bbox.x += string_bbox.y * STROKE_FONT::ITALIC_TILT; if( aTopLimit ) *aTopLimit = ymax * aGlyphSize.y; @@ -463,5 +464,5 @@ VECTOR2D STROKE_FONT::ComputeStringBoundaryLimits( const UTF8& aText, VECTOR2D a if( aBottomLimit ) *aBottomLimit = ymin * aGlyphSize.y; - return result; + return string_bbox; } diff --git a/common/page_layout/class_worksheet_dataitem.cpp b/common/page_layout/class_worksheet_dataitem.cpp index 50620b66bf..40d707d262 100644 --- a/common/page_layout/class_worksheet_dataitem.cpp +++ b/common/page_layout/class_worksheet_dataitem.cpp @@ -537,14 +537,15 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize() if( m_BoundingBoxSize.x || m_BoundingBoxSize.y ) { - int linewidth = 0; // to know the X and Y size of the line, we should use // EDA_TEXT::GetTextBox() // but this function uses integers // So, to avoid truncations with our unit in mm, use microns. wxSize size_micron; - size_micron.x = KiROUND( m_ConstrainedTextSize.x * 1000.0 ); - size_micron.y = KiROUND( m_ConstrainedTextSize.y * 1000.0 ); + #define FSCALE 1000.0 + int linewidth = 0; + size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE ); + size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE ); WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText, wxPoint(0,0), size_micron, @@ -552,10 +553,11 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize() IsItalic(), IsBold() ) ); dummy.SetMultilineAllowed( true ); TransfertSetupToGraphicText( &dummy ); + EDA_RECT rect = dummy.GetTextBox(); DSIZE size; - size.x = rect.GetWidth() / 1000.0; - size.y = rect.GetHeight() / 1000.0; + size.x = rect.GetWidth() / FSCALE; + size.y = rect.GetHeight() / FSCALE; if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x ) m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x; diff --git a/common/page_layout/title_block_shapes.cpp b/common/page_layout/title_block_shapes.cpp index c7a838578a..086d518f4c 100644 --- a/common/page_layout/title_block_shapes.cpp +++ b/common/page_layout/title_block_shapes.cpp @@ -163,12 +163,12 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( if( jj && ! wsText->IsInsidePage( jj ) ) continue; - Append( gtext = new WS_DRAW_ITEM_TEXT( wsText, wsText->m_FullText, - wsText->GetStartPosUi( jj ), - textsize, - pensize, color, - wsText->IsItalic(), - wsText->IsBold() ) ); + gtext = new WS_DRAW_ITEM_TEXT( wsText, wsText->m_FullText, + wsText->GetStartPosUi( jj ), + textsize, pensize, color, + wsText->IsItalic(), + wsText->IsBold() ); + Append( gtext ); gtext->SetMultilineAllowed( multilines ); wsText->TransfertSetupToGraphicText( gtext );