more & better fontSelection stuff
authorClaus Gittinger <cg@exept.de>
Thu, 29 Feb 1996 04:49:45 +0100
changeset 479 a1ec90f1dc5c
parent 478 91a8a5889bf2
child 480 07ab9bbaea5f
more & better fontSelection stuff
DevWorkst.st
DeviceWorkstation.st
--- a/DevWorkst.st	Thu Feb 29 04:49:06 1996 +0100
+++ b/DevWorkst.st	Thu Feb 29 04:49:45 1996 +0100
@@ -2396,20 +2396,12 @@
     "return a set of all available font faces in aFamily on this display.
      But only those matching filterBlock (if nonNil)."
 
-    |allFonts faces "family face"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    faces := Set new.
-    allFonts do:[:fntDescr |
-        aFamilyName = fntDescr family ifTrue:[
-            (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
-                faces add:(fntDescr face)
-            ]
-        ]
-    ].
-    ^ faces asSortedCollection
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName filtering:filterBlock.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr face]) asSortedCollection
 
     "
      Display facesInFamily:'fixed' filtering:[:f |
@@ -2417,7 +2409,7 @@
     "
 
     "Created: 27.2.1996 / 01:33:25 / cg"
-    "Modified: 27.2.1996 / 01:34:11 / cg"
+    "Modified: 29.2.1996 / 04:29:01 / cg"
 !
 
 fontFamilies
@@ -2436,27 +2428,135 @@
     "return a set of all available font families on this display,
      but only those matching aFilterBlock (if nonNil)."
 
-    |allFonts families family|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-    families := Set new.
-    allFonts do:[:fntDescr |
-        (aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
-            family := fntDescr family.
-            family notNil ifTrue:[
-                families add:family
-            ]
-        ]
-    ].
-    ^ families asSortedCollection
+    |fonts|
+
+    fonts := self fontsFiltering:aFilterBlock.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr family]) asSortedCollection
 
     "
      Display fontFamiliesFiltering:[:f | 
         f encoding notNil and:[f encoding startsWith:'jis']]
     "
 
