'\"!  tbl | mmdoc
.if n .pH port.chap11 @(#)chap11	40.4
.\" Porting manual:  Ch. 11 Fonts
.\"
.\" @(#)c1-intro.mex 1.2 89/07/14 Copyright 1989 Sun Micro
.\"
.\" Ps = POSTSCRIPT
.\" Sd = NeWS
.\" Cs = CSCRIPT
.ds Ps P\s-2OST\s+2S\s-2CRIPT\s+2
.ds Sd \s-2X11/Ne\h'-0.2n'WS\s+2
.ds Cs \CS\s-2CRIPT\s+2
.BK "Porting the X11/NeWS Server"
.CH "Font Support" 11
.H 1 "Font Support" 
.H 2 "Font File Types"
This chapter describes how to port fonts in the \*(Sd server.
.\"
.\" .H 2 "Intro to porting Fonts."
Some font formats can be read by the \*(Sd server, and some cannot. Some
are machine independent, and therefore can be easily transported between
different machine architectures. The 
.UI convertfont
utility is useful
for converting between different font formats, but has a limited set
of valid input and output font formats.  The table below 
provides basic information for relevant font formats.
.TS
center, tab (/) box;
l l l l l l
p8l p8l p8l p8l p8l p8l .
Font format/File/Transportable/Server/conv./conv.
/ext.//readable/input/output
_

Source for OpenFont\u\s-3\(tm\s0\d/.f3b/Yes/Yes/No/No
Adobe ASCII bitmap/.afb/Yes/No/Yes/Yes
Adobe ASCII metric/.afm/Yes/No/Yes/Yes
NeWS binary bitmap/.fb/No/Yes/Yes/Yes
NeWS binary metric/.fm/No/Yes/Yes/Yes
Adobe MIT X11 BDF 2.1/.bdf/Yes/No/No/Yes
PostScript/.ps/Yes/Yes/No/No
Sun standard vfont/.vft/No/Yes/Yes/Yes

.TE
Use the 
.UI makeafb 
utility to produce 
.UI .afm 
and 
.UI .afb 
files from 
.UI .f3b's
.H 2 "Font Utilities"
Utilities are used for installing font and map files, loading fonts
into the server, converting fonts from one format to another, and 
creating new ASCII cursor and icon fonts. All font utilities are
written in C, except 
.UI ldf 
which is a shell script. The source for these utilities is located under 
.UI usr.bin/xnews/xnews/utilities/fonts .
.P
The font utilities may require some extra porting attention. New
hardware architectures must be taken into account for font conversion.
For example, in porting to AT&T SVR4.0 we had to add extra code
to handle BIGENDIAN/LITTLEENDIAN differences in the following files:
.UI "makeafb.c, rdadobefnt.c, rdfont.c, wrbdffont.c," 
.UI "writeafont.c & writebfont.c."
It may also be necessary to provide support for different font formats
which means 
.UI convertfont 
will have to be enhanced.
.P
Below we describe the function of these utilities.  For a detailed 
description of these utilities and their usage, 
refer to the manpages in the X11/NeWS Server Guide.
.H 3 "\f4bldfamily\fP"
.UI bldfamily 
is used to install a new font in the \*(Sd server.
.P
.nf
Source: \f4
bldfamily.c        fontnames.c\fP
.H 3 "\f4convertfont\fP"
The 
.UI convertfont 
utility is used to convert a font file from one format to another.
.P
.nf
Source: \f4
convertfont.c      findmap.c         fontnames.c
parsemap.c         prntfamily.c      rdadobefnt.c   
rdcmufont.c        rdfont.c          rdobfont.c
wrbdffont.c        writeafont.c      writebfont.c
writevfont.c       NameMap.h         cmufont.h
findmap.h          fontmaps.h        oldfont.h\fP
.P
.fi
.H 3 "\f4ldf\fP 
.P
This utility is used to load a font into the server.
.P
.nf
Source:	\f4
ldf.sh\fP
.P
.fi
.H 3 "\f4makeafb\fP"
The 
.UI makeafb 
utility is used to convert font files from the \f3OpenFonts\fP\u\s-3\(tm\s0\d 
(outline) source format (
.UI .f3b ) 
to the Adobe ASCII bitmap 
and metric formats (
.UI .afb 
and 
.UI .afm
).
.P
.nf
Source: \f4
findmap.c         fontnames.c        makeafb.c
parsemap.c        NameMap.h          findmap.h
fontmaps.h\fP
.fi
.H 3 "\f4map2ps\fP"
.P
This utility is used to install the map file for a new font.
.P
.nf
Source: \f4
map2ps.c          parsemap.c         NameMap.h\fP
.fi
.H 3 "\f4mkiconfont\fP
.P
This utility is used to construct a new ASCII cursor or icon font from
a list of ASCII bitmap files.
.P
.nf
Source:	\f4
mkiconfont.c\fP
.H 2 "Font Location, Construction, and Installation"
The font source code is located under the source tree in subdirectories under
.UI usr.bin/xnews/xnews/fonts . 
Each subdirectory contains related font files,
possibly in more than one format. Some of the subdirectories contain 
a collection of individual
font character or image files which are combined to produce entire fonts.
.P
The following list describes the font subdirectories, what each
contains, and how fonts are installed.
.P
.H 3 "\f4FolioFonts\fP"
The font files in this subdirectory contain the OpenFonts or outline fonts.
It is possible for the server to read these files (file extension 
.UI .f3b )
directly, but each new point size requires extra calculation. 
That is, to load a new font point size takes more time if the binaries are not 
available.  
.P
The local Makefile installs these files directly into the font 
destination directory, and the Makefile in the 
.UI fonts 
directory one level up 
produces binaries for at least one point size (probably 12). The calculation 
time for loading
that point size is therefore eliminated. The binaries are 
produced by using 
.UI makeafb 
to generate the Adobe ASCII files, and 
.UI convertfont 
to generate NeWS binaries from the ASCII files.
.H 3 "\f4TextFonts\fP"
This directory contains the regular text fonts.
The \*(Ps fonts (file extension 
.UI .ps ) 
are copied into 
the font destination directory. The Adobe ASCII fonts (file extensions: 
.UI .afb 
and 
.UI .afm )
and the BDF fonts (
.UI .bdf ) 
are converted into binaries with 
.UI convertfont , 
and installed in the font destination directory.
.H 3 "\f4XFonts\fP"
This directory contains the X Fonts as taken from from the MIT tape.
These fonts are converted from Adobe/MIT X11 BDF 2.1 format by 
.UI convertfont , 
into NeWS binaries and installed in the font destination directory. The file 
.UI cursorfont.h
is also installed into the X11 public include directory.
.H 3 "\f4OLCursor\fP"
Contains the \f3Open Look\fP\u\s-3\(tm\s0\d cursor fonts.\**
In this directory, the 
.UI ".afb" 
file is already available. 
.UI converfont
is executed to generate 
.UI ".fb" 
files from this and from the 
.UI ".bdf" 
files which are also available in this directory. The local 
.UI makecursorps 
utility is executed to generate a 
.UI cursor.ps 
file. The newly generated 
.UI ".fb"
and 
.UI ".ps" 
files are installed as above.
Note that only one of
.UI OLCursor
or 
.UI Cursor 
can be installed at any one time.
.H 1 "Cursor, Icon, and Open Look Fonts"
These files are located the directories listed below.
Note that the Cursor, Icon, and Open Look fonts are all 
handled in the same way.
A complete Adobe ASCII bitmap font file (
.UI .afb ) 
is created using the 
.UI mkiconfont 
utility on the list of images on the fontlist file (i.e. 
.UI cursfont.lst
for Cursor, 
.UI iconfont.lst
for Icon, 
.UI OpnLk*.lst 
for the 
Open Look fonts). The binary version of the font is then generated from the 
.UI ".afb" 
with 
.UI convertfont . 
The \*(Ps code required to update the font 
dictionary is generated from the ASCII bitmap with the local 
.UI makeps 
utility (i.e. 
.UI makecursorps
for Cursor, 
.UI makeiconps
for Icon, 
.UI makelookps
for Open Look). 
The binary version of the font is installed in the font destination 
directory. 
The \*(Ps file is installed with other \*(Ps files in 
.UI usr/etc/NeWS 
under 
.UI $DESTDIR.
.nf
.H 3 "\f4Cursor\fP"
Contains the NeWS cursor font.
.H 3 \f4Cursor/images\fP
Contains the individual NeWS cursor font images.
.H 3 \f4Icon\fP 
Contains the Icon font.
.H 3 \f4Icon/images\fP
Contains the individual icon images.
.H 3 \f4OpenLook/images8\fP 
Contains the Fonts for XView - point size 8.
.H 3 \f4OpenLook/images10\fP 
Contains the Fonts for XView - point size 10.
.H 3 \f4OpenLook/images12\fP 
Contains the Fonts for XView - point size 12.
.H 3 \f4OpenLook/images14\fP 
Contains the Fonts for XView - point size 14.
.fi
.H 2 "Reading Fonts into the Server"
The files listed below contain the 
source involved in reading fonts into the \*(Sd
Server. The 
.UI xnews/xnews/server/folio
directory tree contains code
only related to folio and is compiled into the server when the
.UI FOLIO 
flag is set.
.P
There is potential here for extra porting work if it becomes necessary
to make the server recognize more font formats than it does at present.
Also, 
.UI xnews/xnews/server/cscript/foliofam.c 
has a small amount of
architecture dependent code. (Look for the 
.UI "LITTLEENDIAN ifdef"
).
.nf
\f4
xnews/xnews/server/folio/*
xnews/xnews/server/nucleus/fontdict.c
                         /definefont.c
xnews/xnews/server/cscript/foliofam.c
                         /font.c
                         /fontcache.c
                         /fontinfo.c
                         /rdbfont.c
                         /rdfamily.c
                         /buildfont.c
                         /bitmapfam.c
                         /defcursor.h\fP
.fi





