/
StrikeFont.extension.st
55 lines (51 loc) · 1.58 KB
/
StrikeFont.extension.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Extension { #name : #StrikeFont }
{ #category : #'*Text-Edition' }
StrikeFont class >> fromUser [
"StrikeFont fromUser"
^self fromUser: TextStyle defaultFont
]
{ #category : #'*Text-Edition' }
StrikeFont class >> fromUser: priorFont [
^ UIManager default fontFromUser: priorFont.
]
{ #category : #'*Text-Edition' }
StrikeFont class >> fromUser: priorFont allowKeyboard: aBoolean [
"Present a menu of available fonts, and if one is chosen, return it. Otherwise return nil."
"StrikeFont fromUser"
| fontList fontMenu spec font style |
fontList := StrikeFont actualFamilyNames.
fontMenu := UIManager default newMenuIn: self for: self.
fontList do:
[ :fontName | | label active ptMenu |
style := TextStyle named: fontName.
active := priorFont familyName sameAs: fontName.
ptMenu := UIManager default newMenuIn: self for: self.
style pointSizes do:
[ :pt |
ptMenu
add: (active and: [ pt = priorFont pointSize ]) -> (pt printString , ' pt')
target: fontMenu
selector: #modalSelection:
argument: { fontName . pt } ].
style isTTCStyle ifTrue:
[ ptMenu
add: 'new size'
target: style
selector: #addNewFontSizeDialog:
argument: { fontName. fontMenu } ].
label := active -> fontName.
fontMenu
add: label
subMenu: ptMenu ].
spec := fontMenu
invokeModalAt: self currentWorld activeHand position
in: self currentWorld
allowKeyboard: aBoolean.
spec ifNil: [ ^ nil ].
style := TextStyle named: spec first.
style ifNil: [ ^ self ].
font := style fonts
detect: [ :any | any pointSize = spec last ]
ifNone: [ nil ].
^ font
]