--- a/XftFontDescription.st Mon Dec 30 20:07:32 2013 +0100
+++ b/XftFontDescription.st Mon Dec 30 21:19:21 2013 +0100
@@ -1,17 +1,15 @@
"{ Package: 'stx:libview' }"
FontDescription subclass:#XftFontDescription
- instanceVariableNames:'device fontId drawId lasrFgColor lastFgColorId lastBgColor
- lastBgColorId'
+ instanceVariableNames:'device fontId drawId'
classVariableNames:'FC_FAMILY FC_STYLE FC_SLANT FC_WEIGHT FC_SIZE FC_ASPECT
FC_PIXEL_SIZE FC_SPACING FC_FOUNDRY FC_ANTIALIAS FC_HINTING
- FC_HINT_STYLE FC_VERTICAL_LAYOUT FC_AUTOHINT FC_GLOBAL_ADVANCE
- FC_WIDTH FC_FILE FC_INDEX FC_FT_FACE FC_RASTERIZER FC_OUTLINE
- FC_SCALABLE FC_SCALE FC_DPI FC_RGBA FC_MINSPACE FC_SOURCE
- FC_CHARSET FC_LANG FC_FONTVERSION FC_FULLNAME FC_FAMILYLANG
- FC_STYLELANG FC_FULLNAMELANG FC_CAPABILITY FC_FONTFORMAT
- FC_EMBOLDEN FC_EMBEDDED_BITMAP FC_DECORATIVE FC_LCD_FILTER
- FC_NAMELANG FC_CACHE_SUFFIX FC_DIR_CACHE_FILE FC_USER_CACHE_FILE
+ FC_HINT_STYLE FC_VERTICAL_LAYOUT FC_AUTOHINT FC_WIDTH FC_FILE
+ FC_INDEX FC_FT_FACE FC_RASTERIZER FC_OUTLINE FC_SCALABLE FC_SCALE
+ FC_DPI FC_RGBA FC_MINSPACE FC_SOURCE FC_CHARSET FC_LANG
+ FC_FONTVERSION FC_FULLNAME FC_FAMILYLANG FC_STYLELANG
+ FC_FULLNAMELANG FC_CAPABILITY FC_FONTFORMAT FC_EMBOLDEN
+ FC_EMBEDDED_BITMAP FC_DECORATIVE FC_LCD_FILTER FC_NAMELANG
FC_CHAR_WIDTH FC_CHAR_HEIGHT FC_MATRIX FC_WEIGHT_THIN
FC_WEIGHT_EXTRALIGHT FC_WEIGHT_ULTRALIGHT FC_WEIGHT_LIGHT
FC_WEIGHT_BOOK FC_WEIGHT_REGULAR FC_WEIGHT_NORMAL
@@ -214,7 +212,7 @@
FC_LCD_LIGHT := 2.
FC_LCD_LEGACY := 3.
- StXFace2FCWeightMap := Dictionary withKeysAndValues:{
+ StXFace2FCWeightMap := Dictionary withKeysAndValues:{
'regular'. FC_WEIGHT_REGULAR.
'medium'. FC_WEIGHT_MEDIUM.
'bold'. FC_WEIGHT_BOLD.
@@ -291,25 +289,10 @@
] ifFalse:[
self xftDrawChange: drawId drawable: aGC id
].
- lasrFgColor ~= aGC paint ifTrue:[
- lastFgColorId notNil ifTrue:[
- self xftColorDestroy: device displayId screen: device screen color: lastFgColorId.
- ].
- lasrFgColor := aGC paint.
- lastFgColorId := self xftColorCreate: device displayId screen: device screen color: lasrFgColor.
- ].
extents := self xftTextExtents: device displayId font: fontId string: aString from: index1 to: index2.
opaque ifTrue:[
-
- lastBgColor ~= aGC backgroundPaint ifTrue:[
- lastBgColorId notNil ifTrue:[
- self xftColorDestroy: device displayId screen: device screen color: lastBgColorId.
- ].
- lastBgColor := aGC backgroundPaint.
- lastBgColorId := self xftColorCreate: device displayId screen: device screen color: lastBgColor.
- ].
- self xftDrawRect: drawId color: lastBgColorId x: x y:y0 width: extents first height: extents second
+ self xftDrawRect: drawId color: aGC backgroundPaint x: x y:y0 width: extents first height: extents second
].
"true"false ifTrue:[
@@ -329,7 +312,7 @@
].
- self xftDrawString: drawId color: lastFgColorId font: fontId x: x y: y string: aString from: index1 to: index2
+ self xftDrawString: drawId color: aGC paint font: fontId x: x y: y string: aString from: index1 to: index2
"Created: / 21-12-2013 / 21:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 29-12-2013 / 11:38:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -466,88 +449,6 @@
"Created: / 20-12-2013 / 21:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-xftColorCreate: displayId screen: screen color: color
-
- | error r g b a |
-
- self primitiveFailedIfNoXft.
-
- r := color scaledRed.
- g := color scaledGreen.
- b := color scaledBlue.
- a := color alpha * 65535.
-%{
-#ifdef XFT
- XRenderColor xrcolor;
- XftColor *xftcolor;
-
- if ( ! __isExternalAddressLike(displayId) ) {
- error = @symbol(BadArg1);
- goto err;
- }
- if ( ! __isSmallInteger(screen) ) {
- error = @symbol(BadArg2);
- goto err;
- }
- xrcolor.red = __intVal(r);
- xrcolor.green = __intVal(g);
- xrcolor.blue = __intVal(b);
- xrcolor.alpha = __intVal(a);
-
- xftcolor = (XftColor*) malloc( sizeof( XftColor ) );
- XftColorAllocValue ( DISPLAY( displayId ) ,
- DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) ,
- DefaultColormap( DISPLAY( displayId), SCREEN (screen) ),
- &xrcolor,
- xftcolor );
- RETURN ( __MKEXTERNALADDRESS( xftcolor ) );
- err:;
-#endif
-%}.
- self primitiveFailed: error
-
- "Created: / 28-12-2013 / 11:55:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-xftColorDestroy: displayId screen: screen color: xftColorId
-
- | error |
-
- self primitiveFailedIfNoXft.
-
-%{
-#ifdef XFT
- XRenderColor xrcolor;
- XftColor *xftcolor;
-
- if ( ! __isExternalAddressLike(displayId) ) {
- error = @symbol(BadArg1);
- goto err;
- }
- if ( ! __isSmallInteger(screen) ) {
- error = @symbol(BadArg2);
- goto err;
- }
- if ( ! __isExternalAddressLike(xftColorId) ) {
- error = @symbol(BadArg3);
- goto err;
- }
-
- XftColorFree ( DISPLAY( displayId ) ,
- DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) ,
- DefaultColormap( DISPLAY( displayId), SCREEN (screen) ),
- XFT_COLOR( xftColorId ) );
- free( __externalAddressVal( xftColorId ) );
- __externalAddressVal( xftColorId ) = NULL;
- RETURN ( self );
- err:;
-#endif
-%}.
- self primitiveFailed: error
-
- "Created: / 28-12-2013 / 12:21:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
xftDrawChange: xftDrawId drawable: drawableId
| error |
@@ -606,19 +507,27 @@
"Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-xftDrawRect: drawIdArg color: colorIdArg x: x y: y width: w height: h
+xftDrawRect: drawIdArg color: color x: x y: y width: w height: h
- | error extents |
+ | error r g b a pix |
self primitiveFailedIfNoXft.
+ color isColor ifFalse:[^self primitiveFailed: #BadArg2].
+
+ r := color scaledRed.
+ g := color scaledGreen.
+ b := color scaledBlue.
+ a := color alpha * 65535.
+ pix := color colorId.
%{
#ifdef XFT
+ XftColor clr;
if ( ! __isExternalAddressLike(drawIdArg) ) {
error = @symbol(BadArg1);
goto err;
}
- if ( ! __isExternalAddressLike(colorIdArg) ) {
- error = @symbol(BadArg2);
+ if ( ! __isSmallInteger(pix) ) {
+ error = @symbol(BadColorId);
goto err;
}
if ( ! __isSmallInteger(x) ) {
@@ -637,7 +546,13 @@
error = @symbol(BadArg6);
goto err;
}
- XftDrawRect(XFT_DRAW(drawIdArg), XFT_COLOR(colorIdArg),
+ clr.pixel = (unsigned long)__intVal(pix);
+ clr.color.red = __intVal(r);
+ clr.color.green = __intVal(g);
+ clr.color.blue = __intVal(b);
+ clr.color.alpha = __intVal(a);
+
+ XftDrawRect(XFT_DRAW(drawIdArg), &clr,
__intVal(x), __intVal(y), __intVal(w) ,__intVal(h));
RETURN ( self );
@@ -649,25 +564,29 @@
"Created: / 28-12-2013 / 23:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-xftDrawString: drawIdArg color: colorIdArg font: fontIdArg x: x y: y string: text from: start to: stop
+xftDrawString: drawIdArg color: color font: fontIdArg x: x y: y string: text from: start to: stop
- | error extents |
+ | error r g b a pix |
self primitiveFailedIfNoXft.
+ color isColor ifFalse:[^self primitiveFailed: #BadArg2].
+
+ r := color scaledRed.
+ g := color scaledGreen.
+ b := color scaledBlue.
+ a := color alpha * 65535.
+ pix := color colorId.
%{
#ifdef XFT
int _start, _stop;
int _x, _y;
+ XftColor clr;
if ( ! __isExternalAddressLike(drawIdArg) ) {
error = @symbol(BadArg1);
goto err;
}
- if ( ! __isExternalAddressLike(colorIdArg) ) {
- error = @symbol(BadArg2);
- goto err;
- }
- if ( ! __isExternalAddressLike(fontIdArg) ) {
- error = @symbol(BadArg3);
+ if ( ! __isSmallInteger(pix) ) {
+ error = @symbol(BadColorId);
goto err;
}
if ( ! __isSmallInteger(x) ) {
@@ -693,8 +612,14 @@
}
_stop = __intVal(stop);
+ clr.pixel = (unsigned long)__intVal(pix);
+ clr.color.red = __intVal(r);
+ clr.color.green = __intVal(g);
+ clr.color.blue = __intVal(b);
+ clr.color.alpha = __intVal(a);
+
if ( __isStringLike(text) ) {
- XftDrawString8(XFT_DRAW(drawIdArg), XFT_COLOR(colorIdArg), XFT_FONT(fontIdArg),
+ XftDrawString8(XFT_DRAW(drawIdArg), &clr, XFT_FONT(fontIdArg),
_x, _y,
__stringVal(text) + (_start - 1), _stop - _start + 1);
RETURN ( self );
@@ -1222,7 +1147,7 @@
| extents |
- (stop < start) ifTrue:[^ 0].
+ (stop < start) ifTrue:[^ 0].
extents := self xftTextExtents: device displayId font: fontId string: aString from: start to: stop.
"/ extents --> #(width height x y xOff yOff)
^ extents fifth.
@@ -1234,11 +1159,11 @@
!XftFontDescription class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.8 2013-12-30 19:07:32 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.9 2013-12-30 20:19:21 vrany Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.8 2013-12-30 19:07:32 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/XftFontDescription.st,v 1.9 2013-12-30 20:19:21 vrany Exp $'
! !