Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
index 1d667d8d42c..2da2866ae22 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/MarginPainter.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
@@ -45,7 +46,8 @@ public class MarginPainter implements IPainter, PaintListener {
/** The line width of the line to be painted, default value <code>1</code> */
private int fLineWidth= 0; // NOTE: 0 means width is 1 but with optimized performance
/** The cached x-offset of the <code>fMarginWidth</code> for the current font */
- private int fCachedWidgetX= -1;
+ private int fCachedWidgetX= -1;
+ private Font fFontForCachedWidgetX;
/** The active state of this painter */
private boolean fIsActive= false;
@@ -112,6 +114,7 @@ public class MarginPainter implements IPainter, PaintListener {
*/
private void computeWidgetX() {
GC gc= new GC(fTextWidget);
+ fFontForCachedWidgetX= fTextWidget.getFont();
int pixels= gc.getFontMetrics().getAverageCharWidth();
gc.dispose();
@@ -149,6 +152,9 @@ public class MarginPainter implements IPainter, PaintListener {
@Override
public void paintControl(PaintEvent e) {
if (fTextWidget != null) {
+ if (fFontForCachedWidgetX != fTextWidget.getFont()) {
+ computeWidgetX();
+ }
int x= fCachedWidgetX - fTextWidget.getHorizontalPixel();
if (x >= 0) {
Rectangle area= fTextWidget.getClientArea();

Back to the top