pixel fonts
authorClaus Gittinger <cg@exept.de>
Wed, 25 Feb 2009 17:34:17 +0100
changeset 3841 f8cc80f595ce
parent 3840 0d7d1b7bd6ec
child 3842 88de8b4c49ee
pixel fonts
FontPanel.st
--- a/FontPanel.st	Mon Feb 23 16:00:07 2009 +0100
+++ b/FontPanel.st	Wed Feb 25 17:34:17 2009 +0100
@@ -16,7 +16,7 @@
 		revertButton currentFamily currentFace currentStyle
 		currentFaceAndStyle currentSize sizeUnit currentEncoding
 		selectedFont nameLabel encodingFilter encodingLabel filter
-		encoding sizeLabelHolder'
+		encoding sizeLabelHolder pixelPointSwitch'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-DialogBoxes'
@@ -473,6 +473,8 @@
 
     selectedFont := aFont.
     encoding := aFont encoding.    
+    sizeUnit := aFont sizeUnit.
+
 "/ self halt.
     encodingFilter contents:encoding.
     self encodingFilterSelected:encoding.
@@ -494,7 +496,7 @@
 
 initialize
     |familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3
-     mm fH eH l box1 box2 showFontNameLabel pixelPointSwitch sep|
+     mm fH eH l box1 box2 showFontNameLabel sep|
 
     super initialize.
 
@@ -566,7 +568,7 @@
     pixelPointSwitch := ComboListView in:box2.
     "/ encodingFilter font:l font.
     pixelPointSwitch level:-1.
-    pixelPointSwitch contents:'point'.
+    pixelPointSwitch contents:'pt'.
     pixelPointSwitch list:#(#pt #px).
     pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit].
     box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm.
@@ -770,6 +772,8 @@
 
     |font allFonts fonts|
 
+    self assert:(currentSize notNil).
+
     allFonts := device 
                     fontsInFamily:(currentFamily ? '*')
                     face:(currentFace ? '*')
@@ -886,7 +890,8 @@
         ].
         self faceSelected:faceAndStyle showPreview:false.
         faceAndStyle notNil ifTrue:[
-            sz := selectedFont size.
+            sz := sizeUnit == #px ifTrue:[selectedFont pixelSize] ifFalse:[selectedFont size].
+            pixelPointSwitch contents:sizeUnit.
             self sizeSelected:sz showPreview:false. 
         ]
     ].
@@ -1015,6 +1020,7 @@
     (sizes isEmptyOrNil) ifTrue:[
         sizeList list:nil.
         currentSize := nil.
+self halt.
         showPreview ifTrue:[
             self showPreview.
         ].
@@ -1107,6 +1113,7 @@
                         face:currentFace 
                         style:currentStyle 
                         size:currentSize 
+                        sizeUnit:(sizeUnit ? #pt)
                         encoding:(currentEncoding ? encoding)).
         ]
     ]
@@ -1165,21 +1172,26 @@
     |sizes sizeStrings|
 
     sizes := self 
-                getSizesInFamily:(currentFamily ? '*')
-                face:(currentFace ? '*')
-                style:(currentStyle ? '*')
-                filtering:filter.
+            getSizesInFamily:(currentFamily ? '*')
+            face:(currentFace ? '*')
+            style:(currentStyle ? '*')
+            filtering:filter.
 
     (sizes isEmptyOrNil) ifTrue:[
         sizeList list:nil.
         currentSize := nil.
+self halt.
         ^ self
     ].
 
     sizes := sizes asOrderedCollection.
     selectedFont notNil ifTrue:[
-        (sizes includes:selectedFont size) ifFalse:[
-            sizes add:selectedFont size
+        currentSize := (selectedFont sizeUnit == #px)
+                         ifTrue:[ selectedFont pixelSize ]
+                         ifFalse:[ selectedFont size ].
+
+        (sizes includes:currentSize) ifFalse:[
+            sizes add:currentSize
         ].
     ].
     sizes sort.
@@ -1196,5 +1208,5 @@
 !FontPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.98 2009-02-18 17:56:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.99 2009-02-25 16:34:17 cg Exp $'
 ! !