[squeak-dev] The Trunk: Graphics-mt.462.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jan 19 16:52:07 UTC 2022

Marcel Taeumel uploaded a new version of Graphics to project The Trunk:

==================== Summary ====================

Name: Graphics-mt.462
Author: mt
Time: 19 January 2022, 5:52:01.397517 pm
UUID: c5dfdf6e-4452-3e49-90f3-dceec6fb5201
Ancestors: Graphics-mt.461

Fixes two very old bugs in composition of text lines:

1. It is now possible to use fonts in a text that are smaller than the text-morph's current text-style's default font. That line height will be correctly smaller than #defaultLineHeight.

2. The text cursor for a trailing CR in a text field will now use the height of the previous line, which makes it look better if the current font is much smaller/bigger than the text-morph's current text-style's default font.

=============== Diff against Graphics-mt.461 ===============

Item was changed:
  ----- Method: TextComposer>>addNullLineWithIndex:andRectangle: (in category 'private') -----
  addNullLineWithIndex: index andRectangle: r
+ 	"TextEditor has emphasisHere, which encodes the emphasis of future input. We don't have that info here. Therefore we just use the height of the last text line if there is any."
  	lines addLast: (
  				start: index 
  				stop: index - 1
  				internalSpaces: 0 
  				paddingWidth: 0
  			rectangle: r;
+ 			lineHeight: (lines
+ 				ifEmpty: [defaultLineHeight]
+ 				ifNotEmpty: [lines last lineHeight])
+ 			baseline: (lines
+ 				ifEmpty: [theTextStyle baseline]
+ 				ifNotEmpty: [lines last baseline])
- 			lineHeight: defaultLineHeight baseline: theTextStyle baseline

Item was changed:
  ----- Method: TextComposer>>composeAllRectangles: (in category 'private') -----
  composeAllRectangles: rectangles
  	| charIndexBeforeLine numberOfLinesBefore reasonForStopping |
+ 	actualHeight := 0.
- 	actualHeight := defaultLineHeight.
  	charIndexBeforeLine := currCharIndex.
  	numberOfLinesBefore := lines size.
  	reasonForStopping := self composeEachRectangleIn: rectangles.
  	currentY := currentY + actualHeight.
  	currentY > theContainer bottom ifTrue: [
  		"Oops -- the line is really too high to fit -- back out"
  		currCharIndex := charIndexBeforeLine.
  		lines size - numberOfLinesBefore timesRepeat: [lines removeLast].
  	"It's OK -- the line still fits."
  	maxRightX := maxRightX max: scanner rightX.
  	1 to: rectangles size - 1 do: [ :i | |lineIndex|
  		"Adjust heights across rectangles if necessary"
  		lineIndex:=lines size - rectangles size + i.
  		(lines size between: 1 and: lineIndex) ifTrue: 
  			[(lines at: lineIndex)
  				lineHeight: lines last lineHeight
  				baseline: lines last baseline] 
  	isFirstLine := false.
  	reasonForStopping == #columnBreak ifTrue: [^nil].
  	currCharIndex > theText size ifTrue: [
  		^nil		"we are finished composing"

More information about the Squeak-dev mailing list