TextMorph abandons 'Principle of Least Astonishment'

Ned Konz ned at squeakland.org
Wed Nov 3 01:52:57 UTC 2004


On Tuesday 02 November 2004 12:34 pm, Ken Dickey wrote:

> I don't know if this is considered a bug. but..
>
> (TextMorph new string: 'Text me!' fontName: 'ComicSansMS' size: 26)
> openInWorld.
>
> ..shows the proper font but has font size 11.

Hi Ken,

(I guess you're a neighbor, since I'm in Stanwood...)

Don't confuse 'size' with 'pointSize'. The font operations that have 'size' in 
their names refer to nominal height in pixels. And since a point is not the 
same as a pixel, these differ by a factor of 96/72 (by default).

I picked a nominal factor of 96 dpi because it was close to the actual 
resolution of today's display devices.

Plus,

 fontOfSize: whatever

will find the closest  *pixel* size to whatever.

So if you ask for a 26 pixel tall font (which is what you did), this is going 
to find the closest available font size to 26 pixels/19.5 points.

Which apparently was the 11 point font you found.

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list