XftFontDescription.st
changeset 6936 1d258b6b9632
parent 6876 b1aa2b47d252
child 6938 0fe07ed7c80f
child 7032 bc8b85059e2b
equal deleted inserted replaced
6932:ab9546b8b707 6936:1d258b6b9632
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'stx:libview' }"
     3 "{ Package: 'stx:libview' }"
     2 
     4 
     3 "{ NameSpace: Smalltalk }"
     5 "{ NameSpace: Smalltalk }"
     4 
     6 
     5 FontDescription subclass:#XftFontDescription
     7 FontDescription subclass:#XftFontDescription
    73 #undef Time
    75 #undef Time
    74 #define Time XTime
    76 #define Time XTime
    75 
    77 
    76 #ifdef XFT
    78 #ifdef XFT
    77 
    79 
    78 extern OBJ __GLOBAL_GET_BY_NAME();
    80 extern OBJ __GLOBAL_GET_BY_NAME(char *);
    79 
    81 
    80 # define __HANDLE_VAL(type, externalAddress) \
    82 # define __HANDLE_VAL(type, externalAddress) \
    81 	((type)__externalAddressVal(externalAddress))
    83         ((type)__externalAddressVal(externalAddress))
    82 
    84 
    83 # define __HANDLE_NEW(ptr, __cls)                \
    85 # define __HANDLE_NEW(ptr, __cls)                    \
    84 	({                                      \
    86         ({                                           \
    85 	    OBJ handle;                         \
    87             OBJ handle = __MKEXTERNALADDRESS(ptr);   \
    86 	    handle = __MKEXTERNALADDRESS(ptr);  \
    88             OBJ clsObj = __GLOBAL_GET_BY_NAME(__cls);\
    87 	    __InstPtr(handle)->o_class =        \
    89             __InstPtr(handle)->o_class = clsObj;     \
    88 		__GLOBAL_GET_BY_NAME(__cls);    \
    90             __STORE(handle, clsObj);                 \
    89 	    handle;                             \
    91             handle;                                  \
    90 	})
    92         })
    91 
    93 
    92 
    94 
    93 
    95 
    94 # define DISPLAY(x)    __HANDLE_VAL(Display*, x)
    96 # define DISPLAY(x)    __HANDLE_VAL(Display*, x)
    95 # define SCREEN(x)     ((int)(__intVal(x)))
    97 # define SCREEN(x)     ((int)(__intVal(x)))
    96 # define DRAWABLE(x)   __HANDLE_VAL(Drawable, x)
    98 # define DRAWABLE(x)   __HANDLE_VAL(Drawable, x)
    97 # define GC(x)         __HANDLE_VAL(GC, x)
    99 # define GC(x)         __HANDLE_VAL(GC, x)
    98 # define VISUAL(x)     __HANDLE_VAL(Visual*, x)
   100 # define VISUAL(x)     __HANDLE_VAL(Visual*, x)
    99 # define COLORMAP(x)   __HANDLE_VAL(Colormap, x)
   101 # define COLORMAP(x)   __HANDLE_VAL(Colormap, x)
   100 
       
   101 
       
   102 
       
   103 
   102 
   104 /* FontConfig objects */
   103 /* FontConfig objects */
   105 # define FC_PATTERN(x)                  __HANDLE_VAL(XftPattern*, x)
   104 # define FC_PATTERN(x)                  __HANDLE_VAL(XftPattern*, x)
   106 # define FC_PATTERN_HANDLE_NEW(x)       __HANDLE_NEW(x, "XftFontDescription::FCPatternHandle")
   105 # define FC_PATTERN_HANDLE_NEW(x)       __HANDLE_NEW(x, "XftFontDescription::FCPatternHandle")
   107 
   106 
   418     top open.
   417     top open.
   419 
   418 
   420     "Created: / 30-12-2013 / 19:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   419     "Created: / 30-12-2013 / 19:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   421 ! !
   420 ! !
   422 
   421 
       
   422 !XftFontDescription class methodsFor:'primitives'!
       
   423 
       
   424 xftAvailable
       
   425 %{
       
   426 #ifdef XFT
       
   427     RETURN ( true )
       
   428 #endif
       
   429 %}.
       
   430     ^ false
       
   431 
       
   432     "Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   433 ! !
       
   434 
   423 !XftFontDescription class methodsFor:'queries'!
   435 !XftFontDescription class methodsFor:'queries'!
   424 
   436 
   425 listOfAvailableFonts
   437 listOfAvailableFonts
   426     "uses fc-list to get a list of available fontDescriptions"
   438     "uses fc-list to get a list of available fontDescriptions"
   427 
   439 
   545     ^ fontId
   557     ^ fontId
   546 
   558 
   547     "Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   559     "Created: / 02-01-2014 / 23:29:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   548 ! !
   560 ! !
   549 
   561 
       
   562 !XftFontDescription methodsFor:'change & update'!
       
   563 
       
   564 update:anAspect with:something from:changedObject
       
   565     "I want to be informed when a view that printed something with me is destroyed.
       
   566      Disassociate the view from the XFT drawable"
       
   567 
       
   568     |drawableId|
       
   569 
       
   570     anAspect == #aboutToDestroy ifTrue:[
       
   571         drawableId := changedObject drawableId.
       
   572         drawableId notNil ifTrue:[
       
   573             self disassociateXftDrawableFrom:drawableId.
       
   574         ].
       
   575         changedObject removeDependent:self.
       
   576     ].
       
   577 ! !
       
   578 
   550 !XftFontDescription methodsFor:'converting'!
   579 !XftFontDescription methodsFor:'converting'!
   551 
   580 
   552 asNonXftFont
   581 asNonXftFont
   553     |newFont|
   582     |newFont|
   554 
   583 
   574      drawX drawY drawPnt displayId screen drawableId error  stringLen|
   603      drawX drawY drawPnt displayId screen drawableId error  stringLen|
   575 
   604 
   576     "limit the string len, otherwise bad output is generated"
   605     "limit the string len, otherwise bad output is generated"
   577     stringLen := index2Arg - index1 + 1.
   606     stringLen := index2Arg - index1 + 1.
   578     stringLen > 8000 ifTrue:[
   607     stringLen > 8000 ifTrue:[
   579 	index2 := index1 + 8000 - 1.
   608         index2 := index1 + 8000 - 1.
   580     ]  ifFalse:[
   609     ]  ifFalse:[
   581 	stringLen <= 0 ifTrue:[^ self].
   610         stringLen <= 0 ifTrue:[^ self].
   582 	index2 := index2Arg.
   611         index2 := index2Arg.
   583     ].
   612     ].
   584     bytesPerCharacter := aString bitsPerCharacter // 8.
   613     bytesPerCharacter := aString bitsPerCharacter // 8.
   585     transformation := aGC transformation.
   614     transformation := aGC transformation.
   586 
   615 
   587     clipR := aGC clippingBoundsOrNil.
   616     clipR := aGC clippingBoundsOrNil.
   588     clipR notNil ifTrue:[
   617     clipR notNil ifTrue:[
   589 	clipX := clipR left.
   618         clipX := clipR left.
   590 	clipY := clipR top.
   619         clipY := clipR top.
   591 	clipW := clipR width.
   620         clipW := clipR width.
   592 	clipH := clipR height.
   621         clipH := clipR height.
   593 	"/ YES YES YES: this MUST be transformed!!
   622         "/ YES YES YES: this MUST be transformed!!
   594 	"/ (see htmlView) fix the notebook, please.
   623         "/ (see htmlView) fix the notebook, please.
   595 	transformation notNil ifTrue:[
   624         transformation notNil ifTrue:[
   596 	    clipPnt := transformation transformPoint:(clipX @ clipY).
   625             clipPnt := transformation transformPoint:(clipX @ clipY).
   597 	    clipX := clipPnt x ceiling.
   626             clipX := clipPnt x ceiling.
   598 	    clipY := clipPnt y ceiling.
   627             clipY := clipPnt y ceiling.
   599 "/            clipX := (transformation applyToX:clipX) ceiling.
   628 "/            clipX := (transformation applyToX:clipX) ceiling.
   600 "/            clipY := (transformation applyToY:clipY) ceiling.
   629 "/            clipY := (transformation applyToY:clipY) ceiling.
   601 	].
   630         ].
   602     ].
   631     ].
   603 
   632 
   604     transformation isNil ifTrue:[
   633     transformation isNil ifTrue:[
   605 	drawX := xArg.
   634         drawX := xArg.
   606 	drawY := yArg.
   635         drawY := yArg.
   607     ] ifFalse:[
   636     ] ifFalse:[
   608 	drawPnt := transformation transformPoint:(xArg @ yArg).
   637         drawPnt := transformation transformPoint:(xArg @ yArg).
   609 	drawX := drawPnt x ceiling.
   638         drawX := drawPnt x ceiling.
   610 	drawY := drawPnt y ceiling.
   639         drawY := drawPnt y ceiling.
   611 "/        drawX := (transformation applyToX:xArg) ceiling.
   640 "/        drawX := (transformation applyToX:xArg) ceiling.
   612 "/        drawY := (transformation applyToY:yArg) ceiling.
   641 "/        drawY := (transformation applyToY:yArg) ceiling.
   613     ].
   642     ].
   614 
   643 
   615     fg  :=  aGC paint.
   644     fg  :=  aGC paint.
   616     fgPixel := fg colorId.
   645     fgPixel := fg colorId.
   617     "/ fgPixel notNil ifTrue:[
   646     "/ fgPixel notNil ifTrue:[
   618 	fgR := fg scaledRed.
   647         fgR := fg scaledRed.
   619 	fgG := fg scaledGreen.
   648         fgG := fg scaledGreen.
   620 	fgB := fg scaledBlue.
   649         fgB := fg scaledBlue.
   621 	fgA := (fg alpha * 65535) rounded.
   650         fgA := (fg alpha * 65535) rounded.
   622     "/].
   651     "/].
   623     fgR isNil ifTrue:[
   652     fgR isNil ifTrue:[
   624 	"/ when drawing into a pixmap...
   653         "/ when drawing into a pixmap...
   625 	fg colorId == 0 ifTrue:[
   654         fg colorId == 0 ifTrue:[
   626 	    fgR := fgG := fgB := 0.
   655             fgR := fgG := fgB := 0.
   627 	] ifFalse:[
   656         ] ifFalse:[
   628 	    fgR := fgG := fgB := 16rFFFF.
   657             fgR := fgG := fgB := 16rFFFF.
   629 	]
   658         ]
   630     ].
   659     ].
   631 
   660 
   632     opaque ifTrue:[
   661     opaque ifTrue:[
   633 	bg  := aGC backgroundPaint.
   662         bg  := aGC backgroundPaint.
   634 	bgPixel := bg colorId.
   663         bgPixel := bg colorId.
   635 	"/bgPixel notNil ifTrue:[
   664         "/bgPixel notNil ifTrue:[
   636 	    bgR := bg scaledRed.
   665             bgR := bg scaledRed.
   637 	    bgG := bg scaledGreen.
   666             bgG := bg scaledGreen.
   638 	    bgB := bg scaledBlue.
   667             bgB := bg scaledBlue.
   639 	    bgA := (bg alpha * 65535) rounded.
   668             bgA := (bg alpha * 65535) rounded.
   640 	"/].
   669         "/].
   641 	bgR isNil ifTrue:[
   670         bgR isNil ifTrue:[
   642 	    "/ when drawing into a pixmap...
   671             "/ when drawing into a pixmap...
   643 	    bg colorId == 0 ifTrue:[
   672             bg colorId == 0 ifTrue:[
   644 		bgR := bgG := bgB := 0.
   673                 bgR := bgG := bgB := 0.
   645 	    ] ifFalse:[
   674             ] ifFalse:[
   646 		bgR := bgG := bgB := 16rFFFF.
   675                 bgR := bgG := bgB := 16rFFFF.
   647 	    ]
   676             ]
   648 	].
   677         ].
   649     ].
   678     ].
   650     displayId := device displayIdOrErrorIfBroken.
   679     displayId := device displayIdOrErrorIfBroken.
   651     displayId isNil ifTrue:[
   680     displayId isNil ifTrue:[
   652 	^ self.
   681         ^ self.
   653     ].
   682     ].
   654     screen := device screen.
   683     screen := device screen.
   655     drawableId := aGC drawableId.
   684     drawableId := aGC drawableId.
   656 
   685     aGC addDependent:self.      "I need to be informed, when the GC is destroyed"
   657 %{
   686 
   658 #ifdef XFT
   687 %{
   659     XftFont *font;
   688 #ifdef XFT
   660     XftDraw *draw;
       
   661     XftColor color;
   689     XftColor color;
   662     XGlyphInfo extents;
   690     XGlyphInfo extents;
   663     XRectangle clipRX;
   691     XRectangle clipRX;
   664     char* string;
   692     char *string;
   665     int len;
   693     int len;
   666     int __bytesPerCharacter;
   694     int __bytesPerCharacter;
       
   695     XftDraw *__sharedDrawId;
       
   696     XftFont *__xftFont = XFT_FONT(__INST(fontId));
   667 
   697 
   668     if (!(__bothSmallInteger(drawX, drawY)
   698     if (!(__bothSmallInteger(drawX, drawY)
   669 	  && __bothSmallInteger(index1, index2)
   699           && __bothSmallInteger(index1, index2)
   670 	  && __isSmallInteger(bytesPerCharacter)
   700           && __isSmallInteger(bytesPerCharacter)
   671 	  && (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA)))
   701           && (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA)))
   672 	  && (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA)))
   702           && (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA)))
   673 	  && __isNonNilObject(aString)
   703           && __isNonNilObject(aString)
   674     )) {
   704     )) {
   675 	goto err;
   705         goto err;
   676     }
   706     }
   677 
   707 
   678     __bytesPerCharacter = __intVal(bytesPerCharacter);
   708     __bytesPerCharacter = __intVal(bytesPerCharacter);
   679 
   709 
   680     if ( __INST(sharedDrawId) == nil ) {
   710     if (__INST(sharedDrawId) == nil) {
   681 	__INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) ,
   711         __sharedDrawId = XftDrawCreate(DISPLAY(displayId),
   682 					       DRAWABLE( drawableId ) ,
   712                                        DRAWABLE(drawableId),
   683 					       DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) ,
   713                                        DefaultVisual(DISPLAY(displayId), SCREEN(screen)),
   684 					       DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) );
   714                                        DefaultColormap(DISPLAY(displayId), SCREEN(screen)));
   685 	__STORE(self, __INST(sharedDrawId));
   715         __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW(__sharedDrawId);
   686     }
   716         __STORE(self, __INST(sharedDrawId));
   687 
   717     } else if (XftDrawDrawable(__sharedDrawId = XFT_DRAW(__INST(sharedDrawId))) != DRAWABLE(drawableId)) {
   688     if ( XftDrawDrawable ( XFT_DRAW ( __INST(sharedDrawId) ) ) != DRAWABLE( drawableId ) ) {
   718         XftDrawChange(__sharedDrawId, DRAWABLE(drawableId));
   689 	XftDrawChange( XFT_DRAW( __INST(sharedDrawId) ) , DRAWABLE( drawableId ) );
   719     }
   690     }
   720 
   691 
   721     string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter);
   692     string = __stringVal( aString ) + (( __intVal(index1) - 1 ) * __bytesPerCharacter);
       
   693     len = __intVal(index2) - __intVal(index1) + 1;
   722     len = __intVal(index2) - __intVal(index1) + 1;
   694 
   723 
   695     if (clipR != nil) {
   724     if (clipR != nil) {
   696 	clipRX.x = __intVal(clipX);
   725         clipRX.x = __intVal(clipX);
   697 	clipRX.y = __intVal(clipY);
   726         clipRX.y = __intVal(clipY);
   698 	clipRX.width = __intVal(clipW);
   727         clipRX.width = __intVal(clipW);
   699 	clipRX.height = __intVal(clipH);
   728         clipRX.height = __intVal(clipH);
   700 	XftDrawSetClipRectangles( XFT_DRAW( __INST( sharedDrawId ) ) , 0, 0, &clipRX, 1);
   729         XftDrawSetClipRectangles(__sharedDrawId, 0, 0, &clipRX, 1);
   701     } else {
   730     } else {
   702 	XftDrawSetClip( XFT_DRAW( __INST( sharedDrawId ) ) , 0);
   731         XftDrawSetClip(__sharedDrawId, 0);
   703     }
   732     }
   704 
   733 
   705     if (opaque == true) {
   734     if (opaque == true) {
   706 	if (bgPixel != nil) {
   735         if (bgPixel != nil) {
   707 	    color.pixel = (unsigned long)__intVal(bgPixel);
   736             color.pixel = (unsigned long)__intVal(bgPixel);
   708 	}
   737         }
   709 	// else {
   738         // else {
   710 	    color.color.red = __intVal(bgR);
   739             color.color.red = __intVal(bgR);
   711 	    color.color.green = __intVal(bgG);
   740             color.color.green = __intVal(bgG);
   712 	    color.color.blue = __intVal(bgB);
   741             color.color.blue = __intVal(bgB);
   713 	    color.color.alpha = __intVal(bgA);
   742             color.color.alpha = __intVal(bgA);
   714 	// }
   743         // }
   715 	switch (__bytesPerCharacter) {
   744         switch (__bytesPerCharacter) {
   716 	case 1:
   745         case 1:
   717 	    XftTextExtents8( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar8*)string, len, &extents);
   746             XftTextExtents8(DISPLAY(displayId), __xftFont, (FcChar8*)string, len, &extents);
   718 	    break;
   747             break;
   719 	case 2:
   748         case 2:
   720 	    XftTextExtents16( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar16*)string, len, &extents);
   749             XftTextExtents16(DISPLAY(displayId), __xftFont, (FcChar16*)string, len, &extents);
   721 	    break;
   750             break;
   722 	case 4:
   751         case 4:
   723 	    XftTextExtents32( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar32*)string, len, &extents);
   752             XftTextExtents32(DISPLAY(displayId), __xftFont, (FcChar32*)string, len, &extents);
   724 	    break;
   753             break;
   725 	}
   754         }
   726 	XftDrawRect( XFT_DRAW ( __INST( sharedDrawId ) ), &color, __intVal(drawX) - extents.x, __intVal(drawY) - XFT_FONT( __INST( fontId ) )->ascent, extents.width, XFT_FONT(__INST (fontId ) )->height);
   755         XftDrawRect(__sharedDrawId, &color, __intVal(drawX) - extents.x, __intVal(drawY) - __xftFont->ascent, extents.width, __xftFont->height);
   727     }
   756     }
   728     if (fgPixel != nil) {
   757     if (fgPixel != nil) {
   729 	color.pixel = (unsigned long)__intVal(fgPixel);
   758         color.pixel = (unsigned long)__intVal(fgPixel);
   730     }
   759     }
   731     // else {
   760     // else {
   732 	color.color.red = __intVal(fgR);
   761         color.color.red = __intVal(fgR);
   733 	color.color.green = __intVal(fgG);
   762         color.color.green = __intVal(fgG);
   734 	color.color.blue = __intVal(fgB);
   763         color.color.blue = __intVal(fgB);
   735 	color.color.alpha = __intVal(fgA);
   764         color.color.alpha = __intVal(fgA);
   736     // }
   765     // }
   737     switch (__bytesPerCharacter) {
   766     switch (__bytesPerCharacter) {
   738     case 1:
   767     case 1:
   739 	XftDrawString8( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ),
   768         XftDrawString8(__sharedDrawId, &color,__xftFont,
   740 			__intVal(drawX),
   769                         __intVal(drawX),
   741 			__intVal(drawY),
   770                         __intVal(drawY),
   742 			(FcChar8*)string,
   771                         (FcChar8*)string,
   743 			len);
   772                         len);
   744 	RETURN ( self );
   773         break;
   745 	break;
   774 
   746     case 2:
   775     case 2:
   747 	XftDrawString16( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ),
   776         XftDrawString16(__sharedDrawId, &color, __xftFont,
   748 			__intVal(drawX),
   777                         __intVal(drawX),
   749 			__intVal(drawY),
   778                         __intVal(drawY),
   750 			(FcChar16*)string,
   779                         (FcChar16*)string,
   751 			len);
   780                         len);
   752 	RETURN ( self );
   781         break;
   753 	break;
   782 
   754     case 4:
   783     case 4:
   755 	XftDrawString32( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ),
   784         XftDrawString32(__sharedDrawId, &color, __xftFont,
   756 			__intVal(drawX),
   785                         __intVal(drawX),
   757 			__intVal(drawY),
   786                         __intVal(drawY),
   758 			(FcChar32*)string,
   787                         (FcChar32*)string,
   759 			len);
   788                         len);
   760 	RETURN ( self );
   789         break;
   761 	break;
   790 
   762     }
   791     default:
       
   792         goto err;
       
   793     }
       
   794 
       
   795 # if 0 // this has been superseeded by receiving change messages on view destroy
       
   796     // Have to disassociate the drawableId - otherwise we get an X11 error 'RenderBadPicture (invalid Picture parameter)'
       
   797     // when the drawable (the window) is destroyed.
       
   798     XftDrawChange(__sharedDrawId, None);
       
   799 # endif
       
   800     RETURN(self);
       
   801 
   763     err:;
   802     err:;
   764 #endif
   803 #endif
   765 %}.
   804 %}.
   766     self primitiveFailed: error.
   805     self primitiveFailed: error.
   767 
   806 
   772 !XftFontDescription methodsFor:'error reporting'!
   811 !XftFontDescription methodsFor:'error reporting'!
   773 
   812 
   774 primitiveFailed
   813 primitiveFailed
   775     <resource: #skipInDebuggersWalkBack>
   814     <resource: #skipInDebuggersWalkBack>
   776 
   815 
   777     self xftAvailable ifFalse:[
   816     self class xftAvailable ifFalse:[
   778 	super primitiveFailed:'Xft support is not configured'.
   817         super primitiveFailed:'Xft support is not configured'.
   779     ].
   818     ].
   780     super primitiveFailed
   819     super primitiveFailed
   781 !
   820 !
   782 
   821 
   783 primitiveFailed:errorString
   822 primitiveFailed:errorString
   784     <resource: #skipInDebuggersWalkBack>
   823     <resource: #skipInDebuggersWalkBack>
   785 
   824 
   786     self xftAvailable ifFalse:[
   825     self class xftAvailable ifFalse:[
   787 	super primitiveFailed:'Xft support is not configured'.
   826         super primitiveFailed:'Xft support is not configured'.
   788     ].
   827     ].
   789     super primitiveFailed:errorString
   828     super primitiveFailed:errorString
   790 ! !
   829 ! !
   791 
   830 
   792 !XftFontDescription methodsFor:'getting a device font'!
   831 !XftFontDescription methodsFor:'getting a device font'!
   939     "Modified: / 30-12-2013 / 12:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   978     "Modified: / 30-12-2013 / 12:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   940 ! !
   979 ! !
   941 
   980 
   942 !XftFontDescription methodsFor:'primitives'!
   981 !XftFontDescription methodsFor:'primitives'!
   943 
   982 
   944 xftAvailable
   983 disassociateXftDrawableFrom:drawableId
   945 %{
   984     "Disassociate the XftDrawable from drawableId.
   946 #ifdef XFT
   985      This mist be done before the drawable is destroyed,
   947     RETURN ( true )
   986      otherwise the XftDrawable is destroyed together with the drawable,
   948 #endif
   987      and X11 errors will be signaled."
   949 %}.
   988 
   950     ^ false
       
   951 
       
   952     "Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   953 !
       
   954 
       
   955 xftDrawChange: xftDrawId drawable: drawableId
       
   956     | error |
   989     | error |
   957 
   990 
   958 %{
   991 %{
   959 #ifdef XFT
   992 #ifdef XFT
       
   993     if (!__isExternalAddressLike(__INST(sharedDrawId))) {
       
   994         // nothing to disasassociate from...
       
   995         RETURN(self);
       
   996     }
       
   997     if (!__isExternalAddressLike(drawableId)) {
       
   998         error = @symbol(BadArg);
       
   999         goto err;
       
  1000     }
       
  1001     if (XftDrawDrawable(XFT_DRAW(__INST(sharedDrawId))) == DRAWABLE(drawableId)) {
       
  1002         XftDrawChange(XFT_DRAW(__INST(sharedDrawId)), None);
       
  1003     }
       
  1004     RETURN(self);
       
  1005 err:;
       
  1006 #endif
       
  1007 %}.
       
  1008     self primitiveFailed: error
       
  1009 
       
  1010     "Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1011 !
       
  1012 
       
  1013 xftDrawChange:xftDrawId drawable:drawableId
       
  1014     | error |
       
  1015 
       
  1016 %{
       
  1017 #ifdef XFT
   960     if ( ! __isExternalAddressLike(xftDrawId) ) {
  1018     if ( ! __isExternalAddressLike(xftDrawId) ) {
   961 	error = @symbol(BadArg1);
  1019         error = @symbol(BadArg1);
   962 	goto err;
  1020         goto err;
       
  1021     }
       
  1022     if (drawableId == nil) {
       
  1023         XftDrawChange(XFT_DRAW(xftDrawId), None);
       
  1024         RETURN (self);
   963     }
  1025     }
   964     if ( ! __isExternalAddressLike(drawableId) ) {
  1026     if ( ! __isExternalAddressLike(drawableId) ) {
   965 	error = @symbol(BadArg2);
  1027         error = @symbol(BadArg2);
   966 	goto err;
  1028         goto err;
   967     }
  1029     }
   968     if (XftDrawDrawable( XFT_DRAW(xftDrawId) ) != DRAWABLE( drawableId ) ) {
  1030     if (XftDrawDrawable( XFT_DRAW(xftDrawId) ) != DRAWABLE( drawableId ) ) {
   969 	XftDrawChange( XFT_DRAW(xftDrawId) , DRAWABLE( drawableId ) );
  1031         XftDrawChange( XFT_DRAW(xftDrawId) , DRAWABLE( drawableId ) );
   970     }
  1032     }
   971     RETURN ( self );
  1033     RETURN (self);
   972     err:;
  1034 err:;
   973 #endif
  1035 #endif
   974 %}.
  1036 %}.
   975     self primitiveFailed: error
  1037     self primitiveFailed: error
   976 
  1038 
   977     "Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1039     "Created: / 26-12-2013 / 12:17:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1768     sharedDrawId := nil.
  1830     sharedDrawId := nil.
  1769     closestFont := nil
  1831     closestFont := nil
  1770 ! !
  1832 ! !
  1771 
  1833 
  1772 !XftFontDescription methodsFor:'testing'!
  1834 !XftFontDescription methodsFor:'testing'!
       
  1835 
       
  1836 isScaledFont
       
  1837     "Xft fonts are always scaled"
       
  1838 
       
  1839     ^ true
       
  1840 !
  1773 
  1841 
  1774 isUsed
  1842 isUsed
  1775     ^ sharedDrawId notNil
  1843     ^ sharedDrawId notNil
  1776 !
  1844 !
  1777 
  1845 
  2092 ! !
  2160 ! !
  2093 
  2161 
  2094 !XftFontDescription class methodsFor:'documentation'!
  2162 !XftFontDescription class methodsFor:'documentation'!
  2095 
  2163 
  2096 version
  2164 version
  2097     ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.70 2015-05-31 09:29:15 cg Exp $'
  2165     ^ '$Header$'
  2098 !
  2166 !
  2099 
  2167 
  2100 version_CVS
  2168 version_CVS
  2101     ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.70 2015-05-31 09:29:15 cg Exp $'
  2169     ^ '$Header$'
  2102 ! !
  2170 ! !
  2103 
  2171 
  2104 
  2172 
  2105 XftFontDescription initialize!
  2173 XftFontDescription initialize!