]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Add line bounds to highlight bounds to get actual bounds. 13/3913/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 24 Feb 2020 12:58:14 +0000 (14:58 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 24 Feb 2020 14:50:43 +0000 (14:50 +0000)
This fixes text clipping with italic font

gitlab #475

Change-Id: I7223d6b7e960f28c61644ba7bc608b46530a58a1
(cherry picked from commit 5d435de8ba4147560a795f8873d234a0489050b2)

bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java

index 2991d234c462bdb09e150e7d81892e7c18013f2c..77eb789220d3118e5d8c370c2889b731450e060f 100644 (file)
@@ -410,6 +410,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         this.scaleRecip = 1.0 / scale;
         this.caret = 0;
         this.selectionTail = 0;
+        
 
         resetCaches();
     }
@@ -1437,6 +1438,9 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
             y += line.layout.getDescent() + line.layout.getLeading() + line.layout.getAscent();
 
             Rectangle2D bbox = line.layout.getLogicalHighlightShape(0, lineText.length()).getBounds2D();
+            // HighlightShape is not large enough, if font is italic.
+            Rectangle2D bbox2 = line.layout.getBounds();
+            bbox.add(bbox2);
             bbox.setFrame(bbox.getX(), bbox.getY() + line.drawPosY, bbox.getWidth(), bbox.getHeight());
             line.bbox = bbox;
         }