# HG changeset patch # User Claus Gittinger # Date 1526740030 -7200 # Node ID fe8c5c603811c5d2e36a5ee6dab4e787f7e0e7bb # Parent 512cb726b5f0d83b659f4b9547c4412452dcbd2b #FEATURE by cg class: XftFontDescription changed: #onDevice:ifAbsent: class: XftFontDescription class added: #fixedLC_CTYPE class: XftFontDescription::FCFontListParser changed: #listOfAvailableFonts diff -r 512cb726b5f0 -r fe8c5c603811 XftFontDescription.st --- a/XftFontDescription.st Sat May 19 16:21:45 2018 +0200 +++ b/XftFontDescription.st Sat May 19 16:27:10 2018 +0200 @@ -573,6 +573,23 @@ " ! ! +!XftFontDescription class methodsFor:'utilities'! + +fixedLC_CTYPE + "to suppress the disturbing warning messages from fontconfig, + if LC_CTYPE is wrong (osx problem only?)" + + |lc_CTYPE| + + lc_CTYPE := OperatingSystem getEnvironment:'LC_CTYPE'. + lc_CTYPE = 'UTF-8' ifTrue:[ + ^ (Smalltalk language + ,'_',Smalltalk languageTerritory asUppercase + ,'.UTF-8'). + ]. + ^ lc_CTYPE +! ! + !XftFontDescription methodsFor:'accessing'! encoding @@ -769,65 +786,67 @@ |displayId myPatternHandle closestPatternHandle newFontId computedWeight deviceFont| (device == aGraphicsDevice) ifTrue:[ - "I am already assigned to that device ..." - ^ self + "I am already assigned to that device ..." + ^ self ]. aGraphicsDevice isNil ifTrue:[ - ^ self + ^ self ]. aGraphicsDevice supportsXftFonts ifFalse:[ - ^ self asNonXftFont onDevice:aGraphicsDevice. + ^ self asNonXftFont onDevice:aGraphicsDevice. ]. deviceFont := aGraphicsDevice deviceFonts detect:[:eachFont | self sameDeviceFontAs:eachFont] ifNone:[]. deviceFont notNil ifTrue:[ - ^ deviceFont. + ^ deviceFont. ]. computedWeight := weight. computedWeight isNil ifTrue:[ - computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR]. + computedWeight := StXFace2FCWeightMap at:(face ? '') asLowercase ifAbsent:[FC_WEIGHT_REGULAR]. ]. (OperatingSystem isMAClike and:[FirstTimeCalled ~~ false]) ifTrue:[ - "Slow font matching is a MAC-only feature" - Logger info:'XFT: matching font (this may take a long time, if the system''s font cache needs to be filled first. Be patient...'. - FirstTimeCalled := false. + "Slow font matching is a MAC-only feature" + Logger info:'XFT: matching font (this may take a long time, if the system''s font cache needs to be filled first. Be patient...'. + FirstTimeCalled := false. ]. [ - myPatternHandle := FCPatternHandle create. - myPatternHandle - add:FC_FOUNDRY value:manufacturer; - add:FC_FAMILY value:family; - add:FC_WEIGHT value:computedWeight; - add:FC_SLANT value:(StXStyle2FCSlantMap at:(style ? '') asLowercase ifAbsent:[FC_SLANT_ROMAN]). - sizeUnit = #px ifTrue:[ - myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]). - ] ifFalse:[ - myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]). - ]. + myPatternHandle := FCPatternHandle create. + myPatternHandle + add:FC_FOUNDRY value:manufacturer; + add:FC_FAMILY value:family; + add:FC_WEIGHT value:computedWeight; + add:FC_SLANT value:(StXStyle2FCSlantMap at:(style ? '') asLowercase ifAbsent:[FC_SLANT_ROMAN]). + sizeUnit = #px ifTrue:[ + myPatternHandle add:FC_PIXEL_SIZE value:(pixelSize isNil ifTrue:[nil] ifFalse:[pixelSize rounded]). + ] ifFalse:[ + myPatternHandle add:FC_SIZE value:(size isNil ifTrue:[nil] ifFalse:[size rounded]). + ]. - displayId := aGraphicsDevice displayId. - closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen. - closestPatternHandle notNil ifTrue:[ - newFontId := closestPatternHandle getFontOnDisplayId:displayId. - newFontId notNil ifTrue:[ - "/ Good, this font exists!! - device isNil ifTrue:[ - deviceFont := self. - ] ifFalse:[ - deviceFont := self copy. - ]. - closestPatternHandle := nil. - deviceFont setDevice:aGraphicsDevice patternId:nil fontId:newFontId. - aGraphicsDevice registerFont:deviceFont. - ^ deviceFont. - ]. - ]. + displayId := aGraphicsDevice displayId. + + OperatingSystem setEnvironment:'LC_CTYPE' to:(self class fixedLC_CTYPE). + closestPatternHandle := myPatternHandle matchFontOnDisplayId:displayId screen:aGraphicsDevice screen. + closestPatternHandle notNil ifTrue:[ + newFontId := closestPatternHandle getFontOnDisplayId:displayId. + newFontId notNil ifTrue:[ + "/ Good, this font exists!! + device isNil ifTrue:[ + deviceFont := self. + ] ifFalse:[ + deviceFont := self copy. + ]. + closestPatternHandle := nil. + deviceFont setDevice:aGraphicsDevice patternId:nil fontId:newFontId. + aGraphicsDevice registerFont:deviceFont. + ^ deviceFont. + ]. + ]. ] ensure:[ - myPatternHandle notNil ifTrue:[myPatternHandle destroy]. - closestPatternHandle notNil ifTrue:[closestPatternHandle destroy]. + myPatternHandle notNil ifTrue:[myPatternHandle destroy]. + closestPatternHandle notNil ifTrue:[closestPatternHandle destroy]. ]. ^ aBlock value @@ -1294,12 +1313,8 @@ "/ 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 - ,'_',Smalltalk languageTerritory asUppercase - ,'.UTF-8'). - ]. + shellEnvironment := Dictionary new. + shellEnvironment at:'LC_CTYPE' put:XftFontDescription fixedLC_CTYPE. pipeStream := PipeStream readingFrom:fcListProg, ' -v'