--- a/FontPanel.st Tue Oct 06 22:31:00 2015 +0200
+++ b/FontPanel.st Tue Oct 06 22:32:06 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
@@ -158,7 +160,7 @@
defaultLatin1SampleString
"return the sample latin1 preview text"
- ^ (self defaultAsciiSampleString) , 'äöüÄÖÜßéèêå©'
+ ^ (self defaultAsciiSampleString) , 'äöüÄÖÜßéèêå©'
!
defaultSampleStringForEncoding:enc
@@ -202,8 +204,8 @@
|t|
t := (self defaultAsciiSampleString) , '
-diaresis: äöüÄÖÜß
-accent: éèêåÅ
+diaresis: äöüÄÖÜß
+accent: éèêåÅ
special: ' , #(16r20AC) asUnicodeString , '
math: ' , #(16r2200 16r2203 16r221E 16r2208 16r2209) asUnicodeString , '
cyrillic: ' , #(16r440 16r443 16r441 16r441 16r43A 16r438 16r439 16r20 16r44F 16r437 16r44B 16r43A) asUnicodeString , '
@@ -427,6 +429,7 @@
"
FontPanel openOn:(Font family:'courier' size:12)
FontPanel openOn:MenuPanel defaultFont
+ FontPanel fontFromUser
"
! !
@@ -491,7 +494,7 @@
currentStyle := aFont style.
currentFaceAndStyle := currentFace,'-',currentStyle.
- self xftFontsOnlyHolder value:(aFont isXftFont).
+"/ self xftFontsOnlyHolder value:(aFont isXftFont).
fontEncoding := aFont encoding.
sizeUnit := aFont sizeUnit.
sizeUnit = #px ifTrue:[
@@ -527,8 +530,8 @@
!
initialize
- |familyLabel faceLabel sizeLabel panel fontBrowserView v1 v2 v3
- mm fH eH l box1 box2 showFontNameLabel xftCheckBox vPanel|
+ |familyLabel faceLabel sizeLabel panel panel2 fontBrowserView fp v1 v2 v3
+ mm fH l box1 box2 showFontNameLabel xftCheckBox vPanel|
super initialize.
@@ -541,27 +544,39 @@
panel := View origin:0.0@0.0 corner:1.0@1.0 in:self.
panel bottomInset:(buttonPanel preferredHeight
- + (mm*3)
- + (showFontNameLabel ifTrue:24 ifFalse:0) ).
+ + (mm)
+ "+ (showFontNameLabel ifTrue:24 ifFalse:0)" ).
+
+ vPanel := VariableVerticalPanel in:panel.
+ vPanel origin:0.0@0.0 corner:1.0@1.0.
+
+ previewField := HVScrollableView for:TextView in:vPanel.
+ fontBrowserView := View in:vPanel.
+ fp := View in:fontBrowserView.
+ fp layout:(0.0@0.0 corner:1.0@1.0) asFractionalLayout.
+ fp layout bottomOffset:-75.
label := resources string:'Font dialog'.
- box1 := HorizontalPanelView in:panel.
- "/ box horizontalLayout:#leftFit.
- box1 horizontalLayout:#left.
- box1 origin:0.0@1.0 corner:0.8@1.0.
+ panel2 := VerticalPanelView in:fontBrowserView.
+ panel2 layout:(0.0@1.0 corner:1.0@1.0) asFractionalLayout.
+ panel2 layout topOffset:-75.
+
+ panel2 horizontalLayout:#fit.
+ panel2 verticalLayout:#top.
- box2 := HorizontalPanelView in:panel.
- "/ box horizontalLayout:#leftFit.
+ box1 := HorizontalPanelView in:panel2.
+ box1 height:25.
+ box1 horizontalLayout:#leftSpace.
+
+ box2 := HorizontalPanelView in:panel2.
+ box2 height:25.
box2 horizontalLayout:#right.
- box2 origin:0.8@1.0 corner:1.0@1.0.
l := Label label:(resources string:'Encoding:') in:box1.
l borderWidth:0.
l adjust:#left.
- eH := 0.
-
encodingFilter := ComboBoxView in:box1.
"/ encodingFilter font:l font.
encodingFilter level:-1.
@@ -571,10 +586,7 @@
encodingFilter immediateAccept:true.
"/ encodingFilter editor font:l font.
- self showEncodingFilter ifTrue:[
- eH := encodingFilter preferredHeight.
- box1 topInset:(eH negated-4); horizontalInset:mm.
- ] ifFalse:[
+ self showEncodingFilter ifFalse:[
encodingFilter beInvisible
].
@@ -585,9 +597,7 @@
"/ encodingFilter acceptOnPointerLeave:true.
encodingLabel := Label label:' ' in:box1.
- "/ eH := encodingLabel preferredExtent y.
- "/ encodingLabel origin:0.6@1.0 corner:1.0@1.0.
- "/ encodingLabel topInset:(eH negated); horizontalInset:mm.
+
encodingLabel level:0; adjust:#left.
encodingLabel adjust:#right.
self showEncodingFilter ifFalse:[
@@ -595,14 +605,10 @@
].
Screen current supportsXFTFonts ifTrue:[
- UserPreferences current useXftFontsOnly ifTrue:[
- self xftFontsOnlyHolder value: true.
- ] ifFalse:[
- self xftFontsOnlyHolder value: false.
- xftCheckBox := CheckBox label:'XFT Fonts Only' in:box1.
- xftCheckBox model:xftFontsOnlyHolder.
- xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ].
- ].
+ self xftFontsOnlyHolder value: (UserPreferences current useXftFontsOnly).
+ xftCheckBox := CheckBox label:'XFT Fonts Only' in:box1.
+ xftCheckBox model:xftFontsOnlyHolder.
+ xftFontsOnlyHolder onChangeEvaluate:[ self xftFontsOnlyChanged ].
].
"/ sep := View in:box1.
@@ -614,28 +620,21 @@
pixelPointSwitch contents:'pt'.
pixelPointSwitch list:#(#pt #px).
pixelPointSwitch action:[:sizeUnit | self sizeUnitSelected:sizeUnit].
- box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm.
+ "/ box2 topInset:(pixelPointSwitch preferredHeight negated-4); horizontalInset:mm.
"/ encodingFilter editor font:l font.
- self showEncodingFilter ifTrue:[
- eH := encodingFilter preferredHeight.
- box1 topInset:(eH negated-4); horizontalInset:mm.
- ] ifFalse:[
- encodingFilter beInvisible
- ].
+"/ self showEncodingFilter ifFalse:[
+"/ encodingFilter beInvisible
+"/ ].
showFontNameLabel ifTrue:[
- nameLabel := Label label:'' in:self.
- nameLabel origin:0.0@1.0 corner:1.0@1.0.
- nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)).
- nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm.
+ nameLabel := Label label:'' in:panel2.
+ "/ nameLabel origin:0.0@1.0 corner:1.0@1.0.
+ "/ nameLabel bottomInset:(buttonPanel preferredHeight + (mm*2)).
+ "/ nameLabel topInset:(buttonPanel preferredHeight + (mm*2) + 24) negated; horizontalInset:mm.
nameLabel level:0; adjust:#left.
].
- vPanel := VariableVerticalPanel in:panel.
- vPanel origin:0.0@0.0 corner:1.0@1.0.
-
- previewField := HVScrollableView for:TextView in:vPanel.
"/ previewField origin:0.0@0.0 corner:1.0@0.4.
previewField autoHideScrollBars:true.
previewField := previewField scrolledView.
@@ -647,12 +646,8 @@
previewField borderWidth:1.
].
- fontBrowserView := View in:vPanel.
- "/ fontBrowserView origin:0.0@0.4 corner:1.0@1.0.
- fontBrowserView bottomInset:(eH + mm).
-
- v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fontBrowserView.
-
+ v1 := View origin:0.0@0.0 corner:0.4@1.0 in:fp.
+
familyLabel := Label label:(resources string:'Family') in:v1.
familyLabel borderWidth:0.
familyLabel origin:(0.0 @ 0.0) extent:(1.0 @ nil).
@@ -666,7 +661,7 @@
familyList := familyList scrolledView.
self makeTabable:familyList.
- v2 := View origin:0.4@0.0 corner:0.8@1.0 in:fontBrowserView.
+ v2 := View origin:0.4@0.0 corner:0.8@1.0 in:fp.
faceLabel := Label label:(resources string:'Typeface') in:v2.
faceLabel borderWidth:0.
@@ -679,7 +674,7 @@
faceList := faceList scrolledView.
self makeTabable:faceList.
- v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fontBrowserView.
+ v3 := View origin:0.8@0.0 corner:1.0@1.0 in:fp.
sizeLabelHolder := (resources string:'Size') asValue.
sizeLabel := Label in:v3.
@@ -702,6 +697,7 @@
"
FontPanel new showAtPointer
+ FontPanel fontFromUser
"
"Modified: 31.5.1996 / 22:01:45 / cg"
@@ -851,6 +847,7 @@
fonts size > 1 ifTrue:[
'FontPanel [info]: huh - multiple entries: ' infoPrint. fonts infoPrintCR.
+ "/ self halt.
].
fontShown := fonts first.
fontShown isScaledFont ifTrue:[
@@ -928,9 +925,18 @@
getFamilyList
"the list of font families"
- |d|
+ |d sav_useXftFontsOnly sav_useXFontsOnly|
- allFonts := self graphicsDevice listOfAvailableFonts.
+ sav_useXftFontsOnly := UserPreferences current useXftFontsOnly.
+ sav_useXFontsOnly := UserPreferences current useXFontsOnly.
+ [
+ UserPreferences current useXftFontsOnly:(xftFontsOnlyHolder value).
+ UserPreferences current useXFontsOnly:false.
+ allFonts := self graphicsDevice listOfAvailableFonts.
+ ] ensure:[
+ UserPreferences current useXftFontsOnly:sav_useXftFontsOnly.
+ UserPreferences current useXFontsOnly:sav_useXFontsOnly.
+ ].
allFonts isNil ifTrue:[^ nil].
d := Dictionary new.
@@ -1076,7 +1082,8 @@
currentEncoding := selectedFont encoding.
fontsPerFamily isNil ifTrue:[
- self getFamilyList
+ self updateFamilyList
+ "/ self getFamilyList
].
self familySelected:fam showPreview:false.
@@ -1334,12 +1341,24 @@
familySelected:aFamilyName showPreview:showPreview
"a fonts family was selected; find available faces and update lists"
- |faces styles list|
+ |familyNameUsed faces styles list idx|
- familyList setSelectElement:aFamilyName.
-
- currentFamily := aFamilyName.
- faces := self getFacesForFamily:aFamilyName filtering:combinedFilter.
+ familyNameUsed := aFamilyName.
+
+ familyList setSelectElement:familyNameUsed.
+ familyList selection isNil ifTrue:[
+ "/ mhm - maybe lowercase...
+ idx := familyList list indexOf:(familyNameUsed := aFamilyName asUppercaseFirst).
+ idx == 0 ifTrue:[
+ idx := familyList list indexOf:(familyNameUsed := aFamilyName asLowercaseFirst).
+ ].
+ idx ~~ 0 ifTrue:[
+ familyList selection:idx.
+ ].
+ ].
+
+ currentFamily := familyNameUsed.
+ faces := self getFacesForFamily:currentFamily filtering:combinedFilter.
faces isEmptyOrNil ifTrue:[
currentFace := currentStyle := currentFaceAndStyle := nil.
faceList list:nil.
@@ -1349,7 +1368,7 @@
list := SortedCollection new.
faces do:[:aFace |
- styles := (self getStylesInFamily:aFamilyName face:aFace filtering:combinedFilter) ? #().
+ styles := (self getStylesInFamily:currentFamily face:aFace filtering:combinedFilter) ? #().
styles do:[:aStyle |
aFace isEmpty ifTrue:[
list add:(aStyle)