Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 7219

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<HTML
><HEAD
><TITLE
>Fonts and Colors</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="The X Window User HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="More X Configuration"
HREF="moreconfig.html"><LINK
REL="NEXT"
TITLE="Window Managers and Desktops"
HREF="windowman.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The X Window User HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="moreconfig.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="windowman.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="FONTSCOLORS">5. Fonts and Colors</H1
><P
> Understanding fonts and colors can be more complex in
 <SPAN
CLASS="APPLICATION"
>X</SPAN
> than on other platforms. </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN822">5.1. Fonts Demystified</H2
><P
> <SPAN
CLASS="APPLICATION"
>X</SPAN
> 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). <B
CLASS="COMMAND"
>xfs</B
> (X Font Server) is the most common
 font server in use on Linux.&#13;</P
><P
> A font server is not required, as <SPAN
CLASS="APPLICATION"
>X</SPAN
> 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.&#13;</P
><P
> <SPAN
CLASS="APPLICATION"
>X</SPAN
> knows about fonts according to fonts that are in
 the <SPAN
CLASS="QUOTE"
>"FontPath"</SPAN
>. This is set initially in
 <TT
CLASS="FILENAME"
>XF86Config</TT
>. 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:&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; 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"

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> If a font server is being used, the <SPAN
CLASS="QUOTE"
>"FontPath"</SPAN
> will point to the
 socket where the font server is serving (this is just one possible example):&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; FontPath "unix/:7101"

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> 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 <TT
CLASS="FILENAME"
>XF86Config</TT
>.&#13;</P
><P
> Once suitable fonts have been installed, they must be
 <SPAN
CLASS="QUOTE"
>"prepared"</SPAN
>. For most fonts, this means running the 
 <B
CLASS="COMMAND"
>mkfontdir</B
> 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 <SPAN
CLASS="APPLICATION"
>X</SPAN
>, 
 you will need to run the appropriate
 <B
CLASS="COMMAND"
>xset</B
> commands to either modify the existing FontPath, or
 re-read it (see man page). Or, re-initialize your font server.&#13;</P
><P
> Example: Preparing fonts, and re-initializing font server after adding new
 fonts:&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; su 
 &#60;password&#62;
 mkfontdir /usr/X11R6/lib/X11/fonts/my_new_fonts/
 /etc/init.d/xfs restart

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> 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:&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; su 
 &#60;password&#62;
 mkfontdir /usr/X11R6/lib/X11/fonts/my_new_fonts/
 xset +fp /usr/X11R6/lib/X11/fonts/my_new_fonts/
 xset fp rehash

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> The <SPAN
CLASS="QUOTE"
>"<B
CLASS="COMMAND"
>xset +fp</B
>"</SPAN
> would not be necessary if the
 directory is already part of the FontPath.&#13;</P
><P
> <B
CLASS="COMMAND"
>xlsfonts | less</B
> can be used to list what fonts are known,
 and thus available, to <SPAN
CLASS="APPLICATION"
>X</SPAN
> and its clients. Run
 <B
CLASS="COMMAND"
>xlsfonts | less</B
>, and you also can get an idea of the font
 definition as understood by <SPAN
CLASS="APPLICATION"
>X</SPAN
>. Font resources are
 specified quite explicitly, and it may seem complex at first. The <EM
>X
 Logical Font Description</EM
> (<SPAN
CLASS="QUOTE"
>"XLFD"</SPAN
>) is the full
 description for any given font. The XLFD looks like: 
 </P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; -adobe-helvetica-medium-r-normal-*-*-120-*-*-p-*-iso10646-1

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> Where each field, left to right is:&#13;</P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>fndry</TT
> - font foundry, the company or individual
  which made the font.
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>fmly</TT
> - font family, the popular nickname of the font
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>wght</TT
> - font weight (bold, medium, etc.)
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>slant</TT
> - font slant (italics, oblique, roman
  (normal), etc.)

 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>sWdth</TT
> - font width (normal, condensed, extended, etc.)
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>adstyl</TT
> - additional style (sans serif, serif, etc.)
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>pxlsz</TT
> - pixel size, the number of pixels
  vertically in a character
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>ptSz</TT
> - approximate point size of the text
  (similar to pxlsz)
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>resx</TT
> - horizontal resolution, in dpi
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>resy</TT
> - vertical resolution, in dpi
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>spc</TT
> - spacing, only useful, apparently, in the
  Schumacher fonts
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>avgWidth</TT
> - average character width of the font
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>rgstry</TT
> - the recognized registry that lists
  the font 
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
>  <TT
CLASS="LITERAL"
>encdng</TT
> - nationality encoding
 </TD
></TR
></TBODY
></TABLE
><P
></P
><P
> The <SPAN
CLASS="QUOTE"
>"*"</SPAN
> 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 
 <SPAN
