Fixed text bbox computation under the presence of global view transformations and 'apply text transformation' false

This commit is contained in:
Matthias Koefferlein
2023-05-11 20:05:28 +02:00
parent 424c039b7e
commit da52eeb7c3
3 changed files with 26 additions and 14 deletions
@@ -47,7 +47,10 @@ TEST(1)
// Default font
lay::TextInfo ti (&lv);
EXPECT_EQ (ti.bbox (text, db::DCplxTrans ()).to_string (), "(12,22;36,37)");
// global transformation changes the dimension as the default font is not scaled or rotated
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (2.0)).to_string (), "(11,21;23,28.5)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (db::DFTrans (1))).to_string (), "(12,-6;27,18)");
// long text
EXPECT_EQ (ti.bbox (text2, db::DCplxTrans ()).to_string (), "(12,22;60,52)");
// valign
@@ -69,6 +72,11 @@ TEST(1)
ti = lay::TextInfo (&lv);
EXPECT_EQ (ti.bbox (text, db::DCplxTrans ()).to_string (), "(12,15;72,47)");
// global trans only scales pixel-based border but does not modify the outline in
// "apply transformation" mode
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (2.0)).to_string (), "(11,14;71,46)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (db::DFTrans (1))).to_string (), "(12,15;72,47)");
// long text
EXPECT_EQ (ti.bbox (text2, db::DCplxTrans ()).to_string (), "(12,15;134,83)");
// valign
@@ -110,4 +118,9 @@ TEST(1)
lv.apply_text_trans (false);
ti = lay::TextInfo (&lv);
EXPECT_EQ (ti.bbox (text3, db::DCplxTrans ()).to_string (), "(12,20.6;36.4,34.2)");
// with apply_text_trans false, the global transformation does change the text
// bounding box.
EXPECT_EQ (ti.bbox (text, db::DCplxTrans ()).to_string (), "(12,20.6;24,27)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (2.0)).to_string (), "(11,19.6;23,26)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (db::DFTrans (1))).to_string (), "(10.6,6;17,18)");
}