Marcel Taeumel uploaded a new version of Morphic to project The Trunk: http://source.squeak.org/trunk/Morphic-mt.1904.mcz
==================== Summary ====================
Name: Morphic-mt.1904 Author: mt Time: 21 February 2022, 4:27:51.232875 pm UUID: 46a193b0-46ff-b04b-9114-ed54b892efa8 Ancestors: Morphic-mt.1903
Improves FontChooserTool to support not-yet-installed fonts.
In change-style dialog (in text fields) do not show aliased styles such as our current ComicSansMS. And whenever a TextMorph gets a new text style, it must want to be redrawn, not just releasing its paragraph and hoping for somebody else to tell the environment. :-)
=============== Diff against Morphic-mt.1903 ===============
Item was changed: ----- Method: FontChooserTool>>fontList (in category 'font list') ----- fontList "List of available font family names. Avoid StrikeFonts if PPI is not 96.0." fontList ifNotNil: [^ fontList]. fontList := TextStyle knownTextStylesWithoutDefault. + self getFontFromRequestor ifNotNil: [:font | + (fontList includes: font familyName) ifFalse: [ + fontList := (fontList, {font familyName}) sorted]]. TextStyle pixelsPerInch = 96.0 ifFalse: [ fontList := fontList select: [:styleName | (TextStyle named: styleName) isTTCStyle]]. ^ fontList!
Item was changed: ----- Method: FontChooserTool>>fontListIconAt: (in category 'font list') ----- fontListIconAt: index
+ ^ ToolIcons iconNamed: ( ((TextStyle named: (self fontList at: index)) + ifNil: [self getFontFromRequestor ifNotNil: [:font | TextStyle fontArray: {font} "Not yet installed" ]]) + ifNil: [#blank16] + ifNotNil: [:style | style isTTCStyle ifTrue: [#font] ifFalse: [#blank16]] )! - ^ ToolIcons iconNamed: ((TextStyle named: (self fontList at: index)) - ifNil: [#blank16] - ifNotNil: [:style | style isTTCStyle ifTrue: [#font] ifFalse: [#blank16]])!
Item was added: + ----- Method: FontChooserTool>>getFontFromRequestor (in category 'updating') ----- + getFontFromRequestor + + ^ (getSelector isSymbol and:[target notNil]) + ifTrue:[target perform: getSelector] + ifFalse:[getSelector]!
Item was changed: ----- Method: FontChooserTool>>getSelector: (in category 'accessing') ----- getSelector: aSelectorSymbolOrFont "Set the value of getSelector"
+ getSelector := aSelectorSymbolOrFont. + self updateFromRequestor.! - getSelector := aSelectorSymbolOrFont!
Item was changed: ----- Method: FontChooserTool>>pointSize: (in category 'point size') ----- pointSize: aNumber
pointSize := aNumber.
self changed: #selectedFontTextStyle. self changed: #contents. self changed: #pointSizeList. + self changed: #selectedPointSizeIndex. + self changed: #pointSizeInput.! - self changed: #selectedPointSizeIndex.!
Item was changed: ----- Method: FontChooserTool>>selectedFont (in category 'font list') ----- selectedFont "Generate missing pointSIze only if TrueType font."
+ | style | + ^ (style := self selectedTextStyle) isTTCStyle + ifTrue: [ style fontArray size = 1 "Font not yet installed..." + ifTrue: [style defaultFont] + ifFalse: [TTCFont familyName: self selectedFontFamily pointSize: pointSize emphasized: emphasis]] - ^ self selectedTextStyle isTTCStyle - ifTrue: [TTCFont familyName: self selectedFontFamily pointSize: pointSize emphasized: emphasis] ifFalse: [ | font | + font := (style fontOfPointSize: pointSize) emphasized: emphasis. + pointSize := font pointSize. "Can be different for StrikeFont." - font := (self selectedTextStyle fontOfPointSize: pointSize) emphasized: emphasis. - pointSize := font pointSize. "Can be different." self changed: #selectedPointSizeIndex. font]!
Item was changed: ----- Method: FontChooserTool>>selectedFontIndex (in category 'font list') ----- selectedFontIndex + + ^ selectedFontIndex ifNil: [0]! - | font textStyleName family | - selectedFontIndex ifNotNil: [^selectedFontIndex]. - selectedFontIndex := 0. - font := (getSelector isSymbol and:[target notNil]) - ifTrue:[target perform: getSelector] - ifFalse:[getSelector]. - font ifNotNil:[ - emphasis := font emphasis. - pointSize := font pointSize. - textStyleName := font textStyleName. - family := self fontList detect:[:f | f = textStyleName] ifNone:[]. - ]. - selectedFontIndex := self fontList indexOf: family. - self selectedFontIndex: selectedFontIndex. - ^selectedFontIndex!
Item was changed: ----- Method: FontChooserTool>>selectedPointSizeIndex (in category 'point size') ----- selectedPointSizeIndex + + ^ pointSize + ifNil: [0] + ifNotNil: [self pointSizeList indexOf: (pointSize printShowingDecimalPlaces: 1)]! - ^self pointSizeList indexOf: (pointSize printShowingDecimalPlaces: 1), ' '!
Item was changed: ----- Method: FontChooserTool>>selectedTextStyle (in category 'font list') ----- selectedTextStyle
+ ^ (TextStyle named: self selectedFontFamily) + ifNil: [ self getFontFromRequestor + ifNil: [ TextStyle default ] + ifNotNil: [:font | TextStyle fontArray: {font} "Not yet installed" ]].! - ^TextStyle named: (self selectedFontFamily ifNil:[^TextStyle default]).!
Item was added: + ----- Method: FontChooserTool>>updateFromRequestor (in category 'updating') ----- + updateFromRequestor + + + self getFontFromRequestor ifNotNil: [ :font | + | textStyleName | + textStyleName := font textStyleName. + self fontList + detect: [:f | f = textStyleName] + ifFound: [:family | self selectedFontIndex: (self fontList indexOf: family)]. + self selectedFontStyleIndex: font emphasis + 1. + self pointSize: font pointSize].!
Item was changed: ----- Method: TextEditor>>changeStyle (in category 'attributes') ----- changeStyle "Let user change styles for the current text pane."
| known knownTTCStyles knownLegacyStyles defaultStyles newStyle current currentName menuList | current := morph textStyle. currentName := current defaultFamilyName. + knownTTCStyles := ((TextStyle actualTextStyles + select: [:ea | ea isTTCStyle + "No aliased text styles here..." + and: [(TextStyle named: ea defaultFamilyName) == ea]]) - knownTTCStyles := ((TextStyle actualTextStyles select: [:ea | ea isTTCStyle]) sorted: [:a :b | a defaultFamilyName <= b defaultFamilyName]) collect: [:ea | ea defaultFamilyName -> ea] as: OrderedDictionary. knownLegacyStyles := ((TextStyle actualTextStyles reject: [:ea | ea isTTCStyle]) sorted: [:a :b | a defaultFamilyName <= b defaultFamilyName]) collect: [:ea | ea defaultFamilyName -> ea] as: OrderedDictionary. defaultStyles := ((TextStyle defaultFamilyNames collect: [:ea | ea -> (TextStyle named: ea)] as: OrderedDictionary) reject: [:ea | ea isNil "undefined default styles"]) sorted: [:a :b | a key <= b key]. known := defaultStyles, {'---' -> nil}, knownTTCStyles, {'--- ' -> nil}, knownLegacyStyles. menuList := Array streamContents: [:s | known keysAndValuesDo: [ :knownName :knownStyle | s nextPut: (((knownStyle notNil and: [knownStyle defaultFamilyName = currentName]) ifTrue: [ (' > ', knownName, ' (current)' translated) asText ] ifFalse: [ knownName asText ]) addAttribute: (TextFontReference toFont: (knownStyle ifNil: [TextStyle default])defaultFont); yourself)]]. known := known values. newStyle := Project uiManager chooseFrom: menuList values: known. newStyle ifNotNil: [morph textStyle: newStyle copy]. ^ true!
Item was changed: ----- Method: TextMorph>>textStyle: (in category 'accessing') ----- textStyle: aTextStyle "Change the receiver's set of fonts to aTextStyle. You can access those fonts via the TextFontChange text attribute. If you want to enfore a specific font face or point size, use #font: instead. NOTE THAT you must provide either a freshly created instance of TextStyle or a copy of an existing one. NEVER use, for example, TextStyle class >> #default directly. Also see senders and implementors of #asNewTextStyle."
textStyle := aTextStyle. + self releaseParagraph; changed.! - self releaseParagraph.!
packages@lists.squeakfoundation.org