#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Tue, 30 Aug 2016 18:51:30 +0200
changeset 7525 ee2bf9b6606c
parent 7524 780f829a2e1f
child 7526 d0199171a370
#UI_ENHANCEMENT by cg class: XftFontDescription changed: #onDevice:ifAbsent:
XftFontDescription.st
--- a/XftFontDescription.st	Tue Aug 30 17:02:38 2016 +0200
+++ b/XftFontDescription.st	Tue Aug 30 18:51:30 2016 +0200
@@ -910,79 +910,80 @@
     |displayId myPatternHandle closestPatternHandle newFontId computedWeight|
 
     (device == aGraphicsDevice) ifTrue:[
-	"I am already assigned to that device ..."
-	^ self
+        "I am already assigned to that device ..."
+        ^ self
     ].
     aGraphicsDevice isNil ifTrue:[
-	^ self
+        ^ self
     ].
     aGraphicsDevice supportsXftFonts ifFalse:[
-	^ self asNonXftFont onDevice:aGraphicsDevice.
+        ^ self asNonXftFont onDevice:aGraphicsDevice.
     ].
 
     RecentlyUsedFonts isNil ifTrue:[
-	RecentlyUsedFonts := OrderedCollection new:20.
+        RecentlyUsedFonts := OrderedCollection new:20.
     ].
 
     RecentlyUsedFonts keysAndValuesDo:[:index :aFont |
-	((aFont class == self class) and:[(self sameDeviceFontAs:aFont) and:[aFont getXftFontId notNil]]) ifTrue:[
-	    "/ Transcript showCR:'hit'.
-	    RecentlyUsedFonts
-		removeIndex:index;
-		addFirst:aFont.
-	    ^ aFont
-	]
+        ((aFont class == self class) and:[(self sameDeviceFontAs:aFont) and:[aFont getXftFontId notNil]]) ifTrue:[
+            "/ Transcript showCR:'hit'.
+            RecentlyUsedFonts
+                removeIndex:index;
+                addFirst:aFont.
+            ^ aFont
+        ]
     ].
 
     RecentlyUsedFonts size >= 20 ifTrue:[
-	RecentlyUsedFonts removeLast.
+        RecentlyUsedFonts removeLast.
     ].
 
     aGraphicsDevice deviceFonts do:[:aFont |
-	((aFont class == self class) and:[self sameDeviceFontAs:aFont]) ifTrue:[
-	    RecentlyUsedFonts addFirst:aFont.
-	    ^ aFont
-	].
+        ((aFont class == self class) and:[self sameDeviceFontAs:aFont]) ifTrue:[
+            RecentlyUsedFonts addFirst:aFont.
+            ^ aFont
+        ].
     ].
 
 "/    ^ self asNonXftFont onDevice:aGraphicsDevice.
 
     computedWeight := weight.
     computedWeight isNil ifTrue:[
-	computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR].
+        computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR].
     ].
 
     [
-	myPatternHandle := FCPatternHandle create.
-	myPatternHandle
-	    add:FC_FOUNDRY value:manufacturer;
-	    add:FC_FAMILY value:family;
-	    add:FC_WEIGHT value:computedWeight;
-	    add:FC_SLANT  value:(StXStyle2FCSlantMap at:(style ? '') asLowercase ifAbsent:[FC_SLANT_ROMAN]).
-	sizeUnit = #px ifTrue:[
-	    myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]).
-	] ifFalse:[
-	    myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]).
-	].
+        myPatternHandle := FCPatternHandle create.
+        myPatternHandle
+            add:FC_FOUNDRY value:manufacturer;
+            add:FC_FAMILY value:family;
+            add:FC_WEIGHT value:computedWeight;
+            add:FC_SLANT  value:(StXStyle2FCSlantMap at:(style ? '') asLowercase ifAbsent:[FC_SLANT_ROMAN]).
+        sizeUnit = #px ifTrue:[
+            myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]).
+        ] ifFalse:[
+            myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]).
+        ].
 
-	displayId := aGraphicsDevice displayId.
+        displayId := aGraphicsDevice displayId.
 
-	closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen.
-	closestPatternHandle notNil ifTrue:[
-	    newFontId := closestPatternHandle getFontOnDisplayId:displayId.
-	    newFontId notNil ifTrue:[
-		"/ Good, this font exists!!
-		closestPatternHandle := nil.
-		fontId := newFontId.
-		device := aGraphicsDevice.
-		aGraphicsDevice registerFont:self.
-		RecentlyUsedFonts addFirst:self.
-		^ self.
-	    ].
-	].
+        'XftFont: matching font (this may take a long time, if the system''s font cache needs to be filled first. Be patient...' infoPrintCR.
+        closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen.
+        closestPatternHandle notNil ifTrue:[
+            newFontId := closestPatternHandle getFontOnDisplayId:displayId.
+            newFontId notNil ifTrue:[
+                "/ Good, this font exists!!
+                closestPatternHandle := nil.
+                fontId := newFontId.
+                device := aGraphicsDevice.
+                aGraphicsDevice registerFont:self.
+                RecentlyUsedFonts addFirst:self.
+                ^ self.
+            ].
+        ].
     ] ensure:[
-	myPatternHandle notNil ifTrue:[myPatternHandle destroy].
-	closestPatternHandle notNil ifTrue:[closestPatternHandle destroy].
+        myPatternHandle notNil ifTrue:[myPatternHandle destroy].
+        closestPatternHandle notNil ifTrue:[closestPatternHandle destroy].
     ].
     ^ aBlock value