s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
7. Fonts and ColorsThere are a lot of tricks to the fonts and colors used in X. They are not quite as simple as in some other systems, for instance, the font is not just a one-word name. You specify these resources quite explicitly, and it seems rather complex at first, but with a little explanation you'll be a whiz in no time.
7.1 Fonts DemystifiedThe X Logical Font Description (``XLFD'') is the full name for a font. It consists of the following fields:
In light of this chaos, the program xfontsel (the default X
Window font selection program) will come in enormously useful to you.
Try
launching it right now. You will see a strange nothing helpful in the
main window, but try holding the left button down on the When you go to select from the When you are happy with your font selection, you can hit the select
button, and your selection will be placed in the X clipboard, ready to
be
pasted into your document or whatever you are working on. For instance,
go to your xterm window and type in something like The utility xfd is very helpful for examining a font. If you
launch it with a command line such as
7.2 Font Aliases and ConfigurationSometimes it gets tiresome to remember all of the long font names, and very impractical too. Luckily, it is not necessary to type in a hundred keystrokes or so just to get the font name you want, for X provides something called font aliases. If you look in the directory
/usr/X11R6/lib/fonts/misc/fonts.alias,
you will find shortcut names for many of the fonts. For example,
If you add fonts or aliases to your system, you will have to issue a few commands (probably as root). If you add fonts, you will have to issue the following two commands (these are examples, you will have to put in the correct directory, or perhaps leave it off altogether, to have your fonts re-read correctly.
If you change the alias file for a font, you may only have to issue the last command above, but it may be a good idea to issue them both, to be sure. With the xset command you can explicitly issue a font path you wish the server to use, you can delete a specific directory from your font path, see the man page for more information. Another common problem is that some distributions (notably Red Hat 5.2, at the moment) come with the fonts configured in the wrong order. If you take a look at your /etc/XF86Config (it may be somewhere else in some distributions, unfortunately, and I'm not sure where it is in Red Hat at the moment, so maybe locate it...) Take a look at this file if your fonts are ugly in X (as in, very difficult to read even at large sizes). You will see a bunch of entries that look something like this:
The important thing to note here is that we have the unscaled
bitmapped fonts (the directories misc, 75dpi, 100dpi) before the
scaled fonts (such as Type1 and Speedo). Bitmapped fonts are
preferred for the X Server, because scaled fonts don't look very
pretty for common use, they're better for things like The Gimp or
Netscape, perhaps. You should also do a sanity check to see that
these directories all do, in fact exist, and if you have modified any
lately, you might need to (as root) go in and issue an Note that if you are running a more recent distribution, such as one based on Red Hat 6.0 or later, you won't have to worry about this, as the xttfs True Type font server is the default, and does not use the path system to find your fonts.
7.3 Using Type 1 Fonts in XThe font types X generally accepts are of limited use, considering that about the only place you'll find fonts of that kind used are in the X Window System itself, and unfortunately most media junkies and fontaholics work in operating systems that prefer other formats. Type 1 fonts, most commonly used in conjunction with PostScript document formats, can be found for free on the internet with considerable ease. Try ftp://ftp.cdrom.com/pub/os2/fonts/ for starters. To make use of these fonts is not that difficult, and graphics programs
like GIMP will take advantage of them tremendously, and best
of all, the Linux X servers understand Type 1 fonts ``out of the box.''
To use them, first unpack the archive using the appropriate commands,
and put the fonts with a Now, you should be able to If you find yourself using Type 1 fonts a lot, and for things other than just X (GhostScript, for instance, can handle this font format as well), you'll want to check out the type1inst utility by James Macnicol. This program can configure Type 1 fonts for GhostScript and X, and it can also generate sample sheets for your fonts, and does most of the work of configuration for you. This program can usually be found at ftp://metalab.unc.edu/pub/Linux/X11/xutils/.
7.4 Using TrueType Fonts in XIf you have been using an operating system such as Windows or the MacOS, you may have lots of fonts sitting on your computer already that are TrueType fonts. TrueType fonts are considered best on smaller, low-resolution displays, such as your computer monitor, and attempt to provide nice features like shading and antialiasing, making your display look smoother. It is also really easy to find cheap TrueType fonts in bulk, and CD's featuring upwards of 500 fonts in the TrueType format are common in computer stores. X does not understand TrueType fonts, and has no innate capability (at present) to do so, and so it needs a separate program to do the font rendering for it. There is a FreeType library to do this, but if you just want to use them on your computer, all you will need is a program called xfstt, the X font server for TrueType. This program should be available at ftp://metalab.unc.edu/pub/Linux/X11/fonts/. Installation is fairly straightforward. Extract the archive, and
If you got no errors there, run the font server in the background with
the command It has been brought to my attention that more recent versions of
xset require a slightly modified version of this command, because of
changes in the code of xset. If you are running a distribution based
on Red Hat 6.0 or later, or something equivalent, you will first want
to try If everything seems to be working fine, at this point you will want to
configure your system so that the fonts will be working when you start
X. If you are just starting X from the command line, this is easy.
All you have to do is add the two commands from the previous paragraph
to your Bear in mind that the installation of a TrueType font server can be
tricky business. Remember that the order that you issue the above
commands is important. The font server must be started before X is
started, otherwise you will run into problems. Be sure to read
the FAQ file that came with the distribution, and the
7.5 ColorsLet's go back to our terminal window and try some more things. Try opening an xterm with a command line like the following:
While that window may not be pretty, and you may not do much of your best work in it, it demonstrates one interesting theme of X, the names of the colors. While not very precise, this is a nice way to remember the colors more easily than remembering a series of hexadecimal numbers. Note that color names are never case-sensitive. If you're interested in the gory details, or want to see the samples, or even want to replace those silly color names with your own for some strange reason, you can find the file listing all the colors with their hexadecimal representation in /usr/X11R6/lib/X11/rgb.txt on your system. There are also some extremely useful utilities with names like xcolorsel and such. They can be found in the usual locations, on http://metalab.unc.edu/pub/Linux/ and elsewhere. A more precise way of specifying colors is through the numerical definition. This consists of a color space name and a set of values in the following syntax: <colorspace-name>:<value>/.../<value> An RGB Device, which you will most likely be using, is specified with the prefix "rgb:" and has the following syntax: rgb:<red>/<green>/<blue> , where <color> is a 1 to 4 digit hexadecimal number. As an example, you might represent the color red with
Next Previous Contents |