XftFontDescription.st
changeset 7116 ab09e688e134
parent 7115 f03fcb541d90
child 7121 a3833df3f396
--- a/XftFontDescription.st	Tue Feb 02 13:10:08 2016 +0100
+++ b/XftFontDescription.st	Tue Feb 02 15:42:27 2016 +0100
@@ -1402,6 +1402,16 @@
     ^ true
 ! !
 
+!XftFontDescription::FCFontListParser class methodsFor:'api'!
+
+listOfAvailableFonts
+    ^ self new listOfAvailableFonts
+
+    "
+       self listOfAvailableFonts
+    "
+! !
+
 !XftFontDescription::FCFontListParser class methodsFor:'documentation'!
 
 documentation
@@ -1423,56 +1433,53 @@
 !XftFontDescription::FCFontListParser methodsFor:'api'!
 
 listOfAvailableFonts
-    |readEntry list l fcListProg|
+    |readEntry list fcListProg|
 
     list := OrderedCollection new.
 
-    readEntry :=
-	[
-	    |key|
+    readEntry := [
+            |key line|
 
-	    [l startsWith:'Pattern has'] whileFalse:[
-	      l := pipeStream nextLine. Transcript showCR:l.
-	    ].
+            [
+                line := pipeStream nextLine.
+            ] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]].
 
-	    currentDescription := XftFontDescription new.
-	    [ l := pipeStream nextLine. l notEmptyOrNil ] whileTrue:[
-		"/ Transcript showCR:l.
-		lineStream := l readStream. lineStream skipSeparators.
-		key := lineStream upToSeparator.
-		(
-		    #('family:' 'style:' 'slant:' 'weight:' 'width:'
-		      'pixelsize:' 'spacing:' 'foundry:' 'antialias:'
-		      'file:' 'outline:' 'scalable:' 'charset:' 'lang:'
-		      'fontversion:' 'fontformat:' 'decorative:' 'index:'
-		      'outline:' 'familylang:' 'stylelang:' 'fullname:'
-		      'fullnamelang:' 'capability:' 'hash:' 'postscriptname:'
-		    ) includes:key
-		) ifTrue:[
-		    self perform:('fc_', (key allButLast)) asSymbol
-		] ifFalse:[
-		    Transcript show:'Xft ignored line: '; showCR:l.
-		    self breakPoint:#cg.
-		].
-	    ].
-	    list add:currentDescription
-	].
+            currentDescription := XftFontDescription new.
+            [line := pipeStream nextLine. line notEmptyOrNil] whileTrue:[
+                "/ Transcript showCR:l.
+                lineStream := line readStream. lineStream skipSeparators.
+                key := ('fc_', (lineStream upTo:$:)) asSymbolIfInterned.
+                (
+                    #(fc_family fc_style fc_slant fc_weight fc_width 
+                      fc_pixelsize fc_spacing fc_foundry fc_antialias
+                      fc_file fc_outline fc_scalable fc_charset fc_lang  
+                      fc_fontversion fc_fontformat fc_decorative fc_index
+                      fc_outline fc_familylang fc_stylelang fc_fullname
+                      fc_fullnamelang fc_capability fc_hash fc_postscriptname
+                    ) includesIdentical:key
+                ) ifTrue:[
+                    self perform:key.
+                ] ifFalse:[
+                    Transcript show:'Xft ignored line: '; showCR:line.
+                ].
+            ].
+            list add:currentDescription
+        ].
 
     fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg|
-			eachProg asFilename isExecutableProgram
-		    ] ifNone:[
-			'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR.
-			^ list.
-		    ].
+                        eachProg asFilename isExecutableProgram
+                    ] ifNone:[
+                        'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR.
+                        ^ list.
+                    ].
 
     pipeStream := PipeStream readingFrom:fcListProg, ' -v'.
     [
-	[pipeStream atEnd] whileFalse:[
-	    l := pipeStream nextLine.
-	    readEntry value.
-	]
+        [pipeStream atEnd] whileFalse:[
+            readEntry value.
+        ]
     ] ensure:[
-	pipeStream close
+        pipeStream close
     ].
     ^ list
 
@@ -1501,35 +1508,33 @@
     |page bits l min max minCode maxCode|
 
     [ l := pipeStream nextLine. l notEmpty ] whileTrue:[
-	"/ Transcript show:'->'; showCR:l.
-	(l startsWith:Character tab) ifFalse:[
-	    (l startsWith:'(') ifFalse:[self halt].
-	    currentDescription minCode:minCode.
-	    currentDescription maxCode:maxCode.
-	    ^ self.
-	].
+        "/ Transcript show:'->'; showCR:l.
+        (l startsWith:Character tab) ifFalse:[
+            (l startsWith:'(') ifFalse:[self halt].
+            currentDescription minCode:minCode; maxCode:maxCode.
+            ^ self.
+        ].
 
-	lineStream := l readStream.
-	lineStream skipSeparators.
-	page := Integer readFrom:(lineStream upTo:$:) radix:16.
-	lineStream next.
-	bits := 0 to:7 collect:[:i|
-	    lineStream skipSeparators.
-	    Integer readFrom:(lineStream upToSeparator) radix:16.
-	].
-	min := (page * 256 + 0).
-	max := (page * 256 + 255).
-	minCode isNil ifTrue:[
-	    minCode := min.
-	    maxCode := max.
-	] ifFalse:[
-	    minCode := minCode min:min.
-	    maxCode := maxCode max:max.
-	].
+        lineStream := l readStream.
+        lineStream skipSeparators.
+        page := Integer readFrom:(lineStream upTo:$:) radix:16.
+        lineStream next.
+        bits := 0 to:7 collect:[:i|
+            lineStream skipSeparators.
+            Integer readFrom:(lineStream upToSeparator) radix:16.
+        ].
+        min := (page * 256 + 0).
+        max := (page * 256 + 255).
+        minCode isNil ifTrue:[
+            minCode := min.
+            maxCode := max.
+        ] ifFalse:[
+            minCode := minCode min:min.
+            maxCode := maxCode max:max.
+        ].
     ].
     "/ currentDescription characterSet:(self getString).
-    currentDescription minCode:minCode.
-    currentDescription maxCode:maxCode.
+    currentDescription minCode:minCode; maxCode:maxCode.
 !
 
 fc_decorative
@@ -1714,9 +1719,8 @@
 getString
     "helper for font listing"
 
-    lineStream skipSeparators.
-    lineStream peekFor:$".
-    ^ (lineStream upTo:$").
+    lineStream skipThrough:$".
+    ^ lineStream upTo:$".
 ! !
 
 !XftFontDescription::FCPatternHandle class methodsFor:'instance creation'!