[DOC][3.8g][Morphic][m17n] Unicode True Type font example (was Re: internationalisation of squeak: Bitmap font SofijaUC)

Ned Konz ned at squeakland.org
Mon Dec 20 18:06:16 UTC 2004


On Saturday 18 December 2004 12:55 am, Hannes Hirzel wrote:
> a) In TTCFont class pointsizes you write in the commentary that one can
> add additional new sizes by the 'new-size feature'. What do you mean by
> that? I would like to have large font sizes for selected fonts only,
> i.e. I don't want to change the general method #pointSizes.

There is a menu option in some of the menus that are presented for choosing 
font sizes that says "new size". Also, of course, you can do this 
programmatically.

Just sending #pointSize: to a TTCFont will change its size.

> b) In (3) [see attached screenshot] I have to choose as fontSize a
> parameter value of 180 to get a font of size 90 effectively.

#fontOfSize: gets you a font of the given nominal *pixel height*, depending on 
the design *width* of the font in points, related by a DPI value (see below).

You can use #fontOfPointSize: instead if you'd rather use units that 
correspond to the menu choices and other point size metrics on your system.

> This are obviously two different kinds of ways to specifiy the font
> size. How are they called and could this be made a bit more explicit (or
> consistent)?

There is pixel size (what #fontOfSize:, #pixelSize, and #height use) and point 
size (what #pointSize uses). This preceded the concept of pointSize in 
Squeak, so it's got the simple names like #fontOfSize:.

The point size is a design parameter of the font, and comes from the 
definition of the font itself. Plus it has nothing (directly) to do with the 
*height* of the font; it's the nominal size of an "em" space (a horizontal 
metric which is roughly the widest letter width) in the font. (We use this 
nominal value instead of the appropriate vertical metric for calculating the 
pixel *height* for some reason.)

So for instance one could ask for a 100-point font and get something that 
looked 10 points high, if the font designer chose to do this. Fortunately, 
most don't.

The pixel size in Squeak is the nominal size of the font, too; however, it's 
in units of pixels (device dependent) instead of points (device independent, 
1/72 inch (at least for the "computer point")).

The relation between these two values depends on the dot pitch of your 
display. However, since we don't know that I chose 96 dpi as a default. See 
TextStyle class>>pointsToPixels: for the details of the conversion. If you 
have a display that is significantly different from 96 dpi, you may want to 
change the default value:

 TextStyle pixelsPerInch: 120

for a 120 dpi display, for instance.

Then there is the mysterious TTCFont class variable "Scale" that does 
something too.

Strictly speaking, #height should use the vertical font metrics instead of the 
pointSize. But it doesn't.

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



More information about the Squeak-dev mailing list