Welcome to Linux Knowledge Base and Tutorial
"The place where you learn linux"

 Create an AccountHome | Submit News | Your Account  

Tutorial Menu
Linux Tutorial Home
Table of Contents
Up to --> Linux Tutorial

· The X Windowing System
· Configuring the X-Windows Server
· The Basics of X
· Resources
· Colors
· Displaying Clients
· Fonts
· The Window Manager
· Remote Access

Glossary
MoreInfo
Man Pages
Linux Topics
Test Your Knowledge

Site Menu
Site Map
FAQ
Copyright Info
Terms of Use
Privacy Info
Disclaimer
WorkBoard
Thanks
Donations
Advertising
Masthead / Impressum
Your Account

Communication
Feedback
Forums
Private Messages
Recommend Us
Surveys

Features
HOWTOs
News
News Archive
Submit News
Topics
User Articles
Web Links

Google
Google


The Web
linux-tutorial.info

Who's Online
There are currently, 256 guest(s) and 1 member(s) that are online.

You are an Anonymous user. You can register for free by clicking here

  
Linux Tutorial - The X Windowing System - Fonts
  Displaying Clients  ---- The Window Manager  


Fonts

Although not applicable to every client, fonts play a major role in many applications. Defined as a set of characters for displaying text and symbols, fonts share a common appearance in terms of size, boldness, and other physical characteristics. Fonts themselves can be grouped together into font families. Additionally, font families are grouped by resolutions (dots-per-inch, or DPI) into directories. Font families are so named because they were initially stored together in the same directory in the file system. Each directory contains a database that the server uses to translate font names into data that the server uses to display the characters on the screen. How the name of a font is translated, we see in Figure 0-2.

If the X client has a font menu like MS-Windows or Macintosh, life would be easy when it came to fonts. Instead, you need to choose the font as you start the application. If you were tired of the boring font used by default on XTerms, you could choose something a little more fancy, perhaps one that looked like cursive. For example, we could start xterm like this:

xterm -fn -bitstream-charter-bold-i-normal--12-120-75-75-p-74-iso8859-1

At first, this appears rather intimidating. There are several hundred fonts on an Linux system and learning them all is a pain. More than that, it is a waste of time. Two utilities make like easier for you: xlsfont and xfontsel. The xlsfont utility simply lists all the available fonts with their complete name, as in the previous example. The xfontsel is a real X client that enables you to pick and choose a font based on different criteria. What those criteria are is helpful in understanding more about fonts.

Characteristics of the Font Name

The foundry is the fonts developer. Here we have bitstream, which, as one might guess, is from the company Bitstream, the same people who develop so many fonts for MS-Windows. The font family (here, charter) is a convenient way of organizing the fonts by certain appearance characteristics.

The weight of a font can be thought of as its thickness. Common weights are medium and bold. The slant, as you might guess, is the change in orientation of the character from the vertical. A Roman slant is upright, italic is tilted, but the characters are given a slightly different shape to make them more esthetically pleasing, and oblique is just tilted with no changes to the characters shape. In the example in Figure 0-2 we have an italic slant.

The set width is a general description of the average width. Common set widths are normal, condensed, and double-width. The size of the font on the screen is determined by several aspects of the font name. These characteristics are the pixels, points, and both vertical and horizontal DPI. Because the appearance on your screen depends on your monitor as well as what fonts you choose, it's safe to gauge the font size by the points. A point is an old printers measurement that represents 1/72 of an inch. In the example in Figure 0-2 we have 120 tenths of a pitch, therefore the size of each character is 1/6 of an inch.

Another important characteristic is the font spacing, which determines whether the font is proportional or monospaced. A proportional font is one in which the width of each character is different. Although this looks good on paper or on a word processor, it is not really suited for applications like terminal emulators. The monospaced font, in which every character takes up the same space, is better for such applications.

The character set is basically another way of saying what letters are represented. In this example and most others in Linux, this field will be iso8859-1, which represents the ISO Latin 1 character set, which is a superset of the standard ASCII character set. In addition to American English characters, iso8859-1 contains the special characters used in most European languages.

So now that we know what goes into font name, we can easily come up with the right font. Well, maybe. Fortunately, we don't have to. We can use a wild card for the parts of the font that we either don't think are important or don't want to guess at. Any one of the specifications can be wild carded and the system will do it's best to find a match. By "do its best," I mean that there can and will be cases in which multiple fonts match the specification. A rather simple example would be:

XTerm -fn -bitstream-charter*

On most systems there are 60 matches. So, which one does the system choose? Easy enough: the first one it finds. Unless you are more specific or know that the first one the system will find is the font you want, you might not get the font you want. Fonts are sorted in alphabetical order, and because bold comes before medium, we get the bold version of this font instead of the medium.

Pop quiz: Why did we enclose the font name in this example inside single quotes though we didn't in the first example? Remember that the shell expands everything into tokens before it passes things off to the command. If we didn't use the single quotes, the shell would try to expand the font name and we would get a message indicating that the system cannot find that font. Details on using quotes can be found here.

Life is even simpler than that. We don't need remember any long, drawn-out font names or try 20 different combinations to find the font we want. We can take advantage of the fact that the system understands font aliases, which are stored in the font directories in the file fonts.alias. These files are ASCII files with the alias in the first column and the font name in the second column.

There are two things to keep mind. First, although you can edit these files and make changes, the system will not recognize the new alias unless you reset the font path with the xset command, which is simply done as;

Next, unless you are absolutely positive about what fonts each user is using and how they are being referenced, it is not a good idea to remove aliases. If you remove an alias that some client is expecting, the results are unpredictable.

