[squeak-dev] The Trunk: Morphic-mt.1833.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Dec 30 12:48:59 UTC 2021
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1833.mcz
==================== Summary ====================
Name: Morphic-mt.1833
Author: mt
Time: 30 December 2021, 1:48:53.712703 pm
UUID: 932445d1-2d4d-034b-8495-9f5753d275b9
Ancestors: Morphic-mt.1832
Some fixes and enhancements around font choosing and importing:
- Font-chooser can now add point-sizes for TrueType fonts.
- Font-chooser only shows pre-rendered StrikeFonts if PPI is still 96.0, i.e., unscaled, looking through the TrueType glasses :-) -- to make point sizes between StrikeFont and TrueType font comparable
- Font-importer now updates TTCFont cache/registry, too, which is used via TTCFont class >> #familyName:pointSize: interface.
- Font-importer now shows the font in the default point size.
Note that I will harmonize point sizes in all StrikeFonts to 96 ppi soon when committing my scale-factor work. Baby steps. :-)
=============== Diff against Morphic-mt.1832 ===============
Item was changed:
----- Method: FontChooserTool>>buildButtonBarWith: (in category 'toolbuilder') -----
buildButtonBarWith: builder
"Build the button bar"
| panelSpec buttonSpec |
panelSpec := builder pluggablePanelSpec new.
panelSpec
layout: #horizontal;
children: OrderedCollection new.
buttonSpec := builder pluggableButtonSpec new.
buttonSpec
model: self;
label: 'Apply' translated;
action: #apply.
panelSpec children addLast: buttonSpec.
+ panelSpec children addLast: (builder pluggableSpacerSpec new extent: ((TextStyle defaultFont widthOf: $m) @1)).
buttonSpec := builder pluggableButtonSpec new.
buttonSpec
model: self;
label: 'OK' translated;
action: #accept.
panelSpec children addLast: buttonSpec.
buttonSpec := builder pluggableButtonSpec new.
buttonSpec
model: self;
label: 'Cancel' translated;
action: #cancel.
panelSpec children addLast: buttonSpec.
^panelSpec!
Item was changed:
----- Method: FontChooserTool>>buildFontListWith: (in category 'toolbuilder') -----
buildFontListWith: builder
"Build the font choosers list of font names"
| listSpec |
listSpec := builder pluggableListSpec new.
listSpec
model: self;
name: #fontList;
+ list: #fontList;
+ icon: #fontListIconAt:;
- list: #fontList;
getIndex: #selectedFontIndex;
setIndex: #selectedFontIndex:.
^listSpec
!
Item was added:
+ ----- Method: FontChooserTool>>buildPointSizeInputWith: (in category 'toolbuilder') -----
+ buildPointSizeInputWith: builder
+ "Build the font choosers list of point sizes"
+ | listSpec |
+ listSpec := builder pluggableInputFieldSpec new.
+ listSpec
+ model: self;
+ plainTextOnly: true;
+ getText: #pointSizeInput;
+ setText: #pointSizeInput:.
+ ^listSpec
+ !
Item was changed:
----- Method: FontChooserTool>>buildPointSizeListWith: (in category 'toolbuilder') -----
buildPointSizeListWith: builder
"Build the font choosers list of point sizes"
| listSpec |
listSpec := builder pluggableListSpec new.
listSpec
model: self;
list: #pointSizeList;
getIndex: #selectedPointSizeIndex;
+ setIndex: #selectedPointSizeIndex:;
+ itemAlignment: #right.
- setIndex: #selectedPointSizeIndex:.
^listSpec
!
Item was changed:
----- Method: FontChooserTool>>buildWith: (in category 'toolbuilder') -----
buildWith: builder
"Create the ui for the browser"
"ToolBuilder open: self"
| windowSpec |
self offerStyleList ifTrue:[
windowSpec := self buildWindowWith: builder specs: {
+ (0 at 0 corner: 0.5 at 0.4) -> [self buildFontListWith: builder].
+ (0.5 at 0 corner: 0.8 at 0.4) -> [self buildStyleListWith: builder].
+ (LayoutFrame fractions: (0.8 at 0 corner: 1.0 at 0.4) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
+ -> [self buildPointSizeListWith: builder].
+ (LayoutFrame fractions: (0.8 at 0.4 corner: 1.0 at 0.4) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
+ -> [self buildPointSizeInputWith: builder].
+ (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
+ -> [self buildPreviewPaneWith: builder].
+ (LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0))
+ -> [self buildButtonBarWith: builder].
- (0 at 0 corner: 0.4 at 0.4) -> [self buildFontListWith: builder].
- (0.4 at 0 corner: 0.8 at 0.4) -> [self buildStyleListWith: builder].
- (0.8 at 0 corner: 1.0 at 0.4) -> [self buildPointSizeListWith: builder].
- (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated)) -> [self buildPreviewPaneWith: builder].
- (LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0)) -> [self buildButtonBarWith: builder].
}.
] ifFalse:[
windowSpec := self buildWindowWith: builder specs: {
(0 at 0 corner: 0.7 at 0.4) -> [self buildFontListWith: builder].
" (0.4 at 0 corner: 0.8 at 0.4) -> [self buildStyleListWith: builder]."
+ (LayoutFrame fractions: (0.7 at 0 corner: 1.0 at 0.4) offsets: (0 at 0 corner: 0 @ self pointSizeInputHeight negated))
+ -> [self buildPointSizeListWith: builder].
+
+ (LayoutFrame fractions: (0.7 at 0.4 corner: 1.0 at 0.4) offsets: (0 at self pointSizeInputHeight negated corner: 0 at 0))
+ -> [self buildPointSizeInputWith: builder].
+ (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated))
+ -> [self buildPreviewPaneWith: builder].
+ (LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0))
+ -> [self buildButtonBarWith: builder].
- (0.7 at 0 corner: 1.0 at 0.4) -> [self buildPointSizeListWith: builder].
- (LayoutFrame fractions: (0.0 at 0.4 corner: 1.0 at 1.0) offsets: (0 at 0 corner: 0 @ self buttonHeight negated)) -> [self buildPreviewPaneWith: builder].
- (LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0@ self buttonHeight negated corner: 0 at 0)) -> [self buildButtonBarWith: builder].
}.
].
windowSpec extent: self initialExtent.
window := builder build: windowSpec.
"Now that the window has been built, notify selection again to scroll it into view."
self changed: #selectedFontIndex.
+ self changed: #selectedFontStyleIndex.
+ self changed: #selectedPointSizeIndex.
+ self changed: #textStyle with: self selectedFontTextStyle.
^window!
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.
+ TextStyle pixelsPerInch = 96.0 ifFalse: [
+ fontList := fontList select: [:styleName | (TextStyle named: styleName) isTTCStyle]].
+ ^ fontList!
- "List of available font family names"
- ^fontList ifNil:[fontList := TextStyle knownTextStyles]!
Item was added:
+ ----- Method: FontChooserTool>>fontListIconAt: (in category 'font list') -----
+ fontListIconAt: index
+
+ ^ ToolIcons iconNamed: ((TextStyle named: (self fontList at: index))
+ ifNil: [#blank16]
+ ifNotNil: [:style | style isTTCStyle ifTrue: [#font] ifFalse: [#blank16]])!
Item was changed:
----- Method: FontChooserTool>>pointSize: (in category 'point size') -----
pointSize: aNumber
+
pointSize := aNumber.
+
+ self changed: #textStyle with: self selectedFontTextStyle.
+ self changed: #contents.
+
+ self changed: #pointSizeList.
+ self changed: #selectedPointSizeIndex.!
- self changed: #pointSize.
- self changed: #contents.!
Item was added:
+ ----- Method: FontChooserTool>>pointSizeInput (in category 'point size') -----
+ pointSizeInput
+
+ ^ self pointSize asString!
Item was added:
+ ----- Method: FontChooserTool>>pointSizeInput: (in category 'point size') -----
+ pointSizeInput: aString
+
+ self pointSize: (aString asNumber roundTo: 0.5).
+ self changed: #pointSizeInput.!
Item was added:
+ ----- Method: FontChooserTool>>pointSizeInputHeight (in category 'toolbuilder') -----
+ pointSizeInputHeight
+ ^ TextStyle defaultFont height * 1.5!
Item was changed:
----- Method: FontChooserTool>>pointSizeList (in category 'point size') -----
pointSizeList
+ ^self selectedTextStyle pointSizes collect: [:each | (each printShowingDecimalPlaces: 1), ' ' ]!
- ^self selectedTextStyle pointSizes collect: [:each | each asString padded: #left to: 3 with: $ ]!
Item was changed:
----- Method: FontChooserTool>>selectedFont (in category 'font list') -----
selectedFont
+ "Generate missing pointSIze only if TrueType font."
+
+ ^ self selectedTextStyle isTTCStyle
+ ifTrue: [TTCFont familyName: self selectedFontFamily pointSize: pointSize emphasized: emphasis]
+ ifFalse: [
+ | font |
+ font := (self selectedTextStyle fontOfPointSize: pointSize) emphasized: emphasis.
+ pointSize := font pointSize. "Can be different."
+ self changed: #selectedPointSizeIndex.
+ font]!
- | font |
- font := self selectedTextStyle fontOfPointSize: pointSize.
- ^font emphasized: emphasis!
Item was changed:
----- Method: FontChooserTool>>selectedFontIndex: (in category 'font list') -----
selectedFontIndex: anIndex
anIndex = 0 ifTrue: [^self].
selectedFontIndex := anIndex.
self changed: #selectedFontIndex.
self changed: #selectedFontStyleIndex.
- self changed: #pointSizeList.
- self changed: #pointSizeIndex.
self changed: #textStyle with: self selectedFontTextStyle.
+ self changed: #contents.
+
+ self changed: #pointSizeList.
+ self changed: #selectedPointSizeIndex.
+ !
- self changed: #contents.!
Item was changed:
----- Method: FontChooserTool>>selectedPointSizeIndex (in category 'point size') -----
selectedPointSizeIndex
+ ^self pointSizeList indexOf: (pointSize printShowingDecimalPlaces: 1), ' '!
- ^self pointSizeList indexOf: (pointSize reduce asString padded: #left to: 3 with: $ )!
Item was changed:
----- Method: FontChooserTool>>selectedPointSizeIndex: (in category 'point size') -----
selectedPointSizeIndex: anIndex
anIndex = 0 ifTrue: [^self].
+ self pointSizeInput: (self pointSizeList at: anIndex).
+ self changed: #selectedPointSizeIndex.!
- pointSize := (self pointSizeList at: anIndex) withBlanksTrimmed asNumber.
- self changed: #selectedPointSizeIndex.
- self changed: #pointSizeList.
-
- self changed: #textStyle with: self selectedFontTextStyle.
- self changed: #contents.!
Item was changed:
----- Method: FontImporterTool>>fontFromFamily: (in category 'helper') -----
fontFromFamily: aFamily
| readFonts |
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 pointSize: 11.0 .
f]].
TTCFontSet newFontArray: ftArray]
ifFalse: [ |f|
f := TTCFont new.
f ttcDescription: readFonts anyOne.
+ f pointSize: TextStyle defaultFont pointSize.
- f pointSize: 11.0 .
f])!
Item was changed:
----- Method: FontImporterTool>>import (in category 'actions') -----
import
| megaSize filenames fonts |
fonts := self currentSelection.
filenames := fonts allFilenames.
megaSize := ((filenames inject: 0 into: [ :sum :fn |
sum + (FileStream readOnlyFileNamed: fn do: [:file | file size])]) / (1024 * 1024)) asFloat.
(UIManager default confirm: (
'About to import {1}{2}.\\This is at least {3} MB of space required in the image.\
Please respect the copyright and embedding restrictions of the font.\
Proceed?'
withCRs format: {
self currentParent
ifNotNil: [:p| p fontname, ' ', self currentSelection fontname]
ifNil: [self currentSelection fontname].
filenames size > 1 ifTrue: [' (', filenames size, ' font files)'] ifFalse: [''].
megaSize printShowingDecimalPlaces: 2}))
ifTrue: [
filenames do: [:filename | | readFonts |
readFonts := TTCFontDescription addFromTTFile: filename.
readFonts isCollection
ifFalse: [TTCFont newTextStyleFromTT: readFonts]
ifTrue: [self importFontFamily: readFonts]]].
self allFonts: nil. "force redraw"
+ TTCFont registerAll.!
- !
Item was changed:
----- Method: FontImporterTool>>link (in category 'actions') -----
link
| filenames fonts |
fonts := self currentSelection.
self warningSeen ifFalse: [
(UIManager default confirm: (
'Note that linking a font instead of importing may make the
image un-portable, since the linked font must be present on
the system the next time the image is run.
This warning is only shown once per session.' ) trueChoice: 'Proceed' falseChoice: 'Cancel')
ifFalse: [^ self].
self warningSeen: true]..
filenames := fonts allFilenames.
filenames do: [:filename | | readFonts |
readFonts := TTFileDescription readFontsFrom: filename.
readFonts isCollection
ifFalse: [TTCFont newTextStyleFromTT: readFonts]
ifTrue: [self importFontFamily: readFonts]].
+ self allFonts: nil. "force redraw"
+ TTCFont registerAll.!
- self allFonts: nil. "force redraw"!
More information about the Squeak-dev
mailing list
|