---------------------------------------------------------------------------- Some Tips Regarding OPENWINDOWS and Fonts SunFLASH Vol 20 #4 August 1990 ---------------------------------------------------------------------------- This is from an internal, technical correspondence that I have been given permission to pass on. If you are planning to have X windows running on multiple platforms, it is likely that you will find this information useful. - flash ---------------------------------------------------------------------------- Point one: ========== The MIT X11 SERVER supports "Adobe Character Bitmap Distribution Format" (bdf) font format. These fonts are provided as ASCII files and must be converted from ASCII to MACHINE-DEPENDENT format in order for X SERVER to process them correctly. So the BDF fonts need to be converted to SNF or Server Natural Fonts-which have .snf extensions. Sun's X11/NeWS server DOESN'T support SNF format fonts! Sun does support the OUTLINE and BITMAP fonts which have extension ".f3b" and ".fb" respectively. In the case of the OUTLINE fonts i.e. ".f3b", this is nothing more than a description file that contains information about the SCALABILITY of the font. The OUTLINE fonts are also known as 1) FOLIO fonts 2) OpenFonts "F3" and 3) SCALABLE fonts. Note that in choosing certain SCALABLE FONTS to run under the Sun environment you may experience problems with backspacing of characters (you get garbled characters) this happens because it's impossible to tune a every scalable font to display correctly on a terminal emulator. The BITMAP fonts i.e. ".fb" extensions are actual binary files that cannot be shared between different architectures. It takes less time to load these into to the X11/NeWS server because they do not have to be created and scaled. Point two: ========== The standard fonts shipped with X11/NeWS should already be compiled. If you add BDF(Bitmap Distributed Format) font files to the system, the files must be converted to SNF(Server Natural Fonts) format using the program "bdftosnf" and if you are using a server other than the standard release - and we are we're using our own server i.e. X11/NeWS server - then the server developer should provide a program to convert BDF font files to a format appropriate for the server - and we do. Sun uses the "converfont" (see convert -b) utility in place of "bdftosnf" to convert the font to an accepted format i.e. ".fb" or ".f3b". Point three: ============ Minimum Set of Fonts for X11/NeWS ------------------------------------------------------------------ Outline fonts | Bitmap fonts ------------------------------------------------------------------ Courier | fixed Courier-Bold | cursor Courier-BoldOblique | olglyph Courier-Oblique | Icon Helvetica | NeWSCursor Helvetica-Bold | OLCursor Helvetica-BoldOblique | Screen Helvetica-Oblique | Screen-Bold LucidaSans | LucidaSans-Bold | LucidaSans-BoldItalic | LucidaSans-Italic | LucidaSansTypeWriter | LucidaSansTypeWriter-Bold | Times-Bold | Times-BoldItalic | Times-Italic | Times-Roman | ------------------------------------------------------------------ Most frequently asked question regarding fonts: ======================================================================== 1) How do I convert Sunview fonts to Open-Windows fonts? STEP 1 ------ (copy the font that you want to convert to some other directory): % cp /usr/lib/fonts/fixedwidthfonts/cour.b.24 /usr/tmp/fontdir/newfont.b.24 --------------------------------------------------- STEP 2 ------ (use the convert font utility to font format to .fb, the below command will create a new font called NwfntB24.fb - try it) % convertfont -d /home/openwin/newfonts -b newfont.b.24 ********************** % man converfont (subset) CONVERTFONT(1) USER COMMANDS CONVERTFONT(1) NAME convertfont - dump font out in some other format ... DESCRIPTION convertfont reads in the set of named font files and dumps them out again according to the specified options, effec- tively converting the files from one font format to another. convertfont is typically used to generate fonts for use with the X11/NeWS window system. ... OPTIONS ... -b Selects X11/NeWS output format (the default). The output file extension will be .fb. If the input file is an Adobe ASCII metrics file, the extension will be .fm. ********************** --------------------------------------------------- STEP 3 ------ ( build a font family using the bldfamily utility - WHY?: IN X11/NeWS THE X11 FONT REQUESTS ARE PROCESSED THROUGH THE NeWS FONT UTILITIES. This means that the actual binary data is stored in NeWS data structure format but are mapped to X11 data structures to be passed to the X11 interpreter as font requests are serviced. There is an ASCII font family description file for each font family for example courier would be a font family. The aforementioned description file is pre-processed by the bldfamily utility which creates the binary font family file .ff file. The bldfamily utility will create a Families.list file in the specified font directory. NeWS understands more than bitmap fonts. It understands spline outline and fonts drawn in Postscript. The X11/NeWS server provides a core set of 57 F3 format typefonts. These fonts contain outline and typographic information that preserves the essential properties of a typeface when characters are scaled or rotated. The core set includes the 35 fonts commonly found in the Apple LaserWriter Plus printer. They are compatible in appearance, metrics, character set, and trademarks with the LaserWriter fonts. When an X application asks for a font, the X11/NeWS server strips the number off the very end of the font name and interprets the rest as the font name. The number is used as the font size. For instance the following X11 font, "Times-Roman12", would be interpreted as Postscript code e.g.: ----------------------------------------------------------------------- /Times-Roman findfont 12 scalefont ----------------------------------------------------------------------- The X11/NeWS Server will INITIALLY look for a for .fb version of the font at the requested size and if it finds the font it will load it. If it DOESN'T FIND THE BITMAP it will search for fonts with the ".f3b" extensions, THIS IS JUST A DESCRIPTION OF A SCALABLE FONT. So, if the X11/NeWS Server finds that description font file i.e. ".f3b" then it will build the bitmap from that description and load it into its buffer cache(memory). This is all transparent to the requestor! However, you could explicity do what the server does i.e. build a bitmap font from a scalable font descripition: ----------------------------------------------------------------------- example% cp $OPENWINHOME/lib/fonts/Times-Roman.f3b /usr/tmp/fontdir/. example% chmod 666 /usr/tmp/fontdir/Times-Roman.f3b example% makeafb -32 /usr/tmp/fontdir/Times-Roman.f3b example% convertfont -d /home2/doctor/newfonts -b TmsR* example% bldfamily -d /usr/tmp/fontdir/Times-Roman.f3b example% ls /usr/tmp/fontdir Families.list Times-Roman.f3b* TmsR.fm TmsR32.fb Synonyms.list TmsR.afm TmsR32.afb ----------------------------------------------------------------------- The xlsfonts(1) utility will give you a list of the fonts that the server knows about - this doesn't mean that the font is loaded though. Actually the only difference between loaded versus unloaded is that the a loaded font is already in the server's memory whereas the an unloaded font is not and therefore it takes longer to display the text. Try the following on your machine: ----------------------------------------------------------------------- % xlsfonts |more -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-1 -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 -adobe-courier-bold-o-normal--14-140-75-75-m-90-iso8859-1 .... .... ----------------------------------------------------------------- When you run the "xlsfonts" utility you may probably wonder what all that information is saying? ----------------------------------------------------------------- points(in tenths of point) | | vertical | resolution | in dpi foundry weight set width | | average | | | | | width (in | | | | | tenths of | | | | | a pixel) | | | | | | | | | | | | v v v v v v -adobe-times-medium-i-normal--24-240-75-75-p-125-iso8859-1 ^ ^ ^ ^ ^ |_______| | | | | | | | | | | | | font family | pixels | | character set slant | | | spacing | horizontal resolutin in dpi ----------------------------------------------------------------- For instance a font with 0's in the i.e. pixels, points, horizontal resolution, vertical resolution, spacing, and average width fields respectively specifies this as a SCALABLE FONT e.g.: -linotype-helvetica-bold-o-normal--0-0-0-0-p-0-iso8859-1 A more technical description of what I just said would be: X11 can access the OpenFonts scaling technology through an enhanced version of the X Logical Font Description (X LFD) protocol. The X LFD gives numeric values for pixel size, point size, resolution, and maximum width. Since these variables have an indefinite range of values for a scalable font, these fonts are reported (through xlsfonts or the XListFonts() request) as having "0" in these fields. To use them, take the reported name and replace the pixel size or point size field with the desired value. There are also aliases for fonts e.g.: -------------------------------------------------------------------------- % xlsfonts .... .... 5x8 6x10 6x12 6x13 6x13bold 7x13 7x14 8x13 9x15 .... .... ------------------------------------------------------------------------- Alias | Filename ------------------------------------------------------------------------- 5x8 | -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1 6x10 | -misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1 6x12 | -misc-fixed-medium-r-semicondensed--12-110-75-75-c-60-iso8859-1 6x13 | -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1 6x13bold| -misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1 7x13 | -misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-1 7x14 | -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1 8x13 | -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1 9x15 | -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1 -------------------------------------------------------------------------- There are FOUR ESSENTIAL ELEMENTS of a Font: -------------------------------------------------------------------------- Essential Elements of a Font Name Family | Weight | Slant | Point Size -------------------------------------------------------------- Charter | Medium | r(roman) | 80(8 pt.) | | | Courier | Bold | i(italic) | 100(10 pt.) | | | Helvetica | Demibold | o(oblique) | 120(12 pt.) | | | New century | | ri(reverse | 140(14 pt.) schoolboy | | italic) | | | | Symbol | | ro(reverse | 180(18 pt.) | | oblique) | Times | | ot(other) | 240(24 pt.) | | | Fixed(R4) | | | | | | Clean(R4) | | | | | | OPEN LOOK (R4) | | | | | | Lucida(R4) | | | | | | Terminal(R4) | | | -------------------------------------------------------------- * FAMILY - Any distinct set of character glyphs * WEIGHT & SLANT - The characters in a given font family can be given a radically different appearance by changing the stroke weight or the slant, or both. The most common weights are medium and bold. X11 R4 also includes one font that has an in-between weight called "demibold". Weight names are somewhat arbitrary, since a demibold weight in one family may be almost as dark as a bold weight in another. * POINT SIZE - Font sizes are often given in a traditional printer's measure known as a point. A point is approximately one seventy-second of an inch. Most of the font families are provided in the six point sizes described above. Some servers (such as Sun's combined X11/NeWS server) support scalable outline fonts, which are device-independent, and thus true to size regardless of the output device. But the standard X fonts are simply bitmaps. Because of the different resolution of computer monitors, a font with a given nominal point size might actually appear larger or smaller on the screen. ) (STEP 3 - Cont.) % bldfamily -d /home/openwin/newfonts ********************** % man bldfamily NAME bldfamily - build font family description SYNOPSIS bldfamily [ -d dirname ] [ -f n ] DESCRIPTION bldfamily scans dirname for X11/NeWS font files (files with extensions .fb, .f3b, and .fm) and constructs a font family file for each group of font files with the same family name. bldfamily also creates a file named Families.list that con- tains a list of all the font families in the directory. If dirname is not specified, it defaults to $FONTDIR if defined, to `.' otherwise. Each family file that is built is given the family name followed by the suffix .ff. A font family is a set of font files that are grouped together to provide a single POSTSCRIPT font. In the POSTSCRIPT language, each font has a name, such as Times- Roman, and can be rendered in many different sizes. An X11/NeWS font file is an instance of a POSTSCRIPT font at a particular size. Font family files contain the information necessary for X11/NeWS to pick the right bitmap font. bldfamily also looks for the files Synonyms.list and Compat.list and, if they are present, loads their contents into Families.list. These files provide aliases for com- monly used font names. OPTIONS -d dirname Specifies the directory to scan and put the .ff file into. -f n Sets the maximum length of an output filename (excluding extension) to n . When writing X11/NeWS format files, X11/NeWS normally constructs the output filename from the name of the font and its scaling factors. Some systems cannot cope with long file names, so this option can be used to squeeze the name heuristically. The default value is 8. EXAMPLE example% bldfamily -d /usr/newfonts In this example, bldfamily scans /usr/newfonts and builds a font family file called /usr/newfonts/Boston.ff. ********************** ----------------------------------------------------------------------- STEP 4 ------ ( add the font to the server using xset(1) ): % xset +fp /home2/doctor/newfonts % xset fp rehash ********************** % man xset (subset) XSET(1) USER COMMANDS XSET(1) NAME xset - user preference utility for X .... .... DESCRIPTION This program is used to set various user preference options of the display. OPTIONS .... .... fp= path,... The fp= sets the font path to the directories given in the path argument. The directories are inter- preted by the server, not by the client, and are server-dependent. Directories that do not contain font databases created by mkfontdir will be ignored by the server. fp default The default argument causes the font path to be reset to the server's default. fp rehash The rehash argument causes the server to reread the font databases in the current font path. This is generally only used when adding new fonts to a font directory (after running mkfontdir to recreate the font database). -fp or fp- The -fp and fp- options remove elements from the current font path. They must be followed by a comma-separated list of directories. +fp or fp+ This +fp and fp+ options prepend and append elements to the current font path, respectively. They must be followed by a comma-separated list of direc- tories. ----------------------------------------------------------------------- STEP 5 ------ (see if Server now knows about this font?) % xlsfonts |grep newfont newfont-bold ======================================================================== Quick Steps Step 1: ------- % cp /usr/lib/fonts/fixedwidthfonts/cour.b.24 /usr/tmp/fontdir/newfont.b.24 Step 2: ------- % convertfont -d /home/openwin/newfonts -b newfont.b.24 Step 3: ------- % bldfamily -d /home/openwin/newfonts Step 4: ------- % xset +fp /home2/doctor/newfonts % xset fp rehash Step 5: ------- % xlsfonts |grep newfont newfont-bold ************************************************************************** RESOURCES: ---------- X11/NeWS Server Guide X Window System User's Guide - O'Reilly Xlib Programming Manual - O'Reilly The NeWS Book - Gosling, Rosenthal and Arden XView Programming Manual - O'Reilly ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Sunflash is an electronic mail news service from Sun Microsystems, Ft. Lauderdale, Florida, USA. It is targeted at Sun Users and Customers. As a field sales and support office, we try to keep SunFlash useful and interesting to you. If you have any comments or suggestions for enhancing SunFlash, please send them to us. SunFlash is ditributed via a hierarchy of aliases. Please try to address change requests to the owner of the alias that you belong to. Please address comments to the SunFlash editor John McLaughlin (sun!sunvice!flash or flash@sunvice.East.Sun.COM). (305) 776-7770.