XftFontDescription.st
branchjv
changeset 7719 c2f802dd340a
parent 7718 6e51fc8b207f
child 7720 8efc17a5de76
--- a/XftFontDescription.st	Thu Nov 24 23:50:51 2016 +0000
+++ b/XftFontDescription.st	Sat Nov 26 21:09:32 2016 +0000
@@ -464,6 +464,22 @@
      fg fgR fgG fgB fgA fgPixel bg bgR bgG bgB bgA bgPixel
      drawX drawY drawPnt displayId screen drawableId error stringLen drawId drawIdIsShared
      newXftDrawId newDrawableAssociation pixmapDepth|
+
+    aGC isPixmap ifTrue:[
+        pixmapDepth := aGC depth.
+        pixmapDepth == 1 ifTrue:[
+            "/ Using XFT font to draw in bitmap is not allowed. In theory it could
+            "/ work if XFT would just turn gray into either black or white. But XFT
+            "/ doesn't do it and simply draw nothing without failing in any way. 
+            "/ 
+            "/ To prevent this silent failures, forbid drawing XFT onto bitmaps
+            "/ (depth-1 pixmaps). After all, the while point of XFT is to use
+            "/ anti-aliased fonts.
+            self error: 'XFT font cannot be used with bitmaps'.
+            ^self
+        ].
+    ].
+
                                              
     "limit the string len, otherwise bad output is generated"
     stringLen := index2Arg - index1 + 1.
@@ -537,9 +553,6 @@
     ].
     screen := device screen.
     drawableId := aGC drawableId.
-    aGC isForm ifTrue:[
-        pixmapDepth := aGC depth.
-    ].
     
     ((aGC class == XGraphicsContext) or:[aGC isKindOf: XGraphicsContext]) ifTrue:[
         "/ TODO: Following should be done atomically together with drawing...
@@ -547,21 +560,10 @@
         drawIdIsShared := false.
         drawId isNil ifTrue:[
 %{  /* STACK: 64000 */
-            if (pixmapDepth != nil) {
-                int __pixmapDepth = __intVal(pixmapDepth);
-                if (__pixmapDepth == 1) {      
-                    drawId = XFT_DRAW_HANDLE_NEW ( XftDrawCreateBitmap ( DISPLAY( displayId ) ,
-                                                   DRAWABLE( drawableId ) ) );           
-                } else {
-                    drawId = XFT_DRAW_HANDLE_NEW ( XftDrawCreateAlpha ( DISPLAY( displayId ) ,
-                                                   DRAWABLE( drawableId ), __pixmapDepth) );                      
-                }
-            } else {
-                drawId = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) ,
-                                               DRAWABLE( drawableId ) ,
-                                               DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) ,
-                                               DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) );
-            }
+            drawId = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) ,
+                                           DRAWABLE( drawableId ) ,
+                                           DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) ,
+                                           DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ); 
 %}.
             aGC xftDrawId: drawId.
         ].