-    "Modified: 27.2.1996 / 01:31:48 / cg"
+    "Modified: 29.2.1996 / 04:31:51 / cg"
+!
+
+fontsFiltering:aFilterBlock
+    "return a set of all available font on this display,
+     but only those matching aFilterBlock (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
+            fntDescr family notNil ifTrue:[
+                fonts add:fntDescr
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsFiltering:[:f | 
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Modified: 29.2.1996 / 04:30:35 / cg"
+!
+
+fontsInFamily:aFamilyName face:aFaceName filtering:filter
+    "return a set of all available fonts in aFamily/aFace on this display.
+     But only thise matching filter (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFamilyName = fntDescr family) ifTrue:[
+            (aFaceName = fntDescr face) ifTrue:[
+                (filter isNil or:[filter value:fntDescr]) ifTrue:[
+                    fonts add:fntDescr
+                ]
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' face:'medium' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Created: 29.2.1996 / 04:32:56 / cg"
+!
+
+fontsInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter
+    "return a set of all available font in aFamily/aFace/aStyle
+     on this display.
+     But only those matching filter (if nonNIl)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFamilyName = fntDescr family) ifTrue:[
+            (aFaceName = fntDescr face) ifTrue:[
+                (aStyleName = fntDescr style) ifTrue:[
+                    (filter isNil or:[filter value:fntDescr]) ifTrue:[
+                        fonts add:fntDescr
+                    ]    
+                ]
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Created: 29.2.1996 / 04:25:30 / cg"
+!
+
+fontsInFamily:aFamilyName filtering:filterBlock
+    "return a set of all available font in aFamily on this display.
+     But only those matching filterBlock (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        aFamilyName = fntDescr family ifTrue:[
+            (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
+                fonts add:fntDescr
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Modified: 27.2.1996 / 01:34:11 / cg"
+    "Created: 29.2.1996 / 04:27:49 / cg"
 !
 
 fullNameOf:aFontId
@@ -2532,24 +2632,12 @@
      on this display.
      But only those matching filter (if nonNIl)."
 
-    |allFonts sizes "family face style size"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    sizes := Set new.
-    allFonts do:[:fntDescr |
-        (aFamilyName = fntDescr family) ifTrue:[
-            (aFaceName = fntDescr face) ifTrue:[
-                (aStyleName = fntDescr style) ifTrue:[
-                    (filter isNil or:[filter value:fntDescr]) ifTrue:[
-                        sizes add:fntDescr size
-                    ]    
-                ]
-            ]
-        ]
-    ].
-    ^ sizes
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ fonts collect:[:descr | descr size].
 
     "
      Display sizesInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
@@ -2557,6 +2645,7 @@
     "
 
     "Created: 27.2.1996 / 01:37:56 / cg"
+    "Modified: 29.2.1996 / 04:26:52 / cg"
 !
 
 stylesInFamily:aFamilyName face:aFaceName
@@ -2576,22 +2665,12 @@
     "return a set of all available font styles in aFamily/aFace on this display.
      But only thise matching filter (if nonNil)."
 
-    |allFonts styles "family face style"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    styles := Set new.
-    allFonts do:[:fntDescr |
-        (aFamilyName = fntDescr family) ifTrue:[
-            (aFaceName = fntDescr face) ifTrue:[
-                (filter isNil or:[filter value:fntDescr]) ifTrue:[
-                    styles add:fntDescr style
-                ]
-            ]
-        ]
-    ].
-    ^ styles asSortedCollection
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName face:aFaceName filtering:filter.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr style]) asSortedCollection
 
     "
      Display stylesInFamily:'fixed' face:'medium' filtering:[:f |
@@ -2599,6 +2678,7 @@
     "
 
     "Created: 27.2.1996 / 01:35:22 / cg"
+    "Modified: 29.2.1996 / 04:33:59 / cg"
 !
 
 widthOf:aString from:index1 to:index2 inFont:aFontId
@@ -3882,6 +3962,6 @@
 !DeviceWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.73 1996-02-28 18:54:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.74 1996-02-29 03:49:45 cg Exp $'
 ! !
 DeviceWorkstation initialize!
--- a/DeviceWorkstation.st	Thu Feb 29 04:49:06 1996 +0100
+++ b/DeviceWorkstation.st	Thu Feb 29 04:49:45 1996 +0100
@@ -2396,20 +2396,12 @@
     "return a set of all available font faces in aFamily on this display.
      But only those matching filterBlock (if nonNil)."
 
-    |allFonts faces "family face"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    faces := Set new.
-    allFonts do:[:fntDescr |
-        aFamilyName = fntDescr family ifTrue:[
-            (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
-                faces add:(fntDescr face)
-            ]
-        ]
-    ].
-    ^ faces asSortedCollection
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName filtering:filterBlock.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr face]) asSortedCollection
 
     "
      Display facesInFamily:'fixed' filtering:[:f |
@@ -2417,7 +2409,7 @@
     "
 
     "Created: 27.2.1996 / 01:33:25 / cg"
-    "Modified: 27.2.1996 / 01:34:11 / cg"
+    "Modified: 29.2.1996 / 04:29:01 / cg"
 !
 
 fontFamilies
@@ -2436,27 +2428,135 @@
     "return a set of all available font families on this display,
      but only those matching aFilterBlock (if nonNil)."
 
-    |allFonts families family|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-    families := Set new.
-    allFonts do:[:fntDescr |
-        (aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
-            family := fntDescr family.
-            family notNil ifTrue:[
-                families add:family
-            ]
-        ]
-    ].
-    ^ families asSortedCollection
+    |fonts|
+
+    fonts := self fontsFiltering:aFilterBlock.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr family]) asSortedCollection
 
     "
      Display fontFamiliesFiltering:[:f | 
         f encoding notNil and:[f encoding startsWith:'jis']]
     "
 
-    "Modified: 27.2.1996 / 01:31:48 / cg"
+    "Modified: 29.2.1996 / 04:31:51 / cg"
+!
+
+fontsFiltering:aFilterBlock
+    "return a set of all available font on this display,
+     but only those matching aFilterBlock (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
+            fntDescr family notNil ifTrue:[
+                fonts add:fntDescr
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsFiltering:[:f | 
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Modified: 29.2.1996 / 04:30:35 / cg"
+!
+
+fontsInFamily:aFamilyName face:aFaceName filtering:filter
+    "return a set of all available fonts in aFamily/aFace on this display.
+     But only thise matching filter (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFamilyName = fntDescr family) ifTrue:[
+            (aFaceName = fntDescr face) ifTrue:[
+                (filter isNil or:[filter value:fntDescr]) ifTrue:[
+                    fonts add:fntDescr
+                ]
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' face:'medium' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Created: 29.2.1996 / 04:32:56 / cg"
+!
+
+fontsInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter
+    "return a set of all available font in aFamily/aFace/aStyle
+     on this display.
+     But only those matching filter (if nonNIl)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        (aFamilyName = fntDescr family) ifTrue:[
+            (aFaceName = fntDescr face) ifTrue:[
+                (aStyleName = fntDescr style) ifTrue:[
+                    (filter isNil or:[filter value:fntDescr]) ifTrue:[
+                        fonts add:fntDescr
+                    ]    
+                ]
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Created: 29.2.1996 / 04:25:30 / cg"
+!
+
+fontsInFamily:aFamilyName filtering:filterBlock
+    "return a set of all available font in aFamily on this display.
+     But only those matching filterBlock (if nonNil)."
+
+    |allFonts fonts|
+
+    allFonts := self listOfAvailableFonts.
+    allFonts isNil ifTrue:[^ nil].
+
+    fonts := Set new.
+    allFonts do:[:fntDescr |
+        aFamilyName = fntDescr family ifTrue:[
+            (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
+                fonts add:fntDescr
+            ]
+        ]
+    ].
+    ^ fonts
+
+    "
+     Display fontsInFamily:'fixed' filtering:[:f |
+        f encoding notNil and:[f encoding startsWith:'jis']]
+    "
+
+    "Modified: 27.2.1996 / 01:34:11 / cg"
+    "Created: 29.2.1996 / 04:27:49 / cg"
 !
 
 fullNameOf:aFontId
@@ -2532,24 +2632,12 @@
      on this display.
      But only those matching filter (if nonNIl)."
 
-    |allFonts sizes "family face style size"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    sizes := Set new.
-    allFonts do:[:fntDescr |
-        (aFamilyName = fntDescr family) ifTrue:[
-            (aFaceName = fntDescr face) ifTrue:[
-                (aStyleName = fntDescr style) ifTrue:[
-                    (filter isNil or:[filter value:fntDescr]) ifTrue:[
-                        sizes add:fntDescr size
-                    ]    
-                ]
-            ]
-        ]
-    ].
-    ^ sizes
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ fonts collect:[:descr | descr size].
 
     "
      Display sizesInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
@@ -2557,6 +2645,7 @@
     "
 
     "Created: 27.2.1996 / 01:37:56 / cg"
+    "Modified: 29.2.1996 / 04:26:52 / cg"
 !
 
 stylesInFamily:aFamilyName face:aFaceName
@@ -2576,22 +2665,12 @@
     "return a set of all available font styles in aFamily/aFace on this display.
      But only thise matching filter (if nonNil)."
 
-    |allFonts styles "family face style"|
-
-    allFonts := self listOfAvailableFonts.
-    allFonts isNil ifTrue:[^ nil].
-
-    styles := Set new.
-    allFonts do:[:fntDescr |
-        (aFamilyName = fntDescr family) ifTrue:[
-            (aFaceName = fntDescr face) ifTrue:[
-                (filter isNil or:[filter value:fntDescr]) ifTrue:[
-                    styles add:fntDescr style
-                ]
-            ]
-        ]
-    ].
-    ^ styles asSortedCollection
+    |fonts|
+
+    fonts := self fontsInFamily:aFamilyName face:aFaceName filtering:filter.
+    fonts size == 0 ifTrue:[^ nil].
+
+    ^ (fonts collect:[:descr | descr style]) asSortedCollection
 
     "
      Display stylesInFamily:'fixed' face:'medium' filtering:[:f |
@@ -2599,6 +2678,7 @@
     "
 
     "Created: 27.2.1996 / 01:35:22 / cg"
+    "Modified: 29.2.1996 / 04:33:59 / cg"
 !
 
 widthOf:aString from:index1 to:index2 inFont:aFontId
@@ -3882,6 +3962,6 @@
 !DeviceWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.73 1996-02-28 18:54:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.74 1996-02-29 03:49:45 cg Exp $'
 ! !
 DeviceWorkstation initialize!