CLASS="QUOTE"
>"loosely"</SPAN
> so that your system has some discretion.&#13;</P
><P
> The program <B
CLASS="COMMAND"
>xfontsel</B
> (<SPAN
CLASS="APPLICATION"
>X</SPAN
> 
 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 <TT
CLASS="LITERAL"
>fndry</TT
> button. If all your fonts are
 in order, you will see a menu of selections such as <TT
CLASS="LITERAL"
>adobe</TT
> and <TT
CLASS="LITERAL"
>b&#38;h</TT
> and
 <TT
CLASS="LITERAL"
>bitstream</TT
> and so forth. Select one such as
 <TT
CLASS="LITERAL"
>b&#38;h</TT
> 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. 
 </P
><P
> When you select from the <TT
CLASS="LITERAL"
>fmly</TT
> 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
 <EM
>Adobe</EM
> and <EM
>Bitstream</EM
> make a
 variation of the Courier font. Now you can select the <TT
CLASS="LITERAL"
>wght</TT
>, 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
 <EM
>that</EM
> many fonts on your system! The options that you do
 not select will be represented by a <TT
CLASS="LITERAL"
>*</TT
>
 indicating that any option will do in that spot, and gives X some leeway.</P
><P
> When you are satisfied with your font selection, hit the select button,
 and your selection will be placed in the <SPAN
CLASS="APPLICATION"
>X</SPAN
>
 clipboard, ready to be pasted into your document or whatever you are working
 on. For example, open an <EM
>xterm</EM
> window and
 type in something like <TT
CLASS="LITERAL"
>xterm -font </TT
> 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 <TT
CLASS="LITERAL"
>Enter</TT
>. For instance, a nice big <EM
>xterm</EM
> with a Courier font specified would look like
 this: <TT
CLASS="LITERAL"
>xterm -font
 "-adobe-courier-medium-r-*-*-14-*-*-*-*-*-*-*"</TT
>. </P
><P
> 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).&#13;</P
><P
>  Note that you can also limit the number of fonts that you want 
  <B
CLASS="COMMAND"
>xfontsel</B
> to display with the command line option
 <EM
>-pattern</EM
>, followed by a quoted font specification, as
 discussed above.&#13;</P
><P
> The <B
CLASS="COMMAND"
>xfd</B
> utility is also helpful for examining
 individual fonts. If launched with a command line such as <B
CLASS="COMMAND"
>xfd
 -fn fixed</B
>, it will show you the complete character set for that font.</P
><P
> <SPAN
CLASS="APPLICATION"
>KDE</SPAN
> and <SPAN
CLASS="APPLICATION"
>GNOME</SPAN
> have
 their own utilities that are not quite as obtuse ;-)&#13;</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN942">5.1.1. Type 1 and TrueType Fonts</H3
><P
> 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. </P
><P
> 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 <A
HREF="ftp://ftp.cdrom.com/pub/os2/fonts/"
TARGET="_top"
>ftp://ftp.cdrom.com/pub/os2/fonts/</A
>
 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 <SPAN
CLASS="QUOTE"
>"other platforms"</SPAN
> in mind.&#13;</P
><P
> 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.&#13;</P
><P
> 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 <SPAN
CLASS="APPLICATION"
>X's</SPAN
>
 bitmapped fonts just don't scale well.&#13;</P
><P
> We won't go into detail on installing and configuring these fonts here, as it
 is addressed in depth in other documents. See <I
CLASS="CITETITLE"
>The Font HOWTO
 </I
>, <A
HREF="http://www.linuxdoc.org/HOWTO/Font-HOWTO.html"
TARGET="_top"
>http://www.linuxdoc.org/HOWTO/Font-HOWTO.html</A
>,
 for general font information, and Type 1 tips. See <I
CLASS="CITETITLE"
>The Font De-Uglification 
 Mini HOWTO</I
>, <A
HREF="http://www.linuxdoc.org/HOWTO/mini/FDU/index.html"
TARGET="_top"
>http://www.linuxdoc.org/HOWTO/mini/FDU/index.html</A
>,
 for various <SPAN
CLASS="APPLICATION"
>X</SPAN
> related font tips, especially TrueType.&#13;</P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN957">5.2. Colors</H2
><P
> Let's go back to our terminal window and try something. Open an
 <B
CLASS="COMMAND"
>xterm</B
> with a command line like the following:</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> 
 xterm -fg DarkSteelBlue1 -bg red3 &#38;
 
 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> 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 <SPAN
CLASS="APPLICATION"
>X</SPAN
>
 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.&#13;</P
><P
> The X server will actually deal with color values as a hexadecimal
 Red-Green-Blue (RGB) color notation. This would look something like
 <SPAN
CLASS="QUOTE"
>"#0aff0a"</SPAN
> in hex. Not so easy to remember. But
 <SPAN
CLASS="APPLICATION"
>X</SPAN
> gives a more mnemonic way of remembering valid
 color definitions. These are stored in a text table, typically as
 <TT
CLASS="FILENAME"
>/usr/X11R6/lib/X11/rgb.txt</TT
>, and is defined in 
 <TT
CLASS="FILENAME"
>XF86Config</TT
> in the <SPAN
CLASS="QUOTE"
>"Files"</SPAN
> section.&#13;</P
><P
> 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:&#13;</P
><P
> <TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>&#13; 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

 </PRE
></FONT
></TD
></TR
></TABLE
></P
><P
> 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. &#13;</P
><P
> Desktop Environments will have a GUI utility for selecting colors.&#13;</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="moreconfig.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="windowman.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>More X Configuration</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Window Managers and Desktops</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>