Understanding fonts and colors can be more complex in X than on other platforms.
X knows about various font types, including bitmaps, Type 1, and as of v4.x, TrueType. The X server can either handle fonts itself, or sometimes this duty is forked to a font server (of which there are several). xfs (X Font Server) is the most common font server in use on Linux.
A font server is not required, as X can handle most font rendering itself. Font servers are traditionally used for serving fonts to multiple hosts on a network, but sometimes are also used to provide enhanced functionality. Additionally, a font server may provide a modest performance boost by off-loading font rendering to a separate process.
X knows about fonts according to fonts that are in the "FontPath". This is set initially in XF86Config. If the X server is handling font duties itself (i.e. no font server), this will be a list of directories that contain font files, like:
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled" FontPath "/usr/X11R6/lib/X11/fonts/Type1" FontPath "/usr/X11R6/lib/X11/fonts/misc" FontPath "/usr/X11R6/lib/X11/fonts/100dpi" FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
If a font server is being used, the "FontPath" will point to the socket where the font server is serving (this is just one possible example):
In this latter case, the actual font directories that are available will be configured with the font server (see local documentation), which will use a similar directory type scheme as shown for XF86Config.
Once suitable fonts have been installed, they must be "prepared". For most fonts, this means running the mkfontdir utility (see man page) in the directory where the fonts are (as root). Type 1 and TrueType require additional steps (see below). Your vendor has done this for any fonts that were included with your distribution. So, this will only need to be done for fonts that you add. For newly added fonts to become visible to X, you will need to run the appropriate xset commands to either modify the existing FontPath, or re-read it (see man page). Or, re-initialize your font server.
Example: Preparing fonts, and re-initializing font server after adding new fonts:
su <password> mkfontdir /usr/X11R6/lib/X11/fonts/my_new_fonts/ /etc/init.d/xfs restart
The first command may not be necessary on newer distros (since it's done by the init script in some cases). And the font server configuration would need to be modified, if this is a new directory. Example: re-initializing with no font server:
su <password> mkfontdir /usr/X11R6/lib/X11/fonts/my_new_fonts/ xset +fp /usr/X11R6/lib/X11/fonts/my_new_fonts/ xset fp rehash
The "xset +fp" would not be necessary if the directory is already part of the FontPath.
xlsfonts | less can be used to list what fonts are known, and thus available, to X and its clients. Run xlsfonts | less, and you also can get an idea of the font definition as understood by X. Font resources are specified quite explicitly, and it may seem complex at first. The X Logical Font Description ("XLFD") is the full description for any given font. The XLFD looks like:
Where each field, left to right is:
|fndry - font foundry, the company or individual which made the font.|
|fmly - font family, the popular nickname of the font|
|wght - font weight (bold, medium, etc.)|
|slant - font slant (italics, oblique, roman (normal), etc.)|
|sWdth - font width (normal, condensed, extended, etc.)|
|adstyl - additional style (sans serif, serif, etc.)|
|pxlsz - pixel size, the number of pixels vertically in a character|
|ptSz - approximate point size of the text (similar to pxlsz)|
|resx - horizontal resolution, in dpi|
|resy - vertical resolution, in dpi|
|spc - spacing, only useful, apparently, in the Schumacher fonts|
|avgWidth - average character width of the font|
|rgstry - the recognized registry that lists the font|
|encdng - nationality encoding|
The "*" acts as a wild-card character. In fact, if not every field is specified, the X server will take the first match it finds in the FontPath. This is why it is best to order the FontPath with preferred fonts coming first since some programs will deliberately specify fonts "loosely" so that your system has some discretion.
The program xfontsel (X Font Selector) may be useful. Try launching it now. You will see nothing helpful in the main window at first, but try holding the left button down on the fndry button. If all your fonts are in order, you will see a menu of selections such as adobe and b&h and bitstream and so forth. Select one such as b&h and you will notice that the font in the lower window changes to something intelligible. This is the way fonts are selected with this program; starting from the left, which is the most general selection, and moving toward the right, to the more specific options. Selecting an option toward the rightmost end will not make much sense before the foundry, for instance, is selected, because the options are generally ordered by their dependence on each other.
When you select from the fmly selection, you will see most of the options grayed out, and only three remaining. That means that these three are the only families of font made by this foundry. Some families appear under more than one foundry, for instance, both Adobe and Bitstream make a variation of the Courier font. Now you can select the wght, and so forth. After you get far enough you will have narrowed it down to the font that you want. You don't necessarily have to fill in all the options to choose a single font, there's not that many fonts on your system! The options that you do not select will be represented by a * indicating that any option will do in that spot, and gives X some leeway.
When you are satisfied with your font selection, 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 example, open an xterm window and type in something like xterm -font followed by an opening quotation mark. Then point to that spot on your screen, and click your middle mouse button (or click both the left and right, if you're middle-button impaired). This will paste the selection from the clipboard, which should be the font you just selected. Then enter the closing quote, and hit Enter. For instance, a nice big xterm with a Courier font specified would look like this: xterm -font "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-*-*".
If you've found a font you prefer, this can permanently be used by placing the font definition in the appropriate configuration file (see above).
Note that you can also limit the number of fonts that you want xfontsel to display with the command line option -pattern, followed by a quoted font specification, as discussed above.
The xfd utility is also helpful for examining individual fonts. If launched with a command line such as xfd -fn fixed, it will show you the complete character set for that font.
KDE and GNOME have their own utilities that are not quite as obtuse ;-)
The fonts provided with XFree86 are of limited use for many of us, considering that about the only place you'll find fonts of that kind, are used in the X Window System itself for the most part. Unfortunately many media junkies, web designers and fontaholics work in operating systems that rely on other formats. And then, there often does not seem to be much emphasis by some distributions on making the best of the default fonts either.
Type 1 fonts, most commonly used in conjunction with PostScript document formats, are the traditional standard in Unix and Linux environments. You should have a reasonably good starter selection installed already. Or, more can be found for free on the Internet with considerable ease, and Try ftp://ftp.cdrom.com/pub/os2/fonts/ for starters. Type 1 are scalable fonts, and have many of the same benefits of the better known TrueType fonts. If you don't have a good selection of TrueType fonts installed, then Type 1 is what you want for most GUI applications. But again, this is not standard on other platforms, and can present problems when viewing documents (e.g. web pages) that are designed with "other platforms" in mind.
TrueType fonts started with Apple, and later were licensed by Microsoft. So people migrating from non-Unix platforms are already familiar with these high quality fonts. Unfortunately, there are not many quality TrueType fonts under a suitable license, and thus there are not many included with Linux distributions. And the ones that are, often are not as high quality. Also unfortunately, TrueType has become somewhat of a standard on the Web and in other venues, and not having good TrueType fonts can be a detriment. XFree86 also seems to render TrueType a little better than Type1.
That's the bad news. The good news is that any TrueType font included with any version of Windows, or any Windows applications, should work on Linux. Though you will have to take some additional steps to integrate them. This particularly helps web browsing where X's bitmapped fonts just don't scale well.
We won't go into detail on installing and configuring these fonts here, as it is addressed in depth in other documents. See The Font HOWTO , http://www.linuxdoc.org/HOWTO/Font-HOWTO.html, for general font information, and Type 1 tips. See The Font De-Uglification Mini HOWTO, http://www.linuxdoc.org/HOWTO/mini/FDU/index.html, for various X related font tips, especially TrueType.
Let's go back to our terminal window and try something. Open an xterm with a command line like the following:
xterm -fg DarkSteelBlue1 -bg red3 &
Ouch! While that may not be pretty, and you may not do much of your best work in it, it demonstrates one interesting aspect of X configuration -- color names. While not particularly precise, this is a nice way to remember a variety of colors. Note that color names are never case-sensitive.
The X server will actually deal with color values as a hexadecimal Red-Green-Blue (RGB) color notation. This would look something like "#0aff0a" in hex. Not so easy to remember. But X gives a more mnemonic way of remembering valid color definitions. These are stored in a text table, typically as /usr/X11R6/lib/X11/rgb.txt, and is defined in XF86Config in the "Files" section.
If you are interested, have a look with a text editor. There are many, many shades defined. I count eighty-three shades of blue in mine, for instance. Brief snip:
176 226 255 LightSkyBlue1 164 211 238 LightSkyBlue2 141 182 205 LightSkyBlue3 96 123 139 LightSkyBlue4 202 225 255 LightSteelBlue1 188 210 238 LightSteelBlue2 162 181 205 LightSteelBlue3 110 123 139 LightSteelBlue4 191 239 255 LightBlue1 178 223 238 LightBlue2 154 192 205 LightBlue3 104 131 139 LightBlue4
This file can be customized should you desire, but this is rarely needed for most of us. It is important to have though, since some applications depend on it.
Desktop Environments will have a GUI utility for selecting colors.
Закладки на сайте
Проследить за страницей
Created 1996-2023 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру