1242 ! ! |
1244 ! ! |
1243 |
1245 |
1244 !XftFontDescription::FCFontListParser methodsFor:'api'! |
1246 !XftFontDescription::FCFontListParser methodsFor:'api'! |
1245 |
1247 |
1246 listOfAvailableFonts |
1248 listOfAvailableFonts |
1247 |readEntry list fcListProg| |
1249 |readEntry list fcListProg shellEnvironment| |
1248 |
1250 |
1249 list := OrderedCollection new. |
1251 list := OrderedCollection new. |
1250 |
1252 |
1251 readEntry := [ |
1253 readEntry := [ |
1252 |key line| |
1254 |key line| |
1253 |
1255 |
1254 [ |
1256 [ |
1255 line := pipeStream nextLine. |
1257 line := pipeStream nextLine. |
1256 ] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]]. |
1258 ] doUntil:[(line startsWith:'Pattern has') or:[Transcript showCR:line. false]]. |
1257 |
1259 |
1258 currentDescription := XftFontDescription new. |
1260 currentDescription := XftFontDescription new. |
1259 [line := pipeStream nextLine. line notEmptyOrNil] whileTrue:[ |
1261 [line := pipeStream nextLine. line notEmptyOrNil] whileTrue:[ |
1260 "/ Transcript showCR:l. |
1262 "/ Transcript showCR:l. |
1261 lineStream := line readStream. lineStream skipSeparators. |
1263 lineStream := line readStream. lineStream skipSeparators. |
1262 key := ('fc_', (lineStream upTo:$:)) asSymbolIfInterned. |
1264 key := ('fc_', (lineStream upTo:$:)) asSymbolIfInterned. |
1263 ( |
1265 ( |
1264 #(fc_family fc_style fc_slant fc_weight fc_width |
1266 #(fc_family fc_style fc_slant fc_weight fc_width |
1265 fc_pixelsize fc_spacing fc_foundry fc_antialias |
1267 fc_pixelsize fc_spacing fc_foundry fc_antialias |
1266 fc_file fc_outline fc_scalable fc_charset fc_lang |
1268 fc_file fc_outline fc_scalable fc_charset fc_lang |
1267 fc_fontversion fc_fontformat fc_decorative fc_index |
1269 fc_fontversion fc_fontformat fc_decorative fc_index |
1268 fc_outline fc_familylang fc_stylelang fc_fullname |
1270 fc_outline fc_familylang fc_stylelang fc_fullname |
1269 fc_fullnamelang fc_capability fc_hash fc_postscriptname |
1271 fc_fullnamelang fc_capability fc_hash fc_postscriptname |
1270 fc_symbol fc_color |
1272 fc_symbol fc_color |
1271 ) includesIdentical:key |
1273 ) includesIdentical:key |
1272 ) ifTrue:[ |
1274 ) ifTrue:[ |
1273 self perform:key. |
1275 self perform:key. |
1274 ] ifFalse:[ |
1276 ] ifFalse:[ |
1275 Transcript show:'Xft ignored line: '; showCR:line. |
1277 Transcript show:'Xft ignored line: '; showCR:line. |
1276 ]. |
1278 ]. |
1277 ]. |
1279 ]. |
1278 list add:currentDescription |
1280 list add:currentDescription |
1279 ]. |
1281 ]. |
1280 |
1282 |
1281 fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
1283 fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
1282 eachProg asFilename isExecutableProgram |
1284 eachProg asFilename isExecutableProgram |
1283 ] ifNone:[ |
1285 ] ifNone:[ |
1284 'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
1286 'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
1285 ^ list. |
1287 ^ list. |
1286 ]. |
1288 ]. |
1287 |
1289 |
1288 pipeStream := PipeStream readingFrom:fcListProg, ' -v'. |
1290 "/ to suppress the disturbing warning message |
|
1291 "/ if LC_CTYPE is wrong (osx problem) |
|
1292 (OperatingSystem getEnvironment:'LC_CTYPE') = 'UTF-8' ifTrue:[ |
|
1293 shellEnvironment := Dictionary new. |
|
1294 shellEnvironment at:'LC_CTYPE' put:(Smalltalk language,'.UTF-8'). |
|
1295 ]. |
|
1296 |
|
1297 pipeStream := PipeStream |
|
1298 readingFrom:fcListProg, ' -v' |
|
1299 environment:shellEnvironment. |
1289 [ |
1300 [ |
1290 [pipeStream atEnd] whileFalse:[ |
1301 [pipeStream atEnd] whileFalse:[ |
1291 readEntry value. |
1302 readEntry value. |
1292 ] |
1303 ] |
1293 ] ensure:[ |
1304 ] ensure:[ |
1294 pipeStream close |
1305 pipeStream close |
1295 ]. |
1306 ]. |
1296 ^ list |
1307 ^ list |
1297 |
1308 |
1298 " |
1309 " |
1299 FCFontListParser new listOfAvailableFonts |
1310 FCFontListParser new listOfAvailableFonts |