[squeak-dev] TextMorph minimal width

Marcel Taeumel marcel.taeumel at hpi.de
Wed Aug 10 08:32:16 UTC 2022

Hi Stef --

Yes, single-character text morphs have always been an issue.

In 5.3, that text morph was also wider than it needs to be:

The overall support for "minimal extent" in Morphic is still brittle. It can yield unexpected errors in various edge cases, including things related to the scale factor and non-Western fonts.

I agree that the "*2" magic constant is bad. Yet, I am afraid that moving it from #minCompositionWidth to #minWidth makes things worse in terms of readability. Also, #minCompositionWidth and #minWidth should do very similar things, except for the "outer" properties such as margin and border. Moving that constant would break that contract.

I would not make your proposed change in 6.0. Yet, we can try to work with that in 6.1alpha.

Can you please give more context on where this turns out to be a problem?

(Apologies that I do not have the time right now to go into the problem. It is much more complicated than it looks here. There are bugs in CompositionScanner when the rectangle is too narrow.)

Am 08.08.2022 22:41:32 schrieb St├ęphane Rollandin <lecteur at zogotounga.net>:

In 6.0

(TextMorph new contents: 'B';
backgroundColor: Color green)

yields a Morph that is wider than needed by an extra character

changing #minCompositionWidth in TextMorph by removing the * 2 fixes
that problem, but introduces another one (bad layout of modal window
titles) that can itself be fixed by reintroducing the same * 2 in
#minWidth as follow:


| result |
result := self minCompositionWidth * 2 + (self borderWidth*2).
margins ifNil: [^ result].

^ margins isRectangle
ifTrue: [result + margins left + margins right]
ifFalse: [margins isPoint
ifTrue: [result + margins x + margins x]
ifFalse: [result + (2*margins)]]

Is that correct?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220810/2666fed1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 1342 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220810/2666fed1/attachment.png>

More information about the Squeak-dev mailing list