Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.951.mcz ==================== Summary ==================== Name: Morphic-mt.951 Author: mt Time: 30 April 2015, 11:22:31.617 am UUID: cd0add46-eb53-a74e-87aa-c6824f6f2512 Ancestors: Morphic-mt.950 Some layout issues fixed in Font importer tool. Code clean-up, too. =============== Diff against Morphic-mt.950 =============== Item was changed: + Model subclass: #FontImporterTool + instanceVariableNames: 'title allFonts emphasis currentSelection currentParent warningSeen' - StringHolder subclass: #FontImporterTool - instanceVariableNames: 'title allFonts emphasis window currentSelection currentParent warningSeen' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Support'! !FontImporterTool commentStamp: 'topa 3/9/2015 18:56' prior: 0! A tool to import platform (native) fonts into the image! Item was removed: - ----- Method: FontImporterTool class>>default (in category 'accessing') ----- - default - "Answer the default font imporer tool, ie me - (polymorphic with font chooser) - " - ^ self! Item was removed: - ----- Method: FontImporterTool class>>openWithWindowTitle:for:setSelector:getSelector: (in category 'opening') ----- - openWithWindowTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector - " - FontChooserTool - openWithWindowTitle: 'Choose the Menu Font' - for: Preferences - setSelector: #setMenuFontTo: - getSelector: #standardMenuFont. - " - ^(self withTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector) open! Item was removed: - ----- Method: FontImporterTool class>>windowTitle:for:setSelector:getSelector: (in category 'opening') ----- - windowTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector - | instance | - - instance := self new. - instance - title: titleString; - target: anObject; - setSelector: setSelector; - getSelector: getSelector. - ^instance open! Item was removed: - ----- Method: FontImporterTool class>>withTitle:for:setSelector:getSelector: (in category 'opening') ----- - withTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector - " - (FontChooserTool - withTitle: 'Choose the Menu Font' - for: Preferences - setSelector: #setMenuFontTo: - getSelector: #standardMenuFont) open. - " - | instance | - instance := self new. - instance - title: titleString; - target: anObject; - setSelector: setSelector; - getSelector: getSelector. - ^instance! Item was changed: ----- Method: FontImporterTool>>buildButtonBarWith: (in category 'toolbuilder') ----- buildButtonBarWith: builder "Build the button bar" | panelSpec buttonSpec | panelSpec := builder pluggablePanelSpec new. + panelSpec + layout: #horizontal; + children: OrderedCollection new. - panelSpec children: OrderedCollection new. buttonSpec := builder pluggableButtonSpec new model: self; + label: 'Import' translated; - label: ' Import ' translated; help: 'Include the font data in the image and provide a TextStyle for the font'; action: #import; - frame: (0@0 corner: 0.5@1); yourself. panelSpec children addLast: buttonSpec. buttonSpec := builder pluggableButtonSpec new model: self; + label: 'Close' translated; - label: ' Close ' translated; action: #close; - frame: (0.5@0 corner: 1@1); yourself. panelSpec children addLast: buttonSpec. ^panelSpec! Item was changed: ----- Method: FontImporterTool>>buildPreviewPaneWith: (in category 'toolbuilder') ----- buildPreviewPaneWith: builder "Build the preview panel" ^ builder pluggablePanelSpec new + wantsResizeHandles: true; children: { builder pluggableInputFieldSpec new model: self; getText: #filename; readOnly: true; indicateUnacceptedChanges: false; font: self filenameFont; frame: (LayoutFrame fractions: (0@0 corner: 1@0) offsets: (0@0 corner: 0@ self filenameHeight)); yourself. + builder pluggableTextSpec new + model: self; + getText: #previewText; - (self buildCodePaneWith: builder) - name: #preview; askBeforeDiscardingEdits: false; indicateUnacceptedChanges: false; + softLineWrap: false; frame: (LayoutFrame fractions: (0@0 corner: 1@0.75) offsets: (0@ self filenameHeight corner: 0@0)); yourself. builder pluggableTextSpec new model: self; getText: #copyright; readOnly: true; indicateUnacceptedChanges: false; frame: (LayoutFrame fractions: (0@0.75 corner: 1@1)); yourself }; yourself! Item was added: + ----- Method: FontImporterTool>>buildWindowWith:specs: (in category 'toolbuilder') ----- + buildWindowWith: builder specs: specs + | windowSpec | + windowSpec := builder pluggableWindowSpec new. + windowSpec + model: self; + label:'Choose a Font to import' translated; + extent: self initialExtent; + children: OrderedCollection new. + + specs do:[:assoc| + | rect action widgetSpec | + rect := assoc key. + action := assoc value. + widgetSpec := action value. + widgetSpec ifNotNil:[ + widgetSpec frame: rect. + windowSpec children add: widgetSpec]]. + ^windowSpec! Item was changed: ----- Method: FontImporterTool>>buildWith: (in category 'toolbuilder') ----- buildWith: builder "Create the ui for the browser" "ToolBuilder open: self" + | windowSpec | windowSpec := self buildWindowWith: builder specs: { (self fontListFrame) -> [self buildFontListWith: builder]. (self previewFrame) -> [self buildPreviewPaneWith: builder]. (self buttonsFrame) -> [self buildButtonBarWith: builder]. }. + ^ builder build: windowSpec! - windowSpec extent: self initialExtent. - window := builder build: windowSpec. - "Yes, that's a hack. But it looks ugly with line breaks." - (builder widgetAt: #preview) textMorph wrapFlag: false. - ^window! Item was changed: + ----- Method: FontImporterTool>>buttonHeight (in category 'layout') ----- - ----- Method: FontImporterTool>>buttonHeight (in category 'toolbuilder') ----- buttonHeight ^ Preferences standardButtonFont height * 3! Item was changed: + ----- Method: FontImporterTool>>buttonsFrame (in category 'layout') ----- - ----- Method: FontImporterTool>>buttonsFrame (in category 'toolbuilder') ----- buttonsFrame ^ LayoutFrame fractions: (0@1 corner: 1@1) offsets: (0@ self buttonHeight negated corner: 0@0) ! Item was changed: ----- Method: FontImporterTool>>close (in category 'actions') ----- close + self changed: #close.! - ToolBuilder default close: window.! Item was removed: - ----- Method: FontImporterTool>>contents (in category 'toolbuilder') ----- - contents - | sample i c f | - sample := WriteStream on: ''. - f := self selectedFont ifNil:[^Text new]. - (f isSymbolFont or: [(self font: f hasGlyphOf: $a) not]) ifFalse:[ - sample - nextPutAll: 'the quick brown fox jumps over the lazy dog' ;cr; - nextPutAll: 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.' ;cr;cr; - nextPutAll: '0123456789'; cr; cr; - nextPutAll: - 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, - sed do eiusmod tempor incididunt ut labore et dolore - magna aliqua. Ut enim ad minim veniam, quis nostrud - exercitation ullamco laboris nisi ut aliquip ex ea commodo - consequat. Duis aute irure dolor in reprehenderit in voluptate - velit esse cillum dolore eu fugiat nulla pariatur. Excepteur - sint occaecat cupidatat non proident, sunt in culpa qui - officia deserunt mollit anim id est laborum.' - ] ifTrue:[ - i := 0. - 33 to: 255 do:[:ci | - sample nextPut: (c:=Character value: ci). - i := i + 1. - (('@Z`z' includes:c) or:[i = 30]) - ifTrue:[i :=0. sample cr]]. - ]. - sample := sample contents asText. - sample addAttribute: (TextFontReference toFont: f). - ^sample! Item was changed: + ----- Method: FontImporterTool>>copyright (in category 'model access') ----- - ----- Method: FontImporterTool>>copyright (in category 'toolbuilder') ----- copyright | f | f := self selectedFont ifNil:[^ '']. ^ f isTTCFont ifTrue: [f ttcDescription copyright ifNil: ['']] ifFalse: ['']! Item was changed: + ----- Method: FontImporterTool>>filename (in category 'model access') ----- - ----- Method: FontImporterTool>>filename (in category 'toolbuilder') ----- filename ^ self currentSelection ifNil: [''] ifNotNil: [:sel | String streamContents: [:stream | sel allFilenames do: [:filename | stream nextPutAll: filename] separatedBy: [stream nextPut: $,;nextPut: $ ]]]! Item was changed: + ----- Method: FontImporterTool>>filenameHeight (in category 'layout') ----- - ----- Method: FontImporterTool>>filenameHeight (in category 'toolbuilder') ----- filenameHeight + ^ self filenameFont height * 2! - ^ (self filenameFont lineGrid * 1.5) truncated! Item was changed: + ----- Method: FontImporterTool>>font:hasGlyphOf: (in category 'helper') ----- - ----- Method: FontImporterTool>>font:hasGlyphOf: (in category 'toolbuilder') ----- font: f hasGlyphOf: aCharacter | font | font := f isFontSet ifTrue: [f fontArray first] ifFalse: [f]. ^ font isTTCFont ifFalse: [font hasGlyphOf: aCharacter] ifTrue: [ " [(f hasGlyphOf: aCharacter) not] does not work, the fallback glyph is always found instead. So we fake. if aCharacter is the same form as Character null aka 0, we assume absence." (font characterFormAt: aCharacter) bits ~= font fallbackForm bits] ! Item was changed: + ----- Method: FontImporterTool>>fontListFrame (in category 'layout') ----- - ----- Method: FontImporterTool>>fontListFrame (in category 'toolbuilder') ----- fontListFrame ^ LayoutFrame fractions: (0@0 corner: 0.4@1) + offsets: (0@0 corner: 0@ self buttonHeight negated)! - offsets: (0@0 corner: 0@ self buttonHeight negated + 4)! Item was changed: ----- Method: FontImporterTool>>initialize (in category 'initialize') ----- initialize + super initialize. - title := 'Choose a Font to import'. emphasis := 0. ! Item was changed: + ----- Method: FontImporterTool>>labelOf: (in category 'model access') ----- - ----- Method: FontImporterTool>>labelOf: (in category 'accessing') ----- labelOf: aFontDescription ^ aFontDescription fontname ! Item was changed: + ----- Method: FontImporterTool>>open (in category 'initialize') ----- - ----- Method: FontImporterTool>>open (in category 'toolbuilder') ----- open ^ToolBuilder open: self! Item was changed: + ----- Method: FontImporterTool>>previewFrame (in category 'layout') ----- - ----- Method: FontImporterTool>>previewFrame (in category 'toolbuilder') ----- previewFrame ^ LayoutFrame fractions: (0.4@0 corner: 1@1) + offsets: (0@0 corner: 0@ self buttonHeight negated)! - offsets: (0@0 corner: 0@ self buttonHeight negated + 4)! Item was added: + ----- Method: FontImporterTool>>previewText (in category 'model access') ----- + previewText + | sample i c f | + sample := WriteStream on: ''. + f := self selectedFont ifNil:[^Text new]. + (f isSymbolFont or: [(self font: f hasGlyphOf: $a) not]) ifFalse:[ + sample + nextPutAll: 'the quick brown fox jumps over the lazy dog' ;cr; + nextPutAll: 'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.' ;cr;cr; + nextPutAll: '0123456789'; cr; cr; + nextPutAll: + 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, + sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Ut enim ad minim veniam, quis nostrud + exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate + velit esse cillum dolore eu fugiat nulla pariatur. Excepteur + sint occaecat cupidatat non proident, sunt in culpa qui + officia deserunt mollit anim id est laborum.' + ] ifTrue:[ + i := 0. + 33 to: 255 do:[:ci | + sample nextPut: (c:=Character value: ci). + i := i + 1. + (('@Z`z' includes:c) or:[i = 30]) + ifTrue:[i :=0. sample cr]]. + ]. + sample := sample contents asText. + sample addAttribute: (TextFontReference toFont: f). + ^sample! Item was changed: + ----- Method: FontImporterTool>>textForFamily:subfamily: (in category 'helper') ----- - ----- Method: FontImporterTool>>textForFamily:subfamily: (in category 'accessing') ----- textForFamily: familyName subfamily: subfamilyName subfamilyName ifNil: [ ^ (TextStyle named: familyName) ifNil: [familyName] ifNotNil: [:style | style isTTCStyle ifTrue: ["we are already present " Text string: familyName attribute: TextEmphasis underlined] ifFalse: [familyName]]]. " frome here on it is only about subfamilies" (self isStyleNameSupported: subfamilyName) ifFalse: [^ Text string: subfamilyName attribute: TextColor gray]. ^ (TextStyle named: familyName) ifNil: ["importable" subfamilyName] ifNotNil: [:style | (style isTTCStyle and: [ | regular emph | regular := style fonts anyOne. emph := TTCFont indexOfSubfamilyName: subfamilyName. " detect if this style is already imported " regular emphasis = emph or: [(regular emphasis: emph) ~= regular]]) ifFalse: ["again importable" subfamilyName] ifTrue: [Text string: subfamilyName attribute: TextEmphasis underlined]]! Item was removed: - ----- Method: FontImporterTool>>title (in category 'accessing') ----- - title - - ^ title! Item was removed: - ----- Method: FontImporterTool>>title: (in category 'accessing') ----- - title: anObject - "Set the value of title" - - title := anObject! Item was removed: - ----- Method: FontImporterTool>>window (in category 'accessing') ----- - window - ^window! Item was removed: - ----- Method: FontImporterTool>>window: (in category 'accessing') ----- - window: anObject - - window := anObject! Item was removed: - ----- Method: FontImporterTool>>windowTitle (in category 'initialize') ----- - windowTitle - ^ title translated! |
Free forum by Nabble | Edit this page |