[squeak-dev] The Inbox: Morphic-ct.1997.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu May 19 13:26:15 UTC 2022
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1997.mcz
==================== Summary ====================
Name: Morphic-ct.1997
Author: ct
Time: 19 May 2022, 3:26:09.13678 pm
UUID: c2225397-5b99-e54c-b73a-d92dc9544ab6
Ancestors: Morphic-ct.1996
Adds "Import file" button to FontImporter to install fonts from custom locations.
Not urgent, we can also integrate this after the release.
=============== Diff against Morphic-ct.1996 ===============
Item was added:
+ ----- Method: FontImporterTool>>buildFontNamePaneWith: (in category 'ui - building') -----
+ buildFontNamePaneWith: builder
+
+ ^ builder pluggablePanelSpec new
+ children: {
+ builder pluggableTextSpec new
+ model: self;
+ getText: #filename;
+ readOnly: true;
+ indicateUnacceptedChanges: false;
+ font: self filenameFont;
+ help: '<- Please select a font family' translated;
+ frame: (LayoutFrame fractions: (0 at 0 corner: 0.8 at 1));
+ yourself.
+
+ builder pluggableButtonSpec new
+ model: self;
+ label: 'Import file...' translated;
+ help: 'Choose a local font file to install it' translated;
+ action: #importFromFile;
+ frame: (LayoutFrame fractions: (0.8 at 0 corner: 1 at 1));
+ yourself.
+ };
+ yourself!
Item was changed:
----- Method: FontImporterTool>>buildFontPanelWith: (in category 'ui - building') -----
buildFontPanelWith: builder
"Build the main panel for the currently selected font (family). Includes a list of associated file names, an interactive preview panel and the copyright."
^ builder pluggablePanelSpec new
children: {
+ (self buildFontNamePaneWith: builder)
- builder pluggableTextSpec new
- model: self;
- getText: #filename;
- readOnly: true;
- indicateUnacceptedChanges: false;
- font: self filenameFont;
- help: '<- Please select a font family';
frame: (LayoutFrame
fractions: (0 at 0 corner: 1 at 0)
offsets: (0 at 0 corner: 0@ self filenameHeight));
yourself.
(self buildPreviewPaneWith: builder)
frame: (LayoutFrame
fractions: (0 at 0 corner: 1 at 1)
offsets: (0@ self filenameHeight corner: 0@ (self copyrightHeight negated)));
yourself.
builder pluggableTextSpec new
model: self;
getText: #copyright;
font: self copyrightFont;
readOnly: true;
indicateUnacceptedChanges: false;
frame: (LayoutFrame
fractions: (0 at 1 corner: 1 at 1)
offsets: (0 @ (self copyrightHeight negated) corner: 0 @ 0));
yourself
};
yourself!
Item was added:
+ ----- Method: FontImporterTool>>importFromFile (in category 'actions') -----
+ importFromFile
+
+ | files names |
+ self flag: #UIManager. "Once UIManager supports it, allow the user to pick multiple files"
+ files := {(Project uiManager chooseFileMatchingSuffixes: #('ttf' 'ttc') label: 'Choose file to import' translated) ifNil: [^ false]}.
+
+ names := TTCFont installFromFileNames: files.
+ names ifEmpty: [^ false].
+
+ self refreshFonts.
+ self selectedFont: nil.
+ self currentSelection: (self allFonts detect: [:font | files includes: font filename] ifNone: [nil]).
+ ^ true!
Item was changed:
----- Method: FontImporterTool>>installFont (in category 'actions') -----
installFont
"Install the selected font. Inform tha user that a modification is best reflected with a custom font name so that it is possible to also install the font with its original parameters."
| handle wasRenamed |
handle := self currentSelection.
wasRenamed := false.
(handle isModified and: [handle hasModifiedName not]) ifTrue: [
(Project uiManager
request: 'You modified the selected font.\Please choose a new name:' translated withCRs
initialAnswer: 'My ', handle familyName)
ifEmpty: [^ false]
ifNotEmpty: [:answer |
wasRenamed := true.
handle fontname: answer]].
self currentSelection installFont.
self selectedFont: nil. "New identity from the handle"
wasRenamed ifTrue: [
+ self refreshFonts. ^ true].
- "New child in the tree. So refresh everything."
- allFonts := nil. self changed: #allFonts. ^ true].
self currentSelection parent ifNotNil: [:p | self currentSelection: p].
self changed: #objectChanged with: self currentSelection.
^ true!
Item was added:
+ ----- Method: FontImporterTool>>refreshFonts (in category 'initialize') -----
+ refreshFonts
+ "New child in the tree. So refresh everything."
+
+ allFonts := nil.
+ self changed: #allFonts.!
More information about the Squeak-dev
mailing list
|