Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.473.mcz
==================== Summary ====================
Name: Graphics-mt.473
Author: mt
Time: 5 February 2022, 4:16:53.295491 pm
UUID: f805f812-8548-5f4f-9f21-74d779cc5426
Ancestors: Graphics-mt.472
Layout text lines using #leadingSlice instead of #leading so that one-liners look centered while multi-line paragraphs are unchanged as a whole. Note that if the very top of a text morphs looks too compact, there is #margins: depending on your use case.
=============== Diff against Graphics-mt.472 ===============
Item was changed:
----- Method: CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide: (in category 'scanning') -----
composeFrom: startIndex inRectangle: lineRectangle
firstLine: firstLine leftSide: leftSide rightSide: rightSide
"Answer an instance of TextLineInterval that represents the next line in the paragraph."
| runLength stopCondition |
"Set up margins"
leftMargin := lineRectangle left.
leftSide ifTrue: [leftMargin := leftMargin +
(firstLine ifTrue: [textStyle firstIndent]
ifFalse: [textStyle restIndent])].
destX := spaceX := leftMargin.
rightMargin := lineRectangle right.
rightSide ifTrue: [rightMargin := rightMargin - textStyle rightIndent].
lastIndex := startIndex. "scanning sets last index"
destY := lineRectangle top.
lineHeight := baseline := 0. "Will be increased by setFont"
line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0)
rectangle: lineRectangle.
self setStopConditions. "also sets font"
runLength := text runLengthFor: startIndex.
runStopIndex := (lastIndex := startIndex) + (runLength - 1).
nextIndexAfterLineBreak := spaceCount := 0.
lastBreakIsNotASpace := false.
self handleIndentation.
leftMargin := destX.
line leftMargin: leftMargin.
[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
in: text string rightX: rightMargin.
"See setStopConditions for stopping conditions for composing."
self perform: stopCondition] whileFalse.
^ line
lineHeight: lineHeight + textStyle leading
+ baseline: baseline + textStyle leadingSlice!
- baseline: baseline + textStyle leading!
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1869.mcz
==================== Summary ====================
Name: Morphic-mt.1869
Author: mt
Time: 5 February 2022, 4:11:07.154491 pm
UUID: 42bc40fc-9eaa-a745-a2f2-0f6fda15d420
Ancestors: Morphic-mt.1868
Prepare Morphic to tweak its widget layout to use a font's #lineGrid and #lineGap.
Note that this is an extra commit for the update map so that images stay functional during updates.
=============== Diff against Morphic-mt.1868 ===============
Item was added:
+ ----- Method: AbstractFont>>lineGapForMorphs (in category '*Morphic-Widgets') -----
+ lineGapForMorphs
+ "Use this hook to control the compactness of Morphic views such as lists, trees, and buttons."
+
+ ^ MorphicProject useCompactLists
+ ifTrue: [0]
+ ifFalse: [self lineGap]!
Item was added:
+ ----- Method: AbstractFont>>lineGapSliceForMorphs (in category '*Morphic-Widgets') -----
+ lineGapSliceForMorphs
+ "Use this hook to control the compactness of Morphic views such as lists, trees, and buttons."
+
+ ^ MorphicProject useCompactLists
+ ifTrue: [0]
+ ifFalse: [self lineGapSlice]!
Item was added:
+ ----- Method: AbstractFont>>lineGridForMorphs (in category '*Morphic-Widgets') -----
+ lineGridForMorphs
+ "Use this hook to control the compactness of Morphic views such as lists, trees, and buttons."
+
+ ^ MorphicProject useCompactLists
+ ifTrue: [self height]
+ ifFalse: [self lineGrid]!
Item was changed:
Project subclass: #MorphicProject
instanceVariableNames: 'uiProcess'
+ classVariableNames: 'DefaultFill UseCompactLists'
- classVariableNames: 'DefaultFill'
poolDictionaries: ''
category: 'Morphic-Support'!
!MorphicProject commentStamp: 'dtl 7/13/2013 15:40' prior: 0!
An MorphicProject is a project with a Morphic user interface. Its world is a PasteUpMorph, and its UI manager is a MorphicUIManager. It uses a MorphicToolBuilder to create the views for various tools. It has a single uiProcess for its world, and Morph updates and user interaction occur in the context of that UI process.
!
Item was added:
+ ----- Method: MorphicProject class>>useCompactLists (in category 'preferences') -----
+ useCompactLists
+ <preference: 'Compact list/tree/menu widgets'
+ categoryList: #('Morphic' 'Tools')
+ description: 'When true, ignore the #lineGrid of the current list font when computing the list layout and other geometry properties. Does not interfere with the layout of text fields.'
+ type: #Boolean>
+
+ ^ UseCompactLists ifNil: [false]!
Item was added:
+ ----- Method: MorphicProject class>>useCompactLists: (in category 'preferences') -----
+ useCompactLists: aBooleanOrNil
+
+ UseCompactLists = aBooleanOrNil ifTrue: [^ self].
+ UseCompactLists := aBooleanOrNil.
+
+ AbstractFont allSubInstancesDo: [:font | font reset "except glyph caches"].
+ UserInterfaceTheme current basicApply.!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1302.mcz
==================== Summary ====================
Name: System-mt.1302
Author: mt
Time: 5 February 2022, 4:08:47.918491 pm
UUID: 947ea0f6-19a2-1147-aefe-55f0b773544b
Ancestors: System-mt.1301
Tweaks Accujen point size. Resets recommended #extraScale for our BitstreamVera fonts, optimized for 75% to 150% scale factor. Update all texts to use the recommended #extraGap in each TrueType font.
Note that you can adjust #extraScale and #extraGap in each TrueType font family via Help > Font Size Summary or About Squeak > Image Fonts. Also see #chooseExtraScale and #chooseExtraGap.
=============== Diff against System-mt.1301 ===============
Item was changed:
+ (PackageInfo named: 'System') postscript: '"Fixes Accujen point sizes."
+ (TextStyle named: #Accujen) ifNotNil: [:style |
+ (style fontArray at: 2) pointSize: 9.5.
+ (style fontArray at: 3) pointSize: 11.0].
- (PackageInfo named: 'System') postscript: '"Add missing sTypo values for our Bitstream Vera fonts."
- TTFontDescription allInstancesDo: [:ea | (ea familyName beginsWith: ''Bitstream Vera'')
- ifTrue: [ea setTypographicAscender: 1556 descender: -492 lineGap: 410 ]].
+ "Reset extraScale for BitstreamVera fonts."
+ TTCFont allSubInstancesDo: [:ea | | tt | ((tt := ea ttcDescription) familyName beginsWith: ''Bitstream Vera'') ifTrue: [tt instVarNamed: #extraScale put: nil]].
+
+ "Update #leading in all text styles using the default font''s #lineGap. Also remove all cached glyphs. Supports #extraGap now."
- "Update #leading in all text styles using the default font''s #lineGap. Also remove all cached glyphs."
AbstractFont allSubInstancesDo: [ :font | font pixelsPerInchChanged ].
TextStyle allInstancesDo: [ :style | style pixelsPerInchChanged ].
+ '!
-
- "Fix default font sizes in existing text styles according to the current UserInterfaceTheme."
- UserInterfaceTheme current installSystemFont: TextStyle defaultFont.'!
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.472.mcz
==================== Summary ====================
Name: Graphics-mt.472
Author: mt
Time: 5 February 2022, 4:00:13.751491 pm
UUID: 18a56b77-995e-1e4a-95c3-9148a92c9246
Ancestors: Graphics-mt.471
Prepare the use of #leadingSlice and #lineGapSlice, which will be used in CharacterScanner to improve layout of one-line texts.
Some tweaks in font-size summary. Let users change a TrueType font's extraScale and extra Gap.
(That fix in DisplayScreen complements System-mt.1301.)
=============== Diff against Graphics-mt.471 ===============
Item was added:
+ ----- Method: AbstractFont>>lineGapSlice (in category 'accessing') -----
+ lineGapSlice
+
+ ^ 1 "pre-rendered legacy fonts"!
Item was changed:
----- Method: DisplayScreen>>uiScaleFactor: (in category 'scale factor') -----
uiScaleFactor: aFloat
"Sets the effective scale factor for the user interface, i.e., all widgets, tools, and windows. The user can override the CurrentScaleFactor recommended by the platform."
| oldFactor newFactor |
+ (UserInterfaceTheme current canFakeScaleFactor: 0.75) ifTrue: [
- (UserInterfaceTheme current canFakeScaleFactor: aFloat) ifTrue: [
self flag: #isTTCBased.
^ UserInterfaceTheme current applyScaled: aFloat].
+
+ aFloat = 0.75 ifTrue: [(Project uiManager confirm: ((('You are currently using <b>TrueType fonts</b>. Your requested scale factor of <b>{1}%</b> looks better using pre-rendered <b>pixel fonts</b>.\\Do you want to switch to pixel fonts now?' translated withCRs format: {(aFloat * 100) rounded}) withNoLineLongerThan: 60) copyReplaceAll: String cr with: '<br>') asTextFromHtml title: 'Blurry Fonts Detected' translated) == true
+ ifTrue: [UserInterfaceTheme cleanUpAndReset. ^ self uiScaleFactor: aFloat]].
oldFactor := RealEstateAgent scaleFactor. "Use effective, pixel-based factor to account for rounding errors. See #isTTCBased and #uiScaleFactor."
newFactor := aFloat max: 0.75.
newFactor = oldFactor ifTrue: [^ self].
TextStyle pixelsPerInch: 96.0 * aFloat.
newFactor := RealEstateAgent resetScaleFactor; scaleFactor. "Again, account for rounding errors."
Project current ifNotNil: [:p | p displayScaleChangedFrom: oldFactor to: newFactor].!
Item was changed:
AbstractFont subclass: #StrikeFont
+ instanceVariableNames: 'characterToGlyphMap xTable glyphs name type minAscii maxAscii maxWidth strikeLength ascent descent xOffset raster subscript superscript emphasis derivativeFonts pointSize fallbackFont charIndexCompatibilitySlot lineGap lineGapSlice'
- instanceVariableNames: 'characterToGlyphMap xTable glyphs name type minAscii maxAscii maxWidth strikeLength ascent descent xOffset raster subscript superscript emphasis derivativeFonts pointSize fallbackFont charIndexCompatibilitySlot lineGap'
classVariableNames: 'DefaultStringScanner'
poolDictionaries: 'TextConstants'
category: 'Graphics-Fonts'!
!StrikeFont commentStamp: 'fbs 11/28/2013 08:50' prior: 0!
I represent a compact encoding of a set of Forms corresponding to characters in the ASCII character set. All the forms are placed side by side in a large form whose height is the font height, and whose width is the sum of all the character widths. The xTable variable gives the left-x coordinates of the subforms corresponding to the glyphs. Characters are mapped to glyphs by using the characterToGyphMap.
Subclasses can have non-trivial mapping rules as well as different representations for glyphs sizes (e.g., not using an xTable). If so, these classes should return nil when queried for xTable and/or the characterToGlyphMap. This will cause the CharacterScanner primitive to fail and query the font for the width of a character (so that a more programatical approach can be implemented).
For display, fonts need to implement two messages:
#installOn: aDisplayContext foregroundColor: foregroundColor backgroundColor: backgroundColor
This method installs the receiver (a font) on the given DisplayContext (which may be an instance of BitBlt or Canvas (or any of its subclasses). The font should take the appropriate action to initialize the display context so that further display operations can be optimized.
#displayString: aString on: aDisplayContext from: startIndex to: stopIndex at: aPoint kern: kernDelta
This method is called for each subsequent run of characters in aString which is to be displayed with the (previously installed) settings.
!
Item was added:
+ ----- Method: StrikeFont>>lineGapSlice (in category 'accessing') -----
+ lineGapSlice
+ "Cached portion of the receiver's #lineGap, which can be used to center one-liners in text fields. Also see TTCFont >> #lineGapSlice."
+
+ ^ lineGapSlice ifNil: [lineGapSlice := (self lineGap asFloat / 2) rounded]!
Item was changed:
----- Method: StrikeFont>>reset (in category 'emphasis') -----
reset
"Reset the cache of derivative emphasized fonts"
+ lineGap := lineGapSlice := nil.
+
fallbackFont class = FixedFaceFont
ifTrue: [fallbackFont := nil].
derivativeFonts notNil ifTrue: [
derivativeFonts withIndexDo: [ :f :i |
(f notNil and: [f isSynthetic]) ifTrue: [derivativeFonts at: i put: nil]]].
"
derivativeFonts := Array new: 32.
#('B' 'I' 'BI') doWithIndex:
[:tag :index |
(style := TextStyle named: self familyName) ifNotNil:
[(font := style fontArray
detect: [:each | each name = (self name , tag)]
ifNone: [nil]) ifNotNil: [derivativeFonts at: index put: font]]]
"!
Item was changed:
Object subclass: #TextStyle
+ instanceVariableNames: 'fontArray fontFamilySize lineGrid baseline alignment firstIndent restIndent rightIndent tabsArray marginTabsArray leading leadingSlice defaultFontIndex'
- instanceVariableNames: 'fontArray fontFamilySize lineGrid baseline alignment firstIndent restIndent rightIndent tabsArray marginTabsArray leading defaultFontIndex'
classVariableNames: ''
poolDictionaries: 'TextConstants'
category: 'Graphics-Text'!
!TextStyle commentStamp: '<historical>' prior: 0!
A textStyle comprises the formatting information for composing and displaying a unit (usually a paragraph) of text. Typically one makes a copy of a master textStyle (such as TextStyle default), and then that copy may get altered in the process of editing. Bad things can happen if you do not copy first.
Each of my instances consists of...
fontArray An array of StrikeFonts
fontFamilySize unused
lineGrid An integer; default line spacing for paragraphs
baseline An integer; default baseline (dist from line top to bottom of an 'a')
alignment An integer; text alignment, see TextStyle alignment:
firstIndent An integer; indent of first line in pixels
restIndent An integer; indent of remaining lines in pixels
rightIndent An integer; indent of right margin rel to section
tabsArray An array of integers giving tab offsets in pixels
marginTabsArray An array of margin tabs
leading An integer giving default vertical line separation
For a concrete example, look at TextStyle default copy inspect!
Item was changed:
----- Method: TextStyle class>>fontSizeSummaryContents (in category 'utilities') -----
fontSizeSummaryContents
^ Text streamContents: [:aStream |
| knownStyles knownTTCStyles knownLegacyStyles defaultStyles printBlock |
knownStyles := self knownTextStylesWithoutDefault sorted.
defaultStyles := self defaultFamilyNames sorted.
aStream nextPutAll: ('This page lists all known text styles and for each style''s font the available point sizes. Most text fields offer the {1} where you can choose a different font or point size. Note that you can use any new point size for TrueType fonts. This is, however, not possible for our pre-rendred legacy fonts. If you need more fonts, use the {2} to import TrueType fonts from your current platform. Click {3} to browse all styles by example.\\'
translated withCRs asText format: {
'FontChooserTool' asText
addAttribute: (PluggableTextAttribute evalBlock: [FontChooserTool open]); yourself.
'FontImporterTool' asText
addAttribute: (PluggableTextAttribute evalBlock: [FontImporterTool open]); yourself.
'here' asText
addAttribute: (PluggableTextAttribute evalBlock: [TextStyle browseAllStyles])}).
defaultStyles do: [:styleName |
| style prefix |
style := self named: styleName.
prefix := (style isNil or: [(self named: style defaultFamilyName) == style]) ifTrue: [''] ifFalse: [' !! '].
aStream
nextPutAll: (((styleName padded: #left to: 24 with: Character space), ': ', prefix) asText addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont); yourself);
nextPutAll: (style ifNil: ['-'] ifNotNil: [(style defaultFamilyName asText addAttribute: (TextFontReference toFont: style defaultFont); addAttribute: (PluggableTextAttribute evalBlock: [style explore]); yourself)]);
cr].
printBlock := [:styleName |
+ | style tt defaultFont preferredPointSize exampleFont |
- | style defaultFont preferredPointSize exampleFont |
style := self named: styleName.
preferredPointSize := TextStyle defaultFont pointSize. "system's current default"
defaultFont := style defaultFont. "style's current default"
exampleFont := defaultFont asPointSize: preferredPointSize.
aStream
nextPutAll: (styleName asText addAttribute: (TextFontReference toFont: exampleFont)).
styleName ~= style defaultFamilyName ifTrue: ["style alias"
aStream nextPutAll: ' (', style defaultFamilyName, ')'].
+ tt := style isTTCStyle ifTrue: [style defaultFont ttcDescription].
-
aStream
nextPutAll: ((Text new,
+ ((style isTTCStyle ifFalse: [''] ifTrue: [' TrueType', (tt isExternal ifFalse: [''] ifTrue: [' (extern)'])])
+ asText addAttribute: (TextColor color: ((self userInterfaceTheme get: #balloonTextColor for: #PluggableTextMorphPlus) ifNil: [Color gray])); yourself),
+ (style isTTCStyle ifFalse: [''] ifTrue: [ | eg |
+ ' ... ' asText,
+ ((' ', (tt extraScale * 100) rounded asString, '%') asText addAttribute: (PluggableTextAttribute evalBlock: [style chooseExtraScale]); yourself),
+ ((' ', ((eg := tt extraGap) >= 0 ifTrue: ['+', eg asString] ifFalse: [eg asString])) asText addAttribute: (PluggableTextAttribute evalBlock: [style chooseExtraGap]); yourself) ]),
+ ' ... ',
- ((style isTTCStyle ifFalse: [''] ifTrue: [ | es tt |
- ' TrueType',
- ((tt := style defaultFont ttcDescription) isExternal ifFalse: [''] ifTrue: [' (extern)']),
- ((es := tt extraScale) > 1.0 ifFalse: [''] ifTrue: [' ', (es * 100) rounded asString, '%'])] ) asText addAttribute: (TextColor color: ((self userInterfaceTheme get: #balloonTextColor for: #PluggableTextMorphPlus) ifNil: [Color gray])); yourself),
- ' ... ',
('explore' translated asText addAttribute: (PluggableTextAttribute evalBlock: [style explore]); yourself),
' ',
('browse' translated asText addAttribute: (PluggableTextAttribute evalBlock: [defaultFont browseAllGlyphs]); yourself),
' ') addAttribute: (TextFontReference toFont: Preferences standardButtonFont); yourself);
cr.
aStream nextPutAll: (((self fontPointSizesFor: styleName) inject: ' ' asText into: [:text :pointSize |
pointSize = defaultFont pointSize
ifFalse: [text, ((pointSize asFloat printShowingDecimalPlaces: 1) padded: #left to: 5 with: Character space)]
ifTrue: [text, (((pointSize asFloat printShowingDecimalPlaces: 1) padded: #left to: 5 with: Character space) asText addAttribute: TextEmphasis bold; yourself)]]) addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont); yourself).
aStream cr; cr].
knownTTCStyles := knownStyles select: [:ea | (self named: ea) isTTCStyle].
knownLegacyStyles := knownStyles reject: [:ea | (self named: ea) isTTCStyle].
aStream cr.
knownTTCStyles do: printBlock.
aStream nextPutAll: ('The following pre-rendered legacy fonts are still available. Note that you can only choose from the point sizes that are listed here. Each point size has a pixel size for 96 PPI. The system scales currently for {1} PPI.' translated format: {TextStyle pixelsPerInch}) ; cr; cr.
knownLegacyStyles do: printBlock.
].!
Item was changed:
----- Method: TextStyle>>defaultFontIndex: (in category 'default font') -----
defaultFontIndex: anIndex
defaultFontIndex := anIndex.
leading := self defaultFont lineGap.
+ leadingSlice := self defaultFont lineGapSlice.
lineGrid := self defaultFont height + leading.
+ baseline := self defaultFont ascent + leadingSlice.!
- baseline := self defaultFont ascent + leading.!
Item was changed:
----- Method: TextStyle>>initialize (in category 'initialize-release') -----
initialize
super initialize.
+ self leading: 2.
+ self leadingSlice: 1.!
- self leading: 2.!
Item was added:
+ ----- Method: TextStyle>>leadingSlice (in category 'accessing') -----
+ leadingSlice
+ "Cached portion of the receiver's #leading, which can be used to vertically center one-liners in text fields."
+
+ ^ leadingSlice!
Item was added:
+ ----- Method: TextStyle>>leadingSlice: (in category 'accessing') -----
+ leadingSlice: yDeltaSlice
+
+ leadingSlice := yDeltaSlice.!
Item was changed:
----- Method: TextStyle>>pixelsPerInchChanged (in category 'notifications') -----
pixelsPerInchChanged
+
+ self reset.!
- "The receiver's #lineGap is cached here."
-
- self defaultFontIndex: self defaultFontIndex.!
Item was added:
+ ----- Method: TextStyle>>reset (in category 'initialize-release') -----
+ reset
+ "Reset values cached from the receiver's default font."
+
+ self defaultFontIndex: self defaultFontIndex.!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1301.mcz
==================== Summary ====================
Name: System-mt.1301
Author: mt
Time: 5 February 2022, 3:54:29.258491 pm
UUID: c97689f7-27f8-614d-92c0-4eea9a79b97a
Ancestors: System-mt.1300
Various fixes around UI-theme switching. Especially when switching to 75% scale factor, ask the user to install pre-rendered (and sharper) fonts again if necessary. Also inform the user when UI themes get converted to TrueType fonts automatically when that user changes the system's default font to a TrueType font. And there was a bug when the user tried to scale to 75/100/125/150 again while using TrueType fonts all over the place already.
=============== Diff against System-mt.1300 ===============
Item was changed:
----- Method: UserInterfaceTheme class>>setFont:to: (in category 'tools - fonts') -----
setFont: symbolicName to: aFont
"Set symbolicName to aFont in all known UI themes. If aFont is a TrueType font, transform all themes into TTC-based ones and re-apply the current theme by name."
+ | fontToUse |
+ fontToUse := aFont.
+ (symbolicName = #standardSystemFont and: [aFont isTTCFont])
+ ifTrue: [(self allThemes anySatisfy: [:uit | uit isTTCBased not]) ifTrue: [
+ self resetAfter: [
- aFont isTTCFont ifTrue: [
- self flag: #discuss. "mt: Should we issue a warning here?"
- (self allThemes anySatisfy: [:uit | uit isTTCBased not])
- ifTrue: [self resetAfter: [
self allThemes copy do: [:uit | uit isGenuine ifFalse: [uit unregister]].
+ self allThemes do: [:uit | uit makeTTCBased]].
+ aFont pointSize ~= TTCFont referencePointSize ifTrue: [
+ "Do not change current #scaleFactor by accident. Use standard point size."
+ fontToUse := aFont asPointSize: TTCFont referencePointSize.
+ self inform: ((('Your system is now using <b>TrueType</b> fonts. The point size you specified was reset to <b>{1}pt</b> to retain the system''s current scale factor of <b>{2}%.</b>\\You can repeat this if you really want to use <b>{3}pt</b>. However, it is advised to change the <b>system''s scale factor</b> if you want to make all fonts look smaller or larger on your current display.\See the menu <b>Extras > Scale Factor</b>.' translated withCRs format: {fontToUse pointSize. (Display relativeUiScaleFactor * 100) rounded. aFont pointSize}) withNoLineLongerThan: 70) copyReplaceAll: String cr with: '<br>') asTextFromHtml]]].
- self allThemes do: [:uit | uit makeTTCBased]] ]].
self allThemes do: [:uit |
+ uit setFont: symbolicName to: fontToUse].!
- uit setFont: symbolicName to: aFont].!
Item was changed:
----- Method: UserInterfaceTheme class>>setSystemFontTo: (in category 'tools - fonts') -----
setSystemFontTo: aFont
"Establish the default text font and style"
aFont isTTCFont not ifTrue: [
Display uiScaleFactor = 1.0
+ ifFalse: [^ self error: 'You may only set a pre-rendered font for 100% scale factor'].
- ifFalse: [^ self error: 'Can only set pre-rendered font for 100% scale factor'].
aFont height = StrikeFont referenceHeight
ifFalse: [^ self error: ('Incompatible pre-rendered font for 100% scale factor. Height must be {1} px' format: {StrikeFont referenceHeight})]].
"Documentation only. Users can increase the default font size to any value. Yet, RealEstateAgent class >> #scaleFactor will change and the system effectively render stuff larger. So, it would be a good idea to keep #pixelSize/#height of system font, list font, and menu font similar.
(aFont isTTCFont and: [aFont pointSize ~= TTCFont referencePointSize])
ifTrue: [self notify: ('The standard system/text font should be {1} pt. If you want to increase the overall font size, please change the screen scale factor instead. You may proceed without harm.' format: {TTCFont referencePointSize})].
"
self setFont: #standardSystemFont to: aFont.!
Item was changed:
----- Method: UserInterfaceTheme>>canFakeScaleFactor: (in category 'private - display scale') -----
canFakeScaleFactor: aFloat
"Answer whether we can fake the given scale factor with pre-rendered fonts."
self isTTCBased ifFalse: [^ true "Need to #makeTTCBased anyway."].
+ self isFullyTTCBased ifTrue: [^ false "Without a fake 100%, we go all-in with TrueType fonts."].
- (self lookupScaleFactor: 1.0) ifNil: [^ false "Without a fake 100%, we go all-in with TrueType fonts."].
aFloat = 0.75 ifTrue: [^ true].
aFloat = 1.0 ifTrue: [^ true].
aFloat = 1.25 ifTrue: [^ true].
aFloat = 1.5 ifTrue: [^ true].
^ false!
Item was changed:
----- Method: UserInterfaceTheme>>doScale075 (in category 'private - display scale') -----
doScale075
"Private. Use #applyScaled:. This is actually about 71% because of which font sizes we have available."
self flag: #hack. "mt: A different scale factor should not result in different point sizes being selected BUT the same point size resulting in a different pixel height."
self setFonts: #(
standardSystemFont 7.5
+ standardFixedFont (Accumon 8.5)
- standardFixedFont 7.5
standardCodeFont 7.5
standardListFont 7.5
standardButtonFont 7.5
standardMenuFont 7.5
standardFlapFont 7.5
windowTitleFont 7.5
balloonHelpFont 7.5
haloLabelFont 7.5
wizardStandardFont 10.5
wizardButtonFont 10.5
wizardHelpFont 7.5
wizardTitleFont 16.5) forceTTC: false.
self apply.
TextStyle pixelsPerInch: 96.0. "Restore Squeak's default PPI for 100%."!
Item was added:
+ ----- Method: UserInterfaceTheme>>isFullyTTCBased (in category 'private - display scale') -----
+ isFullyTTCBased
+ "Answer whether all themes have been converted to TrueType."
+
+ ^ (self lookupScaleFactor: 1.0) isNil!
Item was changed:
----- Method: UserInterfaceTheme>>setFonts:forceTTC: (in category 'private - display scale') -----
setFonts: specs forceTTC: forceTTC
"Change fonts. Do not apply the receiver. Replace StrikeFont with TTCFont if forceTTC or target pointSize not available."
| theme100 |
theme100 := self checkTheme100.
+ specs groupsDo: [:symbolicFontName :newPointSize | | pointSizeToUse familyNameToUse font100 fontScaled |
- specs groupsDo: [:symbolicFontName :newPointSize | | font100 fontScaled |
font100 := theme100 get: symbolicFontName.
+ newPointSize isArray
+ ifFalse: [
+ familyNameToUse := font100 familyName.
+ pointSizeToUse := newPointSize]
+ ifTrue: [ "Switch font family"
+ familyNameToUse := newPointSize first.
+ pointSizeToUse := newPointSize second].
+ fontScaled := (font100 isTTCFont and: [familyNameToUse = font100 familyName "Hacky..."])
+ ifTrue: [TTCFont familyName: familyNameToUse pointSize: pointSizeToUse emphasis: font100 emphasis]
+ ifFalse: [StrikeFont familyName: familyNameToUse pointSize: pointSizeToUse emphasized: font100 emphasis].
+ (fontScaled pointSize ~= pointSizeToUse or: [forceTTC and: [fontScaled isTTCFont not]])
+ ifTrue: [fontScaled := TTCFont familyName: self ttcFallbackName pointSize: pointSizeToUse emphasis: font100 emphasis].
+ self assert: [fontScaled pointSize = pointSizeToUse].
- fontScaled := font100 isTTCFont
- ifTrue: [TTCFont familyName: font100 familyName pointSize: newPointSize emphasis: font100 emphasis]
- ifFalse: [StrikeFont familyName: font100 familyName pointSize: newPointSize emphasized: font100 emphasis].
- (fontScaled pointSize ~= newPointSize or: [forceTTC and: [fontScaled isTTCFont not]])
- ifTrue: [fontScaled := TTCFont familyName: self ttcFallbackName pointSize: newPointSize emphasis: font100 emphasis].
- self assert: [fontScaled pointSize = newPointSize].
self set: symbolicFontName to: fontScaled].!
Item was changed:
----- Method: UserInterfaceTheme>>setScaleFactor: (in category 'private - display scale') -----
setScaleFactor: aFloat
"Private. Use #applyScaled:. In the receiver, change the fonts to have a scale of aFloat. Change all fonts to be TrueType fonts if no pre-rendered fonts exist. Never change the 100% reference theme but make a copy. Apply the receiver to the system."
(self isTTCBased not and: [aFloat = self localScaleFactor])
ifTrue: [self apply. ^ self].
(self isTTCBased not and: [self localScaleFactor = 1.0]) "!!!! Never change the reference theme !!!!"
ifTrue: [^ self lookupSimilar ifNil: [self copyWithScaleFactor: aFloat] ifNotNil: [:other | other setScaleFactorPreApply: aFloat]].
+ self isFullyTTCBased ifFalse: [
+ aFloat = 0.75 ifTrue: [^ self doScale075].
+ aFloat = 1.0 ifTrue: [^ self doScale100].
+ aFloat = 1.25 ifTrue: [^ self doScale125].
+ aFloat = 1.5 ifTrue: [^ self doScale150]].
- aFloat = 0.75 ifTrue: [^ self doScale075].
- aFloat = 1.0 ifTrue: [^ self doScale100].
- aFloat = 1.25 ifTrue: [^ self doScale125].
- aFloat = 1.5 ifTrue: [^ self doScale150].
"And now transition from the pre-rendered world into the TrueType world. Or re-use an existing TrueType-based theme with new values. See #lookupSimilar above."
TextStyle pixelsPerInch: 96.0 * RealEstateAgent scaleFactor "current, based on pixels".
self makeTTCBased.
self applyAfter: [TextStyle pixelsPerInch: 96.0 * aFloat "new, not rounded"].!
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1868.mcz
==================== Summary ====================
Name: Morphic-mt.1868
Author: mt
Time: 5 February 2022, 3:50:39.049491 pm
UUID: 91d21511-de0f-5648-bb2a-1232adb314cb
Ancestors: Morphic-mt.1867
- Fixes "Delete" in FontImporterTool to unregister TTFontDescription as well and free memory
- Fixes blank icons in menus, which must have a sensible height to not mess up layout
- Fixes height of window labels, which included #layoutInset again although the surrounding ProportionalLayout does already account for that
=============== Diff against Morphic-mt.1867 ===============
Item was changed:
----- Method: FontImporterTool>>delete (in category 'actions') -----
delete
| font |
(font := self selectedFont) textStyleOrNil ifNotNil: [:style |
TextConstants removeKey: font familyName].
+ TTCFont registerAll.
+ TTFontDescription removeDescriptionNamed: font familyName.
+ self allFonts: nil. "force redraw"!
- self allFonts: nil. "force redraw"
- TTCFont registerAll.!
Item was changed:
----- Method: MenuIcons class>>blankIconOfWidth: (in category 'accessing - icons') -----
blankIconOfWidth: aNumber
^ Icons
at: ('blankIcon-' , aNumber asString) asSymbol
+ ifAbsentPut: [Form extent: aNumber @ aNumber depth:8]!
- ifAbsentPut: [Form extent: aNumber @ 1 depth:8]!
Item was changed:
----- Method: SystemWindow>>labelHeight (in category 'label') -----
labelHeight
"Answer the height for the window label. The standard behavior is at bottom; a hook is provided so that models can stipulate other heights, in support of various less-window-looking demos."
| aHeight |
(model notNil and: [model respondsTo: #desiredWindowLabelHeightIn:]) ifTrue:
[(aHeight := model desiredWindowLabelHeightIn: self) ifNotNil: [^ aHeight]].
^ label ifNil: [0] ifNotNil:
+ [(label height + self cellInset + self cellGap) max:
- [(label height + self cellInset + self cellGap + self layoutInset) max:
(collapseBox ifNotNil: [collapseBox height] ifNil: [10])]!
Item was changed:
+ (PackageInfo named: 'Morphic') postscript: '"Clear cache of blank icons"
+ MenuIcons cleanUp: true.
+ "Fixes height of all window titles."
+ SystemWindow allSubInstancesDo: [:wnd | wnd replaceBoxes].
+ "Rebuild docking bar menus."
+ TheWorldMainDockingBar updateInstances.'!
- (PackageInfo named: 'Morphic') postscript: 'TheWorldMainDockingBar updateInstances.'!