FontPanel.st
changeset 2843 5c470e6254d0
parent 2842 b660224c409a
child 2845 075391fc5ed1
--- a/FontPanel.st	Fri Feb 06 14:10:37 2004 +0100
+++ b/FontPanel.st	Fri Feb 06 14:25:45 2004 +0100
@@ -17,8 +17,8 @@
 DialogBox subclass:#FontPanel
 	instanceVariableNames:'previewField familyList faceList sizeList revertButton
 		currentFamily currentFace currentStyle currentFaceAndStyle
-		currentSize selectedFont nameLabel encodingFilter encodingLabel
-		filter encoding'
+		currentSize currentEncoding selectedFont nameLabel encodingFilter
+		encodingLabel filter encoding'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-DialogBoxes'
@@ -263,6 +263,9 @@
     "set the encoding goal"
 
     encoding := aPattern.
+    encodingFilter contents:encoding.
+
+    self encodingFilterSelected:encoding.
     shown ifTrue:[
         self updateFamilyList
     ].
@@ -289,6 +292,8 @@
     "set the font to be selected initially"
 
     selectedFont := aFont.
+    encodingFilter contents:aFont encoding.
+    self encodingFilterSelected:aFont encoding.
     self showSelectedFont.
     self showPreview
 
@@ -485,7 +490,7 @@
 showPreview
     "show the preview text"
 
-    |f enc s allFonts fonts fontName|
+    |font deviceFont enc s allFonts fonts fontName|
 
     self clearPreview.
 
@@ -502,14 +507,14 @@
 
         fonts := allFonts select:[:f | f size == currentSize].
         fonts notEmpty ifTrue:[
-            f := fonts anElement.
+            font := fonts anElement.
         ] ifFalse:[
             "/ mhmh
             "/ X returns size0 for scalable fonts. Any size is possible.
             "/
             fonts := allFonts select:[:f | f size == 0].
             fonts notEmpty ifTrue:[
-                f := Font family:currentFamily 
+                font := Font family:currentFamily 
                           face:currentFace 
                           style:currentStyle
                           size:currentSize      
@@ -517,14 +522,15 @@
             ]    
         ].
 
-        f notNil ifTrue:[
-            f := f onDevice:device.
-            previewField font:f.
+        font notNil ifTrue:[
+            deviceFont := font onDevice:device.
+            previewField font:deviceFont.
 
-            enc := f encoding.
+            enc := font encoding.
             enc isNil ifTrue:[enc := 'ascii ?'].
             encodingLabel label:enc.
-            fontName := f fullName.
+            currentEncoding := enc.
+            fontName := deviceFont fullName.
 
             (enc notNil and:[enc startsWith:'jis']) ifTrue:[
                 s := self class defaultJISSampleString
@@ -535,6 +541,7 @@
         ] ifFalse:[
             previewField contents:nil.
             encodingLabel label:nil.
+            currentEncoding := nil.
             fontName := nil.
         ].
         nameLabel notNil ifTrue:[nameLabel label:fontName].
@@ -544,9 +551,11 @@
 !
 
 showSelectedFont
-    |fam face faceAndStyle style sz enc|
+    |fam face faceAndStyle style sz|
 
     fam := selectedFont family.
+    currentEncoding := selectedFont encoding.
+
     self familySelected:fam.
     fam notNil ifTrue:[
         face := selectedFont face.
@@ -557,6 +566,7 @@
         faceAndStyle notNil ifTrue:[
             sz := selectedFont size.
             self sizeSelected:sz. 
+
 "/            sz notNil ifTrue:[
 "/                enc := selectedFont encoding.
 "/                self encodingSelected:enc 
@@ -716,14 +726,13 @@
     self hide.
     okAction notNil ifTrue:[
         currentFamily notNil ifTrue:[
-self halt.
             okAction 
                 value:(FontDescription
                         family:currentFamily 
                         face:currentFace 
                         style:currentStyle 
                         size:currentSize 
-                        encoding:encoding).
+                        encoding:(currentEncoding ? encoding)).
         ]
     ]
 
@@ -752,5 +761,5 @@
 !FontPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.53 2004-02-06 13:10:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.54 2004-02-06 13:25:45 cg Exp $'
 ! !