If you always want to use a particular font with a particular application, you don't need to always specify the -fn option when starting the client. Because the font is just another resource, you can instead make the change to your resource definition file. An example in our .Xdefaults file might look like this:

XTerm*font: ibm10x20

If you looked though the directory files, you wouldn't find a font simply named ibm10x20; this is actually an alias. However, you could specify the full name of the font. Also, just like specifying the font from the command line, we can use wild cards to specify the "we-don't-cares."

The directories in which the fonts are found by the server are referred to by the font path. This is the XFONTS variable, which defaults to /usr/lib/X11/fonts but can be changed using the xset command. Because the server displays the information on the screen, the font path is on the server, not on the client machine. Therefore it is important to ensure that the server is able to display a particular font before changing it for any given client. There are five subdirectories under /usr/lib/X11/fonts varying in size and appearance.

The font database is contained in the fonts.dir file in each directory. You use this database when you select a font. The system knows what file to read to be able to show the proper characters on the screen. The fonts.dir files are ASCII files with the name of the font file in the first column and the font name in the second column. When the system is installed, the mkfontdir reads the font files found in the font path and creates the fonts.dir files. You can use mkfontdir yourself, but the details of fonts creation and management goes beyond the scope of this book.

Rather than requiring every machine on the network to have a full compliment of fonts, the system has something called a font server. Like a file server that provides files across the network, a font server provides fonts across the network. Just like files, if the font you want is not available by the server but is available locally, there is no problem. You can access it as well.

The font server program, xfs, is not started by default but can be started in one of several different ways. Although starting it manually might be good for testing purposes, it is more efficient to have the font server start up every time the system goes into multiuser mode. As with many of the differenromant aspects of the system, this is accomplished through a script in the /etc/rc.d directory. However, there is no script there by default. Obviously, you could write the script yourself, but you ought to let the system do it for you.

Starting the font server from the command line is not recommended for everyday use. To be able to use the fonts provided by the font server, you need to tell your X session about it. The best place to do this is inside your $HOME/.xinitrc file. Although the system administrator (you?) can change the /etc/xinitrc file, everyone using the default gets to use it, so you need to remember those people who already have their own .startxrc file. Before any clients are started, use the xset command to specify where the font server is. The general syntax is

xset fp=tcp/server:port

where the server is the name of the machine on which the font server is running, and port is the TCP broadcast port, which is 7000 by default. For example, to access the font server on the machine siemau, the command would be

xset fp=tcp/siemau:7000

Or, if you want to use local fonts as well, the line might look like this:

The font servers configuration file is /usr/lib/X11/fs/config. Here you can limit what fonts will be made available through the font server by changing the catalog entry and specifying the full paths to the directories with the appropriate fonts. For example, if you only wanted to have access to the 100 dpi fonts, the line might look like this:

catalogue = /usr/lib/X11/fonts/100dpi

To make the changes take effect, either stop and restart the font server or use the /etc/fontserv command to re-read the configuration file and flush the cached entries:

fontserv re-read

fontserv flush

Like name servers in TCP/IP, which get name information from other name servers, you can have font server get fonts from other font servers. This is also done with the catalogue entry. For example, if I wanted to make the local 100 dpi fonts available, as well as the from the remote host scoburg, the entry might look like this

catalogue = /usr/lib/X11/fonts/100dpi,tcp/scoburg:7000

assuming that scoburg has its font server configured to use port 7000. Changing the port is also accomplished by changing the /usr/lib/X11/fs/config file. On a line by itself, add a line specifying the appropriate port. For example, if you wanted to change it to 7042, the entry would look like this:

port=7042

Once the change is made, the font server needs to be stopped and restarted. If any other machines were using this server, they need to be told that it is now set for port 7042.

You can use the -cf option when starting the font server to specify an alternate configuration file. Reconfigure any X servers that use the font server. Note: Use care when you reference other font servers. Font server connections place a heavy demand on network resources and bandwidth. Also, be careful not to let the number of references to other font servers become so large that your system font server becomes unmanageable.

 Previous Page
Displaying Clients
  Back to Top
Table of Contents
Next Page 
The Window Manager


MoreInfo

Test Your Knowledge

User Comments:


You can only add comments if you are logged in.

Copyright 2002-2009 by James Mohr. Licensed under modified GNU Free Documentation License (Portions of this material originally published by Prentice Hall, Pearson Education, Inc). See here for details. All rights reserved.
  
Show your Support for the Linux Tutorial

Purchase one of the products from our new online shop. For each product you purchase, the Linux Tutorial gets a portion of the proceeds to help keep us going.


Login
Nickname

Password

Security Code
Security Code
Type Security Code


Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.

Help if you can!


Amazon Wish List

Did You Know?
The Linux Tutorial welcomes your suggestions and ideas.


Friends



Tell a Friend About Us

Bookmark and Share



Web site powered by PHP-Nuke

Is this information useful? At the very least you can help by spreading the word to your favorite newsgroups, mailing lists and forums.
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters. Articles are the property of their respective owners. Unless otherwise stated in the body of the article, article content (C) 1994-2013 by James Mohr. All rights reserved. The stylized page/paper, as well as the terms "The Linux Tutorial", "The Linux Server Tutorial", "The Linux Knowledge Base and Tutorial" and "The place where you learn Linux" are service marks of James Mohr. All rights reserved.
The Linux Knowledge Base and Tutorial may contain links to sites on the Internet, which are owned and operated by third parties. The Linux Tutorial is not responsible for the content of any such third-party site. By viewing/utilizing this web site, you have agreed to our disclaimer, terms of use and privacy policy. Use of automated download software ("harvesters") such as wget, httrack, etc. causes the site to quickly exceed its bandwidth limitation and are therefore expressly prohibited. For more details on this, take a look here

PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.17 Seconds