--- a/XftFontDescription.st Sat Oct 03 16:08:31 2015 +0200
+++ b/XftFontDescription.st Sat Oct 03 23:20:08 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libview' }"
"{ NameSpace: Smalltalk }"
@@ -28,7 +30,7 @@
FC_RGBA_VBGR FC_RGBA_NONE FC_HINT_NONE FC_HINT_SLIGHT
FC_HINT_MEDIUM FC_HINT_FULL FC_LCD_NONE FC_LCD_DEFAULT
FC_LCD_LIGHT FC_LCD_LEGACY StXFace2FCWeightMap
- StXStyle2FCSlantMap CachedFontList RecentlyUsedFonts'
+ StXStyle2FCSlantMap CachedFontList RecentlyUsedFonts Lobby'
poolDictionaries:''
category:'Graphics-Support'
!
@@ -167,6 +169,10 @@
initialize
"Invoked at system start or when the class is dynamically loaded."
+ Lobby notNil ifTrue:[
+ Lobby := Registry new.
+ ].
+
" Taken from fontconfig,h "
FC_FAMILY := 'family'. "/* String */
@@ -274,28 +280,28 @@
FC_LCD_LEGACY := 3.
StXFace2FCWeightMap := Dictionary withKeysAndValues:{
- 'thin'. FC_WEIGHT_THIN.
- 'extralight'. FC_WEIGHT_EXTRALIGHT.
- 'ultralight'. FC_WEIGHT_ULTRALIGHT.
- 'light'. FC_WEIGHT_LIGHT.
- 'book'. FC_WEIGHT_BOOK.
- 'regular'. FC_WEIGHT_REGULAR.
- 'normal'. FC_WEIGHT_NORMAL.
- 'medium'. FC_WEIGHT_MEDIUM.
- 'demibold'. FC_WEIGHT_DEMIBOLD.
- 'semibold'. FC_WEIGHT_SEMIBOLD.
- 'bold'. FC_WEIGHT_BOLD.
- 'extrabold'. FC_WEIGHT_EXTRABOLD.
- 'ultrabold'. FC_WEIGHT_ULTRABOLD.
- 'black'. FC_WEIGHT_BLACK.
- 'heavy'. FC_WEIGHT_HEAVY.
- 'extrablack'. FC_WEIGHT_EXTRABLACK.
- 'ultrablack'. FC_WEIGHT_ULTRABLACK.
+ 'thin'. FC_WEIGHT_THIN.
+ 'extralight'. FC_WEIGHT_EXTRALIGHT.
+ 'ultralight'. FC_WEIGHT_ULTRALIGHT.
+ 'light'. FC_WEIGHT_LIGHT.
+ 'book'. FC_WEIGHT_BOOK.
+ 'regular'. FC_WEIGHT_REGULAR.
+ 'normal'. FC_WEIGHT_NORMAL.
+ 'medium'. FC_WEIGHT_MEDIUM.
+ 'demibold'. FC_WEIGHT_DEMIBOLD.
+ 'semibold'. FC_WEIGHT_SEMIBOLD.
+ 'bold'. FC_WEIGHT_BOLD.
+ 'extrabold'. FC_WEIGHT_EXTRABOLD.
+ 'ultrabold'. FC_WEIGHT_ULTRABOLD.
+ 'black'. FC_WEIGHT_BLACK.
+ 'heavy'. FC_WEIGHT_HEAVY.
+ 'extrablack'. FC_WEIGHT_EXTRABLACK.
+ 'ultrablack'. FC_WEIGHT_ULTRABLACK.
}.
StXStyle2FCSlantMap := Dictionary withKeysAndValues:{
- 'roman'. FC_SLANT_ROMAN.
- 'italic'. FC_SLANT_ITALIC.
- 'oblique'. FC_SLANT_OBLIQUE.
+ 'roman'. FC_SLANT_ROMAN.
+ 'italic'. FC_SLANT_ITALIC.
+ 'oblique'. FC_SLANT_OBLIQUE.
}.
"Modified: / 30-12-2013 / 19:48:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -598,7 +604,8 @@
|index2 bytesPerCharacter transformation
clipR clipX clipY clipW clipH clipPnt
fg fgR fgG fgB fgA fgPixel bg bgR bgG bgB bgA bgPixel
- drawX drawY drawPnt displayId screen drawableId error stringLen|
+ drawX drawY drawPnt displayId screen drawableId error stringLen
+ newXftDrawId newDrawableAssociation|
"limit the string len, otherwise bad output is generated"
stringLen := index2Arg - index1 + 1.
@@ -686,7 +693,6 @@
].
screen := device screen.
drawableId := aGC drawableId.
- aGC addDependent:self. "I need to be informed, when the GC is destroyed"
%{
#ifdef XFT
@@ -706,7 +712,8 @@
&& (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA)))
&& __isNonNilObject(aString)
)) {
- goto err;
+ error = @symbol(badArgument);
+ goto out;
}
__bytesPerCharacter = __intVal(bytesPerCharacter);
@@ -716,10 +723,12 @@
DRAWABLE(drawableId),
DefaultVisual(DISPLAY(displayId), SCREEN(screen)),
DefaultColormap(DISPLAY(displayId), SCREEN(screen)));
- __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW(__sharedDrawId);
+ __INST(sharedDrawId) = newXftDrawId = XFT_DRAW_HANDLE_NEW(__sharedDrawId);
__STORE(self, __INST(sharedDrawId));
+ newDrawableAssociation = true;
} else if (XftDrawDrawable(__sharedDrawId = XFT_DRAW(__INST(sharedDrawId))) != DRAWABLE(drawableId)) {
XftDrawChange(__sharedDrawId, DRAWABLE(drawableId));
+ newDrawableAssociation = true;
}
string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter);
@@ -793,7 +802,8 @@
break;
default:
- goto err;
+ error = @symbol(invalidStringSize);
+ goto out;
}
# if 0 // this has been superseeded by receiving change messages on view destroy
@@ -801,13 +811,18 @@
// when the drawable (the window) is destroyed.
XftDrawChange(__sharedDrawId, None);
# endif
- RETURN(self);
-
- err:;
+out:;
#endif
%}.
- self primitiveFailed: error.
-
+ error notNil ifTrue:[
+ self primitiveFailed: error.
+ ].
+ newDrawableAssociation notNil ifTrue:[
+ newXftDrawId notNil ifTrue:[
+ Lobby register:self.
+ ].
+ aGC addDependent:self. "I need to be informed, when the GC is destroyed"
+ ].
"Created: / 21-12-2013 / 21:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-01-2014 / 11:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -832,6 +847,16 @@
super primitiveFailed:errorString
! !
+!XftFontDescription methodsFor:'finalization'!
+
+finalizationLobby
+ ^ Lobby
+!
+
+finalize
+ self xftDrawDestroy
+! !
+
!XftFontDescription methodsFor:'getting a device font'!
onDevice:aGraphicsDevice
@@ -1072,6 +1097,20 @@
"Created: / 21-12-2013 / 21:12:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+xftDrawDestroy
+%{
+#ifdef XFT
+ if (__INST(sharedDrawId) != nil) {
+ XftDraw *xftDrawable = XFT_DRAW(__INST(sharedDrawId));
+ __INST(sharedDrawId) = nil;
+ XftDrawDestroy(xftDrawable);
+ }
+ RETURN (self);
+#endif
+%}.
+ self primitiveFailed.
+!
+
xftDrawRect: drawIdArg color: aColor x: x y: y width: w height: h
| error r g b a pix |
@@ -1829,10 +1868,13 @@
releaseFromDevice
"I am no longer available on the device"
+ Lobby unregister:self.
+ self xftDrawDestroy.
+
device := nil.
fontId := nil.
sharedDrawId := nil.
- closestFont := nil
+ closestFont := nil.
! !
!XftFontDescription methodsFor:'testing'!