switch $tcl_platform(platform) "unix" { set font times-roman-10 } "macintosh" { set font {-size 9} } "windows" { set font {-family {MS Sans Serif} -size 7} }I find myself struggling with this frequently. Everytime I need to modify the font from the defaults, I have to play guessing games, trying out various font specifications and seeing what Tk will give me.And then I have to repeat it on the different platforms (UNIX, Win, Mac) and maybe several variations to make sure it's not some non-standard font that might not exist on another computer of the same type. Even then, I've no guarantees that my little world of computers covers the universe to which my software could be run on.With that in mind, I'd like to build some tables of fonts that are "good".I'm thinking of several orthogonal attributes, with things like "size" and "serif-vs-non-serif" and "style (casual, typewriter, formal)".Here's an initial proposal for sizes without regard to those other attributes:
- barely readable / teeny
- uncomfortably small
- distinctively smaller than "comfortable"
- comfortable
- distinctively bigger than "comfortable"
- screamingly larger
- Serif
- Times, Palatino, Bookman, and many many others. Most web-browsers default to using a serif font for displaying web pages. If you can stand the use of variable width text, this is the best choice for large bodies of text.
- Sans-Serif
- Helvetica, Arial, and many others. Tk and many other widget sets usually default to using a sans-serif font (though this is usually configurable). This group of fonts is often used in printed matter for headings and headlines.
- Monospace
- Courier is the most common example of this type of font. These kinds of fonts look like typewriter output, and all the characters are the same width (so a row of 10 'M' characters is the same width as a row of 10 'i' characters). These fonts are nothing like as easy to read as ordinary text, and so should normally be used sparingly in GUIs outside of user-editable fields and text that is explicitly intended to represent typed input or program source.
UNIX
mono serif sans-serif teeny 5x8 times-roman-10 small comfortable {Courier -12} {Times -14} {Helvetica 10} big {avantgarde 10} screaming {Courier 48}For balanced text using the Times/Helvetica/Courier set of fonts, you will need to use Courier set as being about 2 points smaller than the other two. I don't know why this is necessary, but without it the monospaced text looks far too large in comparison. - DKFA lot of this choice on X, however depends on just how an X Server has been set up. A Times 10 may not seem small on a 17" or 19" monitor, where 100dpi fonts preceed 75dpi fonts in the font path. With xfstt, xtt, and other TrueType fontservers growing in use, and native TrueType becoming part of XFree86 X11R6.4, it becomes all the more crucial that fonts be easily user selectable. Bruce Gingery
Windows
mono serif sans-serif teeny small {{MS Sans Serif} 7} comfortable {Courier 12} {Times 12} {{MS Sans Serif} 8} big {Helvetica 10} screaming
Macintosh
mono serif sans-serif teeny {-size 9} small comfortable {Courier 12} {Times 12} big {Helvetica 10} screaming
UNDER NO CIRCUMSTANCES SHOULD YOU USE MORE THAN ONE SERIF FONT, MORE THAN ONE SANS-SERIF FONT, OR MORE THAN ONE MONOSPACE FONT ON A SCREEN AT A TIME. Everyone has seen the "There are 400 different fonts in this DTP package and I am going to use every one of them!!!" type of document from time to time, and they suck so much you can use them to lift heavy steel panels. A few fonts used effectively is always better - the end product looks better and more professional, and it is easier to use too.
Created by (in order of appearance): DL, DKFKBK: [1] adds:The combinations,
Courier 10/12/15/18 Times 10/12/15/18 and Helvetica 10/12/15/18are available and generally attractive on all the platforms, with a single caveat: The scaling must be set correctly for the screen. Some platforms do this gracefully, and some don't. When I do a big app, I generally use the 'tk scaling' command at the start, and have a separate panel where the user can customize the scaling value. If you adjust the scaling, and never use pixel-based font metrics (negative sizes), you'll be a much happier camper. //KevinMGS [2003/04/02] - Don't forget, if you change your tk scaling value interactively, you should make sure to update your named fonts (well, all fonts actually, but using named fonts is much easier) to use the new scaling. See font scaling.
Sometimes, when you're choosing fonts, it's important to know what value to give tk scaling. The tk scaling page gives a little Tk app that helps you with determining this value.
LV: How about some advice on how to select good Unicode related fonts on Unix? In particular good quality Kanji fonts.DKF: Can't help here. I wouldn't know a good Kanji font if it jumped up and bit me (other than by looking at whether it is a stroked or a bitmapped font; the former are usually better, particularly at large sizes; the usual X rasterizer isn't very good at handling small fonts though, which is where bitmapped fonts tend to come into their own).DNK: Two I've seen suggested are both TrueType fonts: Microsoft's "Arial Unicode" and the Bitstream Cyberbit font. [2] describes how to set these up and make them work; following the recommended procedures makes them display beautifully, except that I can't coax any non-Latin-1 characters out of them no matter what I do. Your mileage will hopefully vary.Kroc: free Unicode truetype fonts can be found here : http://corefonts.sourceforge.net
RJH: While I accept and respect the views of the original author, it is fair to point out that font choice is highly subjective on the part of the reader rather than the developer.My own, strong, preference is for monospaced, sans-serif (I tend to use 'Consolas' almost exclusively) and any deviation from that is unwelcome. In particular I find large bodies of proportional, serif-ed text very unpleasant to read.Rather than attempting to chose suitable fonts, it is far more important for developers to either provide means for users to change those fonts (by a configuration mechanism) or ensure that users are aware of the existing configuration options which are available (e.g: xrdb on unix). That way the developer can concentrate on the functionality and leave the user to receive that data in the font most acceptable to them.
See also font and Choose first available font.