[squeak-dev] The Trunk: Morphic-mt.1865.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Feb 3 15:29:48 UTC 2022
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1865.mcz
==================== Summary ====================
Name: Morphic-mt.1865
Author: mt
Time: 3 February 2022, 4:29:43.140027 pm
UUID: 36bb0484-8771-7347-8df0-76a80dcf9a71
Ancestors: Morphic-mt.1864
Extends FontImporterTool to be able to browse a font before installing it and be able to delete a font that is already installed.
Fixes some issues in FontImporterTool and TextEditor.
Builds upon Graphics-mt.471, TrueType-mt.60, and System-mt.1300
=============== Diff against Morphic-mt.1864 ===============
Item was added:
+ ----- Method: FontImporterTool>>browseImported (in category 'actions') -----
+ browseImported
+
+ | filenames fonts ttcFonts |
+ fonts := self currentSelection.
+ filenames := fonts allFilenames.
+
+ ttcFonts := filenames gather: [:ea |
+ (TTCFontReader readTTFFrom: (FileStream readOnlyFileNamed: ea))
+ collect: [:descr | TTCFont new ttcDescription: descr; pointSize: TextStyle defaultFont pointSize; yourself]].
+
+ ttcFonts do: [:ea | ea browseAllGlyphs].!
Item was added:
+ ----- Method: FontImporterTool>>browseLinked (in category 'actions') -----
+ browseLinked
+
+ | filenames fonts ttcFonts |
+ fonts := self currentSelection.
+ filenames := fonts allFilenames.
+
+ ttcFonts := filenames gather: [:ea |
+ (TTFileDescription readFontsFrom: ea)
+ collect: [:descr | TTCFont new ttcDescription: descr; pointSize: TextStyle defaultFont pointSize; yourself]].
+
+ ttcFonts do: [:ea | ea browseAllGlyphs].!
Item was added:
+ ----- Method: FontImporterTool>>delete (in category 'actions') -----
+ delete
+
+ | font |
+ (font := self selectedFont) textStyleOrNil ifNotNil: [:style |
+ TextConstants removeKey: font familyName].
+ self allFonts: nil. "force redraw"
+ TTCFont registerAll.!
Item was changed:
----- Method: FontImporterTool>>font:hasGlyphOf: (in category 'helper') -----
font: f hasGlyphOf: aCharacter
| font |
font := f isFontSet ifTrue: [f fontArray first] ifFalse: [f].
+ ^ font hasGlyphOf: aCharacter!
- ^ 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>>fontFromFamily: (in category 'helper') -----
fontFromFamily: aFamily
| readFonts |
+ aFamily ifNil: [^ TextStyle defaultFont].
- aFamily ifNil: [^ TextStyle default fonts first].
readFonts := TTFileDescription readFontsFrom: aFamily allFilenames anyOne.
^ (readFonts size > 1
ifTrue: [
| ftArray |
" see TTCFontSet>>newTextStyleFromTT: "
ftArray := readFonts collect: [:ttc | |f|
ttc ifNil: [nil] ifNotNil: [
f := TTCFont new.
f ttcDescription: ttc.
f pointSize: TextStyle defaultFont pointSize.
f]].
TTCFontSet newFontArray: ftArray]
ifFalse: [ |f|
f := TTCFont new.
f ttcDescription: readFonts anyOne.
f pointSize: TextStyle defaultFont pointSize.
f])!
Item was changed:
----- Method: FontImporterTool>>fontListMenu: (in category 'font list') -----
fontListMenu: aMenu
^ aMenu addTranslatedList: #(
+ ('Browse Font (imported)' browseImported 'Import and browse all available glyphs')
+ ('Browse Font (linked)' browseLinked 'Browse all available glyphs')
+ -
+ ('Install Font (imported)' import 'Include the font data in the image and provide a TextStyle for the font')
+ ('Install Font (linked)' link 'Install the font as a link to its file and provide a TextStyle for the referenced font')
+ ), (self selectedFont textStyleOrNil ifNil: [#()] ifNotNil: [#(
+ -
+ ('Delete Font' delete 'Remove imported font data or link to font from the system')
+ )])
- ('Import Font' import 'Include the font data in the image and provide a TextStyle for the font')
- ('Link Font' link 'Install the font as a link to its file and provide a TextStyle for the referenced font'))
yourself!
Item was changed:
----- Method: FontImporterTool>>textForFamily:subfamily: (in category 'helper') -----
textForFamily: familyName subfamily: subfamilyName
subfamilyName ifNil: [
+ ^ (TextStyle named: (familyName copyWithout: Character space))
- ^ (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 changed:
----- Method: TextEditor>>changeSelectionFontTo: (in category 'attributes') -----
changeSelectionFontTo: aFont
| attr |
aFont ifNil: [ ^ self ].
attr := TextFontReference toFont: aFont.
self openTypeIn.
paragraph text
addAttribute: attr
+ from: (self hasSelection
+ ifTrue: [ self startIndex ]
+ ifFalse: [ 1 ])
- from: self startIndex
to:
(self hasSelection
ifTrue: [ self stopIndex - 1 min: paragraph text size ]
ifFalse: [ paragraph text size ]).
self closeTypeIn.
paragraph composeAll.
self recomputeSelection.
morph changed!
More information about the Squeak-dev
mailing list
|