--- a/XftFontDescription.st Mon May 07 15:55:29 2018 +0200
+++ b/XftFontDescription.st Tue May 08 12:34:42 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2013 by Jan Vrany
COPYRIGHT (c) 2013 by Claus Gittinger / eXept Software AG
@@ -1244,54 +1246,63 @@
!XftFontDescription::FCFontListParser methodsFor:'api'!
listOfAvailableFonts
- |readEntry list fcListProg|
+ |readEntry list fcListProg shellEnvironment|
list := OrderedCollection new.
readEntry := [
- |key line|
+ |key line|
- [
- line := pipeStream nextLine.
- ] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]].
+ [
+ line := pipeStream nextLine.
+ ] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]].
- 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
- fc_symbol fc_color
- ) includesIdentical:key
- ) ifTrue:[
- self perform:key.
- ] ifFalse:[
- Transcript show:'Xft ignored line: '; showCR:line.
- ].
- ].
- 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
+ fc_symbol fc_color
+ ) 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'.
+ "/ to suppress the disturbing warning message
+ "/ if LC_CTYPE is wrong (osx problem)
+ (OperatingSystem getEnvironment:'LC_CTYPE') = 'UTF-8' ifTrue:[
+ shellEnvironment := Dictionary new.
+ shellEnvironment at:'LC_CTYPE' put:(Smalltalk language,'.UTF-8').
+ ].
+
+ pipeStream := PipeStream
+ readingFrom:fcListProg, ' -v'
+ environment:shellEnvironment.
[
- [pipeStream atEnd] whileFalse:[
- readEntry value.
- ]
+ [pipeStream atEnd] whileFalse:[
+ readEntry value.
+ ]
] ensure:[
- pipeStream close
+ pipeStream close
].
^ list