Skip to content

Commit ca235b7

Browse files
committed
[GTK] Restore changes in text-antialias behavior of images
On some platforms, creating a surface via cairo_image_surface_create(), rather than gdk_window_create_similar_surface(), causes the text-antialias property to be improperly initialized. Even though getTextAntialias() returns SWT.DEFAULT, any text is painted in an undefined way. This change restores the original way images are created as part of 5c2611d.
1 parent da081e9 commit ca235b7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java

+39
Original file line numberDiff line numberDiff line change
@@ -1257,4 +1257,43 @@ public void test_updateWidthHeightAfterDPIChange() {
12571257
DPIUtil.setDeviceZoom(deviceZoom);
12581258
}
12591259
}
1260+
1261+
@Test
1262+
public void test_paintWithTextAntialias() {
1263+
int[] modes = {SWT.ON, SWT.OFF, SWT.DEFAULT};
1264+
int width = (modes.length + 1) * 100;
1265+
int height = 100;
1266+
1267+
Image image1 = new Image(display, width, height);
1268+
GC g1 = new GC(image1);
1269+
g1.setAdvanced(true);
1270+
1271+
g1.drawString("OWVO", 35, 20);
1272+
for (int i = 0 ; i < modes.length; ++i) {
1273+
g1.setTextAntialias(modes[i]);
1274+
g1.drawString("OWVO", 135 + i * 100, 20);
1275+
}
1276+
1277+
Image image2 = new Image(display, width, height);
1278+
GC g2 = new GC(image2);
1279+
g2.setAdvanced(true);
1280+
1281+
for (int i = modes.length - 1 ; i >= 0; --i) {
1282+
g2.setTextAntialias(modes[i]);
1283+
g2.drawString("OWVO", 135 + i * 100, 20);
1284+
}
1285+
g2.setTextAntialias(SWT.DEFAULT);
1286+
g2.drawString("OWVO", 35, 20);
1287+
1288+
ImageData data1 = image1.getImageData();
1289+
ImageData data2 = image2.getImageData();
1290+
1291+
g1.dispose();
1292+
g2.dispose();
1293+
image1.dispose();
1294+
image2.dispose();
1295+
1296+
ImageTestUtil.assertImagesEqual(data1, data2);
1297+
}
1298+
12601299
}

0 commit comments

Comments
 (0)