1ce6676dbSmrg<?xml version="1.0" encoding="utf-8"?>
2ce6676dbSmrg<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
334f90d55Smrg    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
434f90d55Smrg[
534f90d55Smrg<!ENTITY % defs SYSTEM "defs.ent"> %defs;
634f90d55Smrg]>
7ce6676dbSmrg<!-- lifted from troff+ms by doclifter -->
8ce6676dbSmrg<!-- previous version was in xorg-docs/specs/xfs/design.ms -->
9ce6676dbSmrg<!-- encoding notes:
10ce6676dbSmrg	- for lack of a better match, the systemitem tag is used for
11ce6676dbSmrg	  protocol request names
12ce6676dbSmrg  -->
1334f90d55Smrg<article id='xfs-design'>
14ce6676dbSmrg  <articleinfo>
15ce6676dbSmrg    <title>Font server implementation overview</title>
1634f90d55Smrg    <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
17ce6676dbSmrg    <author>
18ce6676dbSmrg      <firstname>Dave</firstname>
19ce6676dbSmrg      <surname>Lemke</surname>
20ce6676dbSmrg      <affiliation>
21ce6676dbSmrg        <orgname>Network Computing Devices, Inc.</orgname>
22ce6676dbSmrg      </affiliation>
23ce6676dbSmrg    </author>
24ce6676dbSmrg    <copyright>
25ce6676dbSmrg      <year>1991</year>
26ce6676dbSmrg      <holder>Network Computing Devices, Inc.</holder>
27ce6676dbSmrg    </copyright>
2834f90d55Smrg
2934f90d55Smrg    <legalnotice>
3034f90d55Smrg      <para>
3134f90d55Smrg        Permission to use, copy, modify, distribute, and sell this
3234f90d55Smrg        documentation for any purpose is hereby granted without fee,
3334f90d55Smrg        provided that the above copyright notice and this permission
3434f90d55Smrg        notice appear in all copies.  Network Computing Devices, Inc.
3534f90d55Smrg        makes no representations about the suitability for any purpose
3634f90d55Smrg        of the information in this document.  This documentation is
3734f90d55Smrg        provided "as is" without express or implied warranty.
3834f90d55Smrg      </para>
3934f90d55Smrg    </legalnotice>
4034f90d55Smrg
41ce6676dbSmrg  </articleinfo>
42ce6676dbSmrg  <sect1 id='introduction'>
43ce6676dbSmrg    <title>Introduction</title>
44ce6676dbSmrg    <para>The font server uses the same client/server model as X.
45ce6676dbSmrg    The basic structure is that of the X Consortium X11R5 X server,
46ce6676dbSmrg    and those who know that code should find the
47ce6676dbSmrg    <firstterm remap='I'>os</firstterm> and
48ce6676dbSmrg    <firstterm remap='I'>difs</firstterm> (device independent font
49ce6676dbSmrg    server) layers familiar.</para>
50ce6676dbSmrg    <literallayout class='monospaced'>
51ce6676dbSmrg                        &boxdr;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxdl;
52ce6676dbSmrg                  &boxdr;&boxh;&boxh;&boxh;&boxh;&boxh;&boxvl;      difs       &boxvr;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxdl;
53ce6676dbSmrg                  &boxv;     &boxur;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxul;      &boxv;
54ce6676dbSmrg                  &boxv;                              &boxv;
55ce6676dbSmrg                &boxdr;&boxh;&boxhu;&boxh;&boxh;&boxdl;                  &boxdr;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxhu;&boxh;&boxh;&boxh;&boxdl;
56ce6676dbSmrg                &boxv; os &boxv;                  &boxv; renderers  &boxv;
57ce6676dbSmrg                &boxur;&boxh;&boxh;&boxh;&boxh;&boxul;                  &boxur;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxh;&boxul;
58ce6676dbSmrg    </literallayout>
59ce6676dbSmrg   <sect2 id='definitions'>
60ce6676dbSmrg    <title>Definitions</title>
61ce6676dbSmrg    <glosslist>
62ce6676dbSmrg      <glossentry>
63ce6676dbSmrg        <glossterm>
64ce6676dbSmrg          <firstterm>Renderer</firstterm>
65ce6676dbSmrg	  <indexterm><primary>renderer</primary></indexterm>
66ce6676dbSmrg        </glossterm>
67ce6676dbSmrg        <glossdef><para>Code that knows how to take font data in
68ce6676dbSmrg          its raw format and convert it to the font server's
69ce6676dbSmrg          format.</para></glossdef>
70ce6676dbSmrg      </glossentry>
71ce6676dbSmrg      <glossentry>
72ce6676dbSmrg        <glossterm>
73ce6676dbSmrg          <firstterm>Font Path Element (<acronym>FPE</acronym>)</firstterm>
74ce6676dbSmrg	  <indexterm><primary>Font Path Element</primary></indexterm>
75ce6676dbSmrg	  <indexterm><primary><acronym>FPE</acronym></primary><see>Font Path Element</see></indexterm>
76ce6676dbSmrg        </glossterm>
77ce6676dbSmrg        <glossdef><para>An instance of a renderer, associated with a specific
78ce6676dbSmrg	font source, (ie a directory of PCF bitmaps).</para></glossdef>
79ce6676dbSmrg      </glossentry>
80ce6676dbSmrg    </glosslist>
81ce6676dbSmrg
82ce6676dbSmrg    <para><indexterm><primary>difs layer</primary></indexterm>
83ce6676dbSmrg          The <firstterm>difs</firstterm> layer interprets the
84ce6676dbSmrg          requests, and handles the renderer independent work. This
85ce6676dbSmrg          includes error checking of requests, and the top level
86ce6676dbSmrg          font database. It also contains various utility
87ce6676dbSmrg          functionality such as caching and byte swapping.</para>
88ce6676dbSmrg
89ce6676dbSmrg    <para><indexterm><primary>os layer</primary></indexterm>
90ce6676dbSmrg	  The <firstterm>os</firstterm> layer sets up the
91ce6676dbSmrg          communications channel, reads requests and sends the raw
92ce6676dbSmrg          data of replies and events. It also handles font server
93ce6676dbSmrg          configuration issues, controlled by command line
94ce6676dbSmrg          arguments and a configuration file.</para>
95ce6676dbSmrg
96ce6676dbSmrg    <para><indexterm><primary>renderer layer</primary></indexterm>
97ce6676dbSmrg	  The <firstterm>renderer</firstterm> layer contains all
98ce6676dbSmrg          font-specific code, and is responsible for rendering a font
99ce6676dbSmrg          (which may mean just reading a bitmap from disk, or may
100ce6676dbSmrg          include scaling of outline data), computing a fonts
101ce6676dbSmrg          properties and header information.</para>
102ce6676dbSmrg
103ce6676dbSmrg   </sect2>
104ce6676dbSmrg  </sect1>
105ce6676dbSmrg  <sect1 id='startup'>
106ce6676dbSmrg    <title>Startup</title>
107ce6676dbSmrg    <para>At startup, the font server handles any command line
108ce6676dbSmrg	  arguments, initializes any OS-specific data, and then sets up
109ce6676dbSmrg	  the communications. Various internal databases are then
110ce6676dbSmrg	  initialized (extensions, the font catalogue, etc).</para>
111ce6676dbSmrg
112ce6676dbSmrg    <para><indexterm><primary>configuration file</primary></indexterm>
113ce6676dbSmrg          The config file, an ordered list of font sources, cache
114ce6676dbSmrg	  size hints, default resolutions, and security information, is
115ce6676dbSmrg	  then read in. Each of these source names could be a directory
116ce6676dbSmrg	  name, the name of another font server, or some other string
117ce6676dbSmrg	  that a particular renderer can recognize.</para>
118ce6676dbSmrg
119ce6676dbSmrg    <para>The default font catalogue is then built up by taking
120ce6676dbSmrg	  each of the font source names and comparing it with the
121ce6676dbSmrg	  names a renderer recognizes. The one that matches this name
122ce6676dbSmrg	  will become attached to this source. A renderer will
123ce6676dbSmrg	  &ldquo;understand&rdquo; a name if it can parse the data in
124ce6676dbSmrg	  that directory, or recognize that it is a valid font server
125ce6676dbSmrg	  address, or recognizes a special string. Thus a collection
126ce6676dbSmrg	  of valid font path elements is built up. Each
127ce6676dbSmrg	  <emphasis remap='B'>FPE</emphasis> has a set of functions to
128ce6676dbSmrg	  support opening a font and accessing its data.</para>
129ce6676dbSmrg
130ce6676dbSmrg    <para>Font information is accessed via method functions in the
131ce6676dbSmrg     <indexterm><primary><structname>Font</structname></primary></indexterm>
132ce6676dbSmrg	  <structname>Font</structname>. When a font is first
133ce6676dbSmrg	  loaded, the header information and properties are
134ce6676dbSmrg	  loaded/computed. The font also initializes its function
135ce6676dbSmrg	  pointers to do the proper work. When specific metrics or
136ce6676dbSmrg	  bitmaps are required, they are access via the font's
137ce6676dbSmrg	  functions.  A disk-based bitmap font will probably want to
138ce6676dbSmrg	  load all data when first accessed. A scaled font or FS font
139ce6676dbSmrg	  may want to do more selective caching. In both cases, the
140ce6676dbSmrg	  renderer can use the utility functions to keep track of this
141ce6676dbSmrg	  data. Changing values of bitmap formats could result in the
142ce6676dbSmrg	  font having multiple copies of data in different formats,
143ce6676dbSmrg	  which the renderer may use the utility functions to
144ce6676dbSmrg	  manage.</para>
145ce6676dbSmrg  </sect1>
146ce6676dbSmrg  <sect1 id='per_client_processing'>
147ce6676dbSmrg    <title>Per client processing</title>
148ce6676dbSmrg    <para>Each entity attaching to the server is a client. Each
149ce6676dbSmrg	  client has its own authorization and resolution information,
150ce6676dbSmrg	  and its own view of the font database. A font open to one
151ce6676dbSmrg	  client may not be open to another, though the font server
152ce6676dbSmrg	  may have it loaded.</para>
153ce6676dbSmrg
154ce6676dbSmrg    <para>After initialization, new clients can attach to the font
155ce6676dbSmrg	  server and have their requests processed. For each request that
156ce6676dbSmrg	  is searching for a font (<systemitem>OpenBitmapFont</systemitem>) or
157ce6676dbSmrg	  listing font names (<systemitem>ListFonts</systemitem>,
158ce6676dbSmrg	  <systemitem>ListFontsWithXInfo</systemitem>), the pattern
159ce6676dbSmrg	  is given to each <emphasis remap='B'>FPE</emphasis>.</para>
160ce6676dbSmrg
161ce6676dbSmrg    <para><indexterm><primary><systemitem>OpenBitmapFont</systemitem></primary></indexterm>
162ce6676dbSmrg          <systemitem>OpenBitmapFont</systemitem> will take the supplied
163ce6676dbSmrg	  name and pass it to each <emphasis remap='B'>FPE</emphasis>.
164ce6676dbSmrg	  The <emphasis remap='B'>FPE</emphasis> will return one of
165ce6676dbSmrg	  three things: <errorname>Success</errorname>, and the font
166ce6676dbSmrg	  object; <errorname>BadFont</errorname>, because it doesn't
167ce6676dbSmrg	  know the font; or <errorname>BadFont</errorname> and an
168ce6676dbSmrg	  alias name, when it has an alias for the font. If
169ce6676dbSmrg	  <errorname>Success</errorname> is returned, the server goes
170ce6676dbSmrg	  on to create an ID (or find an existing one) and return a
171ce6676dbSmrg	  reply. If <errorname>BadFont</errorname> is returned, it
172ce6676dbSmrg	  goes on to the next <emphasis remap='B'>FPE</emphasis>. If
173ce6676dbSmrg	  it reaches the end without finding a font, an error is
174ce6676dbSmrg	  returned to the client. If an alias is returned, the search
175ce6676dbSmrg	  resets to the first <emphasis remap='B'>FPE</emphasis> and
176ce6676dbSmrg	  starts again, using the alias as the new font name. This
177ce6676dbSmrg	  allows aliases to work across different
178ce6676dbSmrg	  <emphasis remap='B'>FPEs</emphasis>, without any ordering
179ce6676dbSmrg	  restrictions.</para>
180ce6676dbSmrg
181ce6676dbSmrg    <para>When each <emphasis remap='B'>FPE</emphasis> receives a font
182ce6676dbSmrg	  name to open, it searches for the font's existence. If it
183ce6676dbSmrg	  can't find, or can only find an alias, it returns
184ce6676dbSmrg	  <errorname>BadFont</errorname> and any alias. If it finds
185ce6676dbSmrg	  the font, it checks the authorization and license status of
186ce6676dbSmrg	  the font to that of the client. If it passes, it then
187ce6676dbSmrg	  creates a new font object, and reads and/or computes at
188ce6676dbSmrg	  least the font's header information and properties. (It may
189ce6676dbSmrg	  also want to produce the bitmaps and extents, but that
190ce6676dbSmrg	  choice is left to the renderer.)</para>
191ce6676dbSmrg
192ce6676dbSmrg    <para>When a font's information is accessed, the interpreter
193ce6676dbSmrg	  routine looks up the font ID to find the font object, and
194ce6676dbSmrg	  then uses the font's access functions to get the data. These
195ce6676dbSmrg	  functions will return the data in the format expected by the
196ce6676dbSmrg	  client.</para>
197ce6676dbSmrg  </sect1>
198ce6676dbSmrg
199ce6676dbSmrg  <sect1 id='client_shutdown'>
200ce6676dbSmrg    <title>Client shutdown</title>
201ce6676dbSmrg    <para>When a client disconnects, all its references to any
202ce6676dbSmrg    fonts it still has opened are removed. If no other clients
203ce6676dbSmrg    reference these fonts, they may be freed, though the server may
204ce6676dbSmrg    choose to cache them.</para>
205ce6676dbSmrg  </sect1>
206ce6676dbSmrg
207ce6676dbSmrg  <sect1 id='server_reset_and_cleanup'>
208ce6676dbSmrg    <title>Server reset and cleanup</title>
209ce6676dbSmrg    <para>A server may be reset to flush the caches, re-read the
210ce6676dbSmrg    configuration file, and a new list of
211ce6676dbSmrg    <emphasis remap='B'>FPEs</emphasis> to be built, via an
212ce6676dbSmrg    OS-specific outside action. In UNIX, this will be handled via
213ce6676dbSmrg    signals; in VMS it could be handled via an async trap or event
214ce6676dbSmrg    flag.</para>
215ce6676dbSmrg  </sect1>
216ce6676dbSmrg
217ce6676dbSmrg  <sect1 id='server_offloading'>
218ce6676dbSmrg    <title>Server offloading</title>
219ce6676dbSmrg    <para>In order to deal with numerous clients without major
220ce6676dbSmrg    performance degradation, the server must be able to clone
221ce6676dbSmrg    itself, or provide the client with a substitute server via the
222ce6676dbSmrg    alternate server mechanism. Since both strategies have their
223ce6676dbSmrg    uses, both will be supported. For a server that has plenty of
224ce6676dbSmrg    host memory or CPU, but insufficient sockets, cloning may be a
225ce6676dbSmrg    good choice. For a host with limited memory, assigning an
226ce6676dbSmrg    alternate server on a different host may be a good choice. The
227ce6676dbSmrg    server will make this decision based on configuration options.</para>
228ce6676dbSmrg  </sect1>
229ce6676dbSmrg
230ce6676dbSmrg  <sect1 id='font_server_data_structures'>
231ce6676dbSmrg    <title>Font server data structures</title>
232ce6676dbSmrg    <para>The
233ce6676dbSmrg     <indexterm><primary><structname>Client</structname></primary></indexterm>
234ce6676dbSmrg     <firstterm id='struct_client'><structname>Client</structname></firstterm>
235ce6676dbSmrg	  handles per-client information and interpreter status.
236ce6676dbSmrg    <synopsis>
237ce6676dbSmrgtypedef struct _Client {
238ce6676dbSmrg    int         index;
239ce6676dbSmrg    pointer     osPrivate;
240ce6676dbSmrg    int         noClientException;
241ce6676dbSmrg    int         (**requestVector) ();
242ce6676dbSmrg    pointer     requestBuffer;
243ce6676dbSmrg    int         clientGone;
244ce6676dbSmrg    int         sequence;
245ce6676dbSmrg    Bool        swapped;
246ce6676dbSmrg    long        last_request_time;
247ce6676dbSmrg    void        (*pSwapReplyFunc) ();
248ce6676dbSmrg    AuthContextPtr auth;
249ce6676dbSmrg    char       *catalogues;
250ce6676dbSmrg    int         num_catalogues;
251ce6676dbSmrg    Mask        eventmask;
252ce6676dbSmrg    fsResolution *resolutions;
253ce6676dbSmrg    int         num_resolutions;
254ce6676dbSmrg}           ClientRec, *ClientPtr;
255ce6676dbSmrg    </synopsis></para>
256ce6676dbSmrg    <para>The
257ce6676dbSmrg     <indexterm><primary><structname>Font</structname></primary></indexterm>
258ce6676dbSmrg     <firstterm id='struct_font'><structname>Font</structname></firstterm>
259ce6676dbSmrg	  contains basic font  information, including header information and
260ce6676dbSmrg	  properties.
261ce6676dbSmrg    <synopsis>
262ce6676dbSmrgtypedef struct _font	{
263ce6676dbSmrg	int	refcount;
264ce6676dbSmrg	fsHeader	header;
265ce6676dbSmrg	fsBitmapFormat	format;
266ce6676dbSmrg	int	(*get_glyphs)();
267ce6676dbSmrg	int	(*get_metrics)();
268ce6676dbSmrg	int	(*get_extents)();
269ce6676dbSmrg	int	(*get_bitmaps)();
270ce6676dbSmrg	int	(*unload_font)();
271ce6676dbSmrg	FontPathElementPtr	fpe;
272ce6676dbSmrg	int	*client_ids;
273ce6676dbSmrg	Bool	restricted_font;
274ce6676dbSmrg}	FontRec *FontPtr;
275ce6676dbSmrg    </synopsis></para>
276ce6676dbSmrg    <para>The
277ce6676dbSmrg     <indexterm><primary><structname>ClientFont</structname></primary></indexterm>
278ce6676dbSmrg     <firstterm id='struct_clientfont'><structname>ClientFont</structname></firstterm>
279ce6676dbSmrg	  is a wrapper on top of <structname>Font</structname>,
280ce6676dbSmrg	  handling client specific font information.
281ce6676dbSmrg    <synopsis>
282ce6676dbSmrgtypedef struct _clientfont {
283ce6676dbSmrg	FontPtr	font;
284ce6676dbSmrg	int	clientindex;
285ce6676dbSmrg}	ClientFontRec, *ClientFontRec;
286ce6676dbSmrg    </synopsis></para>
287ce6676dbSmrg    <para>The
288ce6676dbSmrg     <indexterm><primary><structname>AuthContext</structname></primary></indexterm>
289ce6676dbSmrg
290ce6676dbSmrg     <firstterm id='struct_authcontext'><structname>AuthContext</structname></firstterm>
291ce6676dbSmrg	  contains authorization information.
292ce6676dbSmrg    <synopsis>
293ce6676dbSmrgtypedef 	struct _authcontext	{
294ce6676dbSmrg	char	*authname;
295ce6676dbSmrg	char	*authdata;
296ce6676dbSmrg	FSID	acid;
297ce6676dbSmrg}	AuthContextRec *AuthContextPtr;
298ce6676dbSmrg    </synopsis></para>
299ce6676dbSmrg  </sect1>
300ce6676dbSmrg  <sect1 id='font_path_element_functions'>
301ce6676dbSmrg    <title>Font Path Element functions</title>
302ce6676dbSmrg    <indexterm id='fpe_functions' class='startofrange'>
303ce6676dbSmrg      <primary>Font Path Element</primary></indexterm>
304ce6676dbSmrg    <para>These functions are associated with each renderer, and
305ce6676dbSmrg    handle all aspects of font access. Font data access is
306ce6676dbSmrg    controlled via another set of functions described later. These
307ce6676dbSmrg    functions are intended to support the R5 X server as well as
308ce6676dbSmrg    the font server. As a result, some design decisions were made
309ce6676dbSmrg    to support both models. When the
310ce6676dbSmrg    <emphasis remap='I'>difs</emphasis> layer needs to access a
311ce6676dbSmrg    font, it uses these functions.</para>
312ce6676dbSmrg
313ce6676dbSmrg
314ce6676dbSmrg    <synopsis>
315ce6676dbSmrgtypedef unsigned long Mask;
316ce6676dbSmrgtypedef unsigned char *pointer;
317ce6676dbSmrg
318ce6676dbSmrgtypedef struct _FontPathElement {
319ce6676dbSmrg    int         name_length;
320ce6676dbSmrg    char       *name;
321ce6676dbSmrg    int         type;
322ce6676dbSmrg    int         refcount;
323ce6676dbSmrg    pointer     private;
324ce6676dbSmrg}           FontPathElementRec, *FontPathElementPtr;
325ce6676dbSmrg    </synopsis>
326ce6676dbSmrg
327ce6676dbSmrg
328ce6676dbSmrg    <para>The FPE's reference count is incremented when it is added
329ce6676dbSmrg    to the current list of FPEs and when it opens a font. It is
330ce6676dbSmrg    decremented when it is no longer in the current list and when
331ce6676dbSmrg    it closes a font. All reference changes are handled by the
332ce6676dbSmrg    <emphasis remap='I'>difs</emphasis> layer. The count is required
333ce6676dbSmrg    to support font catalogue changes that may occur while the
334ce6676dbSmrg    fontserver has fonts open, and keeps FPEs from being
335ce6676dbSmrg    lost.</para>
336ce6676dbSmrg
337ce6676dbSmrg
338ce6676dbSmrg    <synopsis>
339ce6676dbSmrgtypedef struct FontNames {
340ce6676dbSmrg    int	nnames;
341ce6676dbSmrg    int	size;
342ce6676dbSmrg    int	*length;
343ce6676dbSmrg    char	**names;
344ce6676dbSmrg}	    FontNamesRec, *FontNamesPtr;
345ce6676dbSmrg
346ce6676dbSmrgtypedef struct {
347ce6676dbSmrg	Bool	(*name_check)();
348ce6676dbSmrg	int	(*init_fpe)();
349ce6676dbSmrg	int	(*reset_fpe)();
350ce6676dbSmrg	int	(*free_fpe)();
351ce6676dbSmrg	int	(*open_font)();
352ce6676dbSmrg	int	(*close_font)();
353ce6676dbSmrg	int	(*list_fonts)();
354ce6676dbSmrg	int	(*start_list_fonts_with_info)();
355ce6676dbSmrg	int	(*list_next_font_with_info)();
356ce6676dbSmrg	int	(*wakeup_fpe)();
357ce6676dbSmrg	int	(*client_died);
358ce6676dbSmrg	FontNamesPtr	renderer_names;
359ce6676dbSmrg} FPEFunctions;
360ce6676dbSmrg
361ce6676dbSmrgint	init_fpe_type(Bool (name_func)(),
362ce6676dbSmrg		int (init_func)(), int (free_func)(), int (reset_func),
363ce6676dbSmrg		int (open_func)(), int (close_func)(),
364ce6676dbSmrg		int (list_func)(),
365ce6676dbSmrg		int (start_lfwi_func)(), int (next_lfwi_func)(),
366ce6676dbSmrg		int (wakeup_func)(),
367ce6676dbSmrg		int (client_died_func)()
368ce6676dbSmrg		)
369ce6676dbSmrg    </synopsis>
370ce6676dbSmrg    <para>This is called by the renderer when it is initialized at
371ce6676dbSmrg    the beginning of time, and sets up an FPEFunctions entry for
372ce6676dbSmrg    the renderer.</para>
373ce6676dbSmrg    <para>The
374ce6676dbSmrg    <emphasis remap='B'>FPEFunctions</emphasis> have the following
375ce6676dbSmrg    parameters:</para>
376ce6676dbSmrg    <para>
377ce6676dbSmrg      <synopsis>
378ce6676dbSmrgBool	name_check(char *<parameter>name</parameter>);
379ce6676dbSmrg      </synopsis>
380ce6676dbSmrg
381ce6676dbSmrg      If <parameter class="function">name</parameter> is something the
382ce6676dbSmrg      renderer recognizes as a valid font source name, it returns
383ce6676dbSmrg      <constant>True</constant>, otherwise <constant>False</constant>.
384ce6676dbSmrg      ie, if <parameter class="function">name</parameter>
385ce6676dbSmrg      is a directory name, or is prefixed by the renderer's prefix,
386ce6676dbSmrg      and the directory contains font data the renderer can interpret,
387ce6676dbSmrg      it would return <constant>True</constant>.
388ce6676dbSmrg    </para>
389ce6676dbSmrg    <para>
390ce6676dbSmrg      <synopsis>
391ce6676dbSmrgint	init_fpe(FontPathElementPtr <parameter>fpe</parameter>);
392ce6676dbSmrg      </synopsis>
393ce6676dbSmrg      Does any initialization work for the renderer. The name in
394ce6676dbSmrg      <parameter class="function">fpe</parameter> will be one whose prefix
395ce6676dbSmrg      matches the list returned when the renderer was initialized.
396ce6676dbSmrg    </para>
397ce6676dbSmrg    <para>
398ce6676dbSmrg      <synopsis>
399ce6676dbSmrgint	reset_fpe(FontPathElementPtr <parameter>fpe</parameter>);
400ce6676dbSmrg      </synopsis>
401ce6676dbSmrg      Tells <parameter class="function">fpe</parameter> to reset any
402ce6676dbSmrg      internal state about what fonts it has available. This will typically be
403ce6676dbSmrg      called because the font server's <emphasis remap='B'>FPE</emphasis>
404ce6676dbSmrg      search list has been changed. The
405ce6676dbSmrg      <parameter class="function">fpe</parameter> should reset any cached state
406ce6676dbSmrg      of available fonts (ie, re-read <filename>fonts.dir</filename>)
407ce6676dbSmrg    </para>
408ce6676dbSmrg    <para>
409ce6676dbSmrg      <synopsis>
410ce6676dbSmrgint	free_fpe(FontPathElementPtr <parameter>fpe</parameter>);
411ce6676dbSmrg      </synopsis>
412ce6676dbSmrg      Frees any renderer-specific data and closes any files or sockets.
413ce6676dbSmrg    </para>
414ce6676dbSmrg    <para>
415ce6676dbSmrg      <synopsis>
416ce6676dbSmrgint	open_font(pointer <parameter>client</parameter>, FontPathElementPtr <parameter>fpe</parameter>, Mask <parameter>flags</parameter>,
417ce6676dbSmrg		  char *<parameter>fontname</parameter>, int <parameter>namelength</parameter>,
418ce6676dbSmrg		  fsBitmapFormat <parameter>format_hint</parameter>, fsBitmapFormatMask <parameter>format_mask</parameter>,
419ce6676dbSmrg		  XID <parameter>fontid</parameter>, FontPtr *<parameter>ppfont</parameter>, char **<parameter>alias</parameter>);
420ce6676dbSmrg      </synopsis>
421ce6676dbSmrg
422ce6676dbSmrg      Opens the font. The bits marked by
423ce6676dbSmrg      <parameter class="function">format_mask</parameter> and
424ce6676dbSmrg      <parameter class="function">format_hint</parameter>
425ce6676dbSmrg      are used where applicable. The resulting FontPtr is returned in
426ce6676dbSmrg      <parameter class="function">ppfont</parameter>. The
427ce6676dbSmrg      <parameter class="function">client</parameter> is optional state
428ce6676dbSmrg      information for use with blocking renderers. If the
429ce6676dbSmrg      <parameter class="function">fontname</parameter> resolves to an
430ce6676dbSmrg      alias, it is returned in <parameter class="function">alias</parameter>
431ce6676dbSmrg      with a <errorcode>FontNameAlias</errorcode> error. This tells
432ce6676dbSmrg      the calling code to start searching again, using
433ce6676dbSmrg      <parameter class="function">alias</parameter> as the font name. The
434ce6676dbSmrg      renderer is expected to fill in any information specified by the
435ce6676dbSmrg      <parameter class="function">flags</parameter>.
436ce6676dbSmrg    </para>
437ce6676dbSmrg    <para>Possible <parameter class="function">flags</parameter> values are:
438ce6676dbSmrg      <synopsis>
439ce6676dbSmrg#define FontLoadInfo    0x0001		/* font header info */
440ce6676dbSmrg#define FontLoadProps   0x0002		/* font properties */
441ce6676dbSmrg#define FontLoadMetrics 0x0004		/* font extents */
442ce6676dbSmrg#define FontLoadBitmaps 0x0008		/* glyph bitmaps */
443ce6676dbSmrg#define FontLoadAll     0x000f
444ce6676dbSmrg#define FontOpenSync    0x0010		/* force synchronous loading */
445ce6676dbSmrg      </synopsis>
446ce6676dbSmrg    </para>
447ce6676dbSmrg
448ce6676dbSmrg    <para>Once a font has been opened, the server may place it and
449ce6676dbSmrg      the pattern it matched into a name cache, to avoid lengthy
450ce6676dbSmrg      searching if the font is reopened. If the renderer does not wish
451ce6676dbSmrg      the font to be in this cache (for licensing reasons), it should
452ce6676dbSmrg      set the font's <emphasis remap='I'>restricted_access</emphasis>
453ce6676dbSmrg      flag.
454ce6676dbSmrg    </para>
455ce6676dbSmrg
456ce6676dbSmrg    <para>
457ce6676dbSmrg      <synopsis>
458ce6676dbSmrgint	close_font(FontPtr <parameter>pfont</parameter>);
459ce6676dbSmrg      </synopsis>
460ce6676dbSmrg
461ce6676dbSmrg      Frees up all the data associated with the font.
462ce6676dbSmrg    </para>
463ce6676dbSmrg
464ce6676dbSmrg    <para>
465ce6676dbSmrg      <synopsis>
466ce6676dbSmrgint	list_fonts(pointer <parameter>client</parameter>, FontPathElementPtr <parameter>fpe</parameter>,
467ce6676dbSmrg		char *<parameter>pattern</parameter>, int <parameter>pattern_length</parameter>, int <parameter>maxnames</parameter>,
468ce6676dbSmrg		FontNamesPtr *<parameter>paths</parameter>);
469ce6676dbSmrg      </synopsis>
470ce6676dbSmrg
471ce6676dbSmrg      Returns in <parameter class="function">paths</parameter> up to
472ce6676dbSmrg      <parameter class="function">maxnames</parameter> font names the fpe
473ce6676dbSmrg      recognizes as matching the given pattern.
474ce6676dbSmrg    </para>
475ce6676dbSmrg
476ce6676dbSmrg    <para>
477ce6676dbSmrg      <synopsis>
478ce6676dbSmrgint	start_list_fonts_with_info(pointer <parameter>client</parameter>,
479ce6676dbSmrg		FontPathElementPtr <parameter>fpe</parameter>, char *<parameter>pattern</parameter>, int <parameter>pattern_length</parameter>,
480ce6676dbSmrg		int <parameter>maxnames</parameter>, pointer <parameter>fpe_data</parameter>);
481ce6676dbSmrg      </synopsis>
482ce6676dbSmrg
483ce6676dbSmrg      Initiates a <systemitem>ListFontsWithXInfo</systemitem>.
484ce6676dbSmrg      Typically, a disk-based renderer will do the equivalent of
485ce6676dbSmrg      <systemitem>ListFonts</systemitem> to gather all the font names
486ce6676dbSmrg      matching the pattern. A font server renderer will send the
487ce6676dbSmrg      request.  <parameter class="function">fpe_data</parameter>
488ce6676dbSmrg      provides a handle for any FPE-private data that needs to be
489ce6676dbSmrg      passed in later via
490ce6676dbSmrg      <function>list_next_font_with_info()</function>, eg, the list of
491ce6676dbSmrg      font names for a disk-based renderer.
492ce6676dbSmrg    </para>
493ce6676dbSmrg
494ce6676dbSmrg    <para>
495ce6676dbSmrg      <synopsis>
496ce6676dbSmrgint	list_next_font_with_info(pointer <parameter>client</parameter>, FontPathElementPtr <parameter>fpe</parameter>,
497ce6676dbSmrg		char **<parameter>name</parameter>, int *<parameter>namelen</parameter>, FontInfoPtr *<parameter>pinfo</parameter>,
498ce6676dbSmrg		int *<parameter>num_fonts</parameter>, pointer <parameter>fpe_data</parameter>);
499ce6676dbSmrg      </synopsis>
500ce6676dbSmrg
501ce6676dbSmrg      Returns the next font's information. The renderer should keep any state
502ce6676dbSmrg      it requires in the <parameter class="function">fpe_data</parameter>
503ce6676dbSmrg      field.  <parameter class="function">num_fonts</parameter> contains the
504ce6676dbSmrg      number of replies remaining.
505ce6676dbSmrg    </para>
506ce6676dbSmrg
507ce6676dbSmrg    <para>These two routines are split for because of the way both
508ce6676dbSmrg      disk-based renderers and font server renderers handle this
509ce6676dbSmrg      request. The first function initiates the action, the second is
510ce6676dbSmrg      used to gather the results. For a disk-based renderer, a list of
511ce6676dbSmrg      font names matching the pattern is first built up when
512ce6676dbSmrg      <function>start_list_fonts_with_info()</function>is called, and
513ce6676dbSmrg      the results are gathered with each call to
514ce6676dbSmrg      <function>list_next_font_with_info()</function>. In a font
515ce6676dbSmrg      server renderer, the first function sends the
516ce6676dbSmrg      <systemitem>ListFontsWithXInfo</systemitem> request, and the
517ce6676dbSmrg      second processes the replies.
518ce6676dbSmrg    </para>
519ce6676dbSmrg
520ce6676dbSmrg    <para>
521ce6676dbSmrg    <synopsis>
522ce6676dbSmrgint	wakeup_fpe(FontPathElementPtr <parameter>fpe</parameter>, unsigned long *<parameter>mask</parameter>)
523ce6676dbSmrg    </synopsis>
524ce6676dbSmrg
525ce6676dbSmrg      Optional function which can be used for blocking
526ce6676dbSmrg      renderers. Typical usage is for a font server renderer, where it
527ce6676dbSmrg      is called when a reply is received, allowing the data to be read
528ce6676dbSmrg      and the client to be signaled and unblocked.
529ce6676dbSmrg    </para>
530ce6676dbSmrg
531ce6676dbSmrg    <para>
532ce6676dbSmrg      <synopsis>
533ce6676dbSmrgint	client_died(pointer <parameter>client</parameter>, FontPathElementPtr <parameter>fpe</parameter>)
534ce6676dbSmrg      </synopsis>
535ce6676dbSmrg
536ce6676dbSmrg
537ce6676dbSmrg      This function is called when a client dies in the middle of a
538ce6676dbSmrg      blocked request, allowing the renderer to clean up.
539ce6676dbSmrg    </para>
540ce6676dbSmrg    <indexterm startref='fpe_functions' class='endofrange' />
541ce6676dbSmrg  </sect1>
542ce6676dbSmrg  <sect1 id='font_specific_functions'>
543ce6676dbSmrg    <title>Font specific functions</title>
544ce6676dbSmrg    <indexterm id='font_functions' class='startofrange'>
545ce6676dbSmrg      <primary><structname>Font</structname></primary></indexterm>
546ce6676dbSmrg    <para>These functions are contained in each
547ce6676dbSmrg    <structname>Font</structname>. For many renderers, every
548ce6676dbSmrg    font will use the same functions, but some renderers may wish
549ce6676dbSmrg    to use different interfaces for different fonts.</para>
550ce6676dbSmrg
551ce6676dbSmrg
552ce6676dbSmrg    <synopsis>
553ce6676dbSmrgtypedef struct {
55476028eb6Smrg	INT16	left,
55576028eb6Smrg		right;
55676028eb6Smrg	INT16	width;
55776028eb6Smrg	INT16	ascent,
55876028eb6Smrg		descent;
55976028eb6Smrg	CARD16	attributes;
560ce6676dbSmrg}	fsCharInfo;
561ce6676dbSmrg
562ce6676dbSmrgtypedef struct {
563ce6676dbSmrg    CARD8	low,
564ce6676dbSmrg		high;
565ce6676dbSmrg}           fsChar2b;
566ce6676dbSmrg
567ce6676dbSmrgtypedef struct {
568ce6676dbSmrg    fsChar2b	min_char,
569ce6676dbSmrg		max_char;
570ce6676dbSmrg}           fsRange;
571ce6676dbSmrg
572ce6676dbSmrgint	get_extents(pointer <parameter>client</parameter>,
573ce6676dbSmrg		FontPtr <parameter>pfont</parameter>, Mask <parameter>flags</parameter>, int <parameter>num_ranges</parameter>, fsRange *<parameter>ranges</parameter>,
574ce6676dbSmrg		int *<parameter>num_extents</parameter>, fsCharInfo **<parameter>extents</parameter>);
575ce6676dbSmrg    </synopsis>
576ce6676dbSmrg
577ce6676dbSmrg
578ce6676dbSmrg    <para>Possible flags:</para>
579ce6676dbSmrg
580ce6676dbSmrg
581ce6676dbSmrg    <synopsis>
582ce6676dbSmrgLoadAll		/* ignore the ranges and get everything */
583ce6676dbSmrgFinishRange	/* magic for range completion as specified by protocol */
584ce6676dbSmrg    </synopsis>
585ce6676dbSmrg
586ce6676dbSmrg
587ce6676dbSmrg    <para>Builds up the requested array of extents. The extent data
588ce6676dbSmrg    (which the renderer allocates) is returned, as well as the
589ce6676dbSmrg    number of extents.
590ce6676dbSmrg    <emphasis remap='I'>closure</emphasis> contains any blocking
591ce6676dbSmrg    state information.</para>
592ce6676dbSmrg
593ce6676dbSmrg    <synopsis>
594ce6676dbSmrg
595ce6676dbSmrg
596ce6676dbSmrgint	get_bitmaps(pointer <parameter>client</parameter>,
597ce6676dbSmrg		FontPtr <parameter>pfont</parameter>, fsBitmapFormat <parameter>format</parameter>, Mask <parameter>flags</parameter>,
598ce6676dbSmrg		int <parameter>num_ranges</parameter>, fsRange *<parameter>ranges</parameter>,
599ce6676dbSmrg		unsigned long *<parameter>size</parameter>, unsigned long *<parameter>num_glyphs</parameter>,
600ce6676dbSmrg		unsigned long **<parameter>offsets</parameter>, pointer *<parameter>glyph_data</parameter>);
601ce6676dbSmrg    </synopsis>
602ce6676dbSmrg
603ce6676dbSmrg
604ce6676dbSmrg    <para>Possible flags:</para>
605ce6676dbSmrg
606ce6676dbSmrg    <synopsis>
607ce6676dbSmrgLoadAll
608ce6676dbSmrgFinishRange	/* magic for range completion as specified by protocol */
609ce6676dbSmrg    </synopsis>
610ce6676dbSmrg
611ce6676dbSmrg
612ce6676dbSmrg    <para>Builds up the requested array of bitmaps. The glyph and
613ce6676dbSmrg    offset data (which the renderer allocates) is returned, as well
614ce6676dbSmrg    as the number of glyphs. The
615ce6676dbSmrg    <emphasis remap='I'>closure</emphasis> contains any blocking
616ce6676dbSmrg    state information. This function will build up the bitmap data
617ce6676dbSmrg    in the format specified by
618ce6676dbSmrg    <parameter class="function">format</parameter> so that the interpreter
619ce6676dbSmrg    can return it without any additional modification. This should
620ce6676dbSmrg    minimize data massaging, since outline renderers will hopefully
621ce6676dbSmrg    be able to produce the bitmaps in the proper format.</para>
622ce6676dbSmrg
623ce6676dbSmrg    <synopsis>
624ce6676dbSmrgvoid	unload_font(FontPtr <parameter>pfont</parameter>)
625ce6676dbSmrg    </synopsis>
626ce6676dbSmrg
627ce6676dbSmrg
628ce6676dbSmrg    <para>The render will free any allocated data. Note that the
629ce6676dbSmrg    <emphasis remap='B'>FPE</emphasis> function
630ce6676dbSmrg    <function>close_font()</function> will also be called, and
631ce6676dbSmrg    should handle any
632ce6676dbSmrg    <emphasis remap='B'>FPE</emphasis> data allocated for the
633ce6676dbSmrg    font.</para>
634ce6676dbSmrg
635ce6676dbSmrg    <synopsis>
636ce6676dbSmrgint	get_glyphs()
637ce6676dbSmrgint	get_metrics()
638ce6676dbSmrg    </synopsis>
639ce6676dbSmrg
640ce6676dbSmrg
641ce6676dbSmrg    <para>These two functions are used by the X server for loading
642ce6676dbSmrg    glyphs and metrics. They expect the results in a considerably
643ce6676dbSmrg    different form. The
644ce6676dbSmrg    <function>get_bitmaps()</function> and
645ce6676dbSmrg    <function>get_extents()</function> routines both allow for
646ce6676dbSmrg    better cache control by the renderer.</para>
647ce6676dbSmrg    <indexterm startref='font_functions' class='endofrange' />
648ce6676dbSmrg  </sect1>
649ce6676dbSmrg  <sect1 id='font_directories_and_aliases'>
650ce6676dbSmrg    <title>Font directories and aliases</title>
651ce6676dbSmrg    <para>Existing bitmap renderers already have their own concept
652ce6676dbSmrg	of font organization. In the X sample server, the files
653ce6676dbSmrg	<filename>fonts.dir</filename> and <filename>fonts.alias</filename>
654ce6676dbSmrg	are used to list the known fonts. <filename>fonts.dir</filename>
655ce6676dbSmrg	maps file names to font names, while <filename>fonts.alias</filename>
656ce6676dbSmrg	maps font names to other font names.
657ce6676dbSmrg    </para>
658ce6676dbSmrg    <para>These concepts will also be needed by other forms of
659ce6676dbSmrg    fonts which the sample X server does not currently use, but the
660ce6676dbSmrg    font server will, like Bitstream outlines.</para>
661ce6676dbSmrg  </sect1>
662ce6676dbSmrg  <sect1 id='handling_scalable_fonts'>
663ce6676dbSmrg    <title>Handling scalable fonts</title>
664ce6676dbSmrg    <para>For those renderers that support scalable fonts, several
665ce6676dbSmrg    issues must be addressed:</para>
666ce6676dbSmrg    <variablelist spacing='compact'>
667ce6676dbSmrg      <varlistentry>
668ce6676dbSmrg        <term><link linkend='name_parsing'>Name Parsing</link>.</term>
669ce6676dbSmrg        <listitem>
670ce6676dbSmrg          <para>An <acronym>XLFD</acronym> name must be parsed to
671ce6676dbSmrg          determine the requested resolutions and/or sizes.</para>
672ce6676dbSmrg        </listitem>
673ce6676dbSmrg      </varlistentry>
674ce6676dbSmrg      <varlistentry>
675ce6676dbSmrg        <term><link linkend='property_scaling'>Property scaling</link>.</term>
676ce6676dbSmrg        <listitem>
677ce6676dbSmrg          <para>Many of the standard font
678ce6676dbSmrg          properties have values that depend on scaling (eg,
679ce6676dbSmrg          <property>RESOLUTION_X</property>,
680ce6676dbSmrg          <property>POINT_SIZE</property>). </para>
681ce6676dbSmrg        </listitem>
682ce6676dbSmrg      </varlistentry>
683ce6676dbSmrg      <varlistentry>
684ce6676dbSmrg        <term><link linkend='default_values'>Default values</link>.</term>
685ce6676dbSmrg        <listitem>
686ce6676dbSmrg          <para>If resolution information is
687ce6676dbSmrg          wildcarded, the proper default resolution should be
688ce6676dbSmrg          supplied.</para>
689ce6676dbSmrg        </listitem>
690ce6676dbSmrg      </varlistentry>
691ce6676dbSmrg    </variablelist>
692ce6676dbSmrg    <sect2 id='name_parsing'>
693ce6676dbSmrg      <title>Name Parsing</title>
694ce6676dbSmrg      <para>The font name pattern supplied to
695ce6676dbSmrg          <systemitem>OpenBitmapFont</systemitem> or
696ce6676dbSmrg          <systemitem>ListFonts</systemitem> may require some
697ce6676dbSmrg          parsing to be recognized as a scalable font known to the
698ce6676dbSmrg          renderer. The
699ce6676dbSmrg          <property>PIXEL_SIZE</property>,
700ce6676dbSmrg          <property>POINT_SIZE</property>,
701ce6676dbSmrg          <property>RESOLUTION_X</property>,
702ce6676dbSmrg          <property>RESOLUTION_Y</property>, and
703ce6676dbSmrg          <property>AVERAGE_WIDTH</property> all need to
704ce6676dbSmrg          determined from the font name pattern. The master font
705ce6676dbSmrg          must then be found, and scaled appropriately. Any
706ce6676dbSmrg          unspecified values that cannot be determined should be
707ce6676dbSmrg          replaced by the proper defaults. For size fields, this is
708ce6676dbSmrg          whatever the configuration specifies. For resolution
709ce6676dbSmrg          fields, these should be taken from the client's
710ce6676dbSmrg          resolution list, if set, or from the server's
711ce6676dbSmrg          configuration.</para>
712ce6676dbSmrg    </sect2>
713ce6676dbSmrg    <sect2 id='property_scaling'>
714ce6676dbSmrg      <title>Property scaling</title>
715ce6676dbSmrg          <para>Part of scaling a font is scaling its properties.
716ce6676dbSmrg          Many scalable fonts will have a very large number of
717ce6676dbSmrg          scalable properties. One way to deal with these is for
718ce6676dbSmrg          the &ldquo;master&rdquo; outline to keep track of the
719ce6676dbSmrg          property names, and supply new values for each instance
720ce6676dbSmrg          of the font. If the property names are stored as Atoms,
721ce6676dbSmrg          memory usage is kept to a minimum.</para>
722ce6676dbSmrg    </sect2>
723ce6676dbSmrg    <sect2 id='default_values'>
724ce6676dbSmrg      <title>Using defaults</title>
725ce6676dbSmrg          <para>Using default values as substitutions for missing
726ce6676dbSmrg          values was covered above. These defaults will also be
727ce6676dbSmrg          useful in handling <systemitem>ListFonts</systemitem> requests.
728ce6676dbSmrg          Returning a scalable font with an instance using the
729ce6676dbSmrg          default values will provide the most user-friendly
730ce6676dbSmrg          environment.</para>
731ce6676dbSmrg    </sect2>
732ce6676dbSmrg  </sect1>
733ce6676dbSmrg  <sect1 id='access_control'>
734ce6676dbSmrg    <title>Access control</title>
735ce6676dbSmrg    <para>The font server will also support large grain security.
736ce6676dbSmrg    It will have both a limit of the number of users, and on the
737ce6676dbSmrg    hosts which it will support.</para>
738ce6676dbSmrg    <para>Limiting the number of users is as much a server loading
739ce6676dbSmrg    issue as a security issue. The limitation will be typically be
740ce6676dbSmrg    set via configuration options or OS limitations. To change it,
741ce6676dbSmrg    use:</para>
742ce6676dbSmrg
743ce6676dbSmrg    <synopsis>
744ce6676dbSmrgvoid	AccessSetConnectionLimit(int <parameter>limit</parameter>)
745ce6676dbSmrg    </synopsis>
746ce6676dbSmrg
747ce6676dbSmrg
748ce6676dbSmrg    <para>A
749ce6676dbSmrg    <parameter class="function">limit</parameter> of 0 will set it to a
750ce6676dbSmrg    compiled constant based on OS resources (eg, number of file
751ce6676dbSmrg    descriptors).</para>
752ce6676dbSmrg
753ce6676dbSmrg    <para>Client-host based access control can be used to
754ce6676dbSmrg      supplement licensing, and support font server load balancing by
755ce6676dbSmrg      restricting access. As with licensing, this is OS-specific
756ce6676dbSmrg      code. To manipulate these functions, use:
757ce6676dbSmrg
758ce6676dbSmrg    <synopsis>
759ce6676dbSmrgtypedef struct _host_address {
760ce6676dbSmrg	int	type;
761ce6676dbSmrg	pointer	address;
762ce6676dbSmrg	struct _host_address *next;
763ce6676dbSmrg} HostAddress;
764ce6676dbSmrg
765ce6676dbSmrgtypedef HostAddress	*HostList;
766ce6676dbSmrg
767ce6676dbSmrgint	AddHost(HostList <parameter>list</parameter>, HostAddress *<parameter>address</parameter>)
768ce6676dbSmrgint	RemoveHost(HostList <parameter>list</parameter>, HostAddress *<parameter>address</parameter>)
769ce6676dbSmrgBool	ValidHost(HostList <parameter>list</parameter>, HostAddress *<parameter>address</parameter>)
770ce6676dbSmrg    </synopsis>
771ce6676dbSmrg
772ce6676dbSmrg
773ce6676dbSmrg      <function>AddHost()</function> adds a host to the
774ce6676dbSmrg      <parameter class="function">list</parameter>.
775ce6676dbSmrg      <function>RemoveHost()</function> removes it, and
776ce6676dbSmrg      <function>ValidHost()</function> checks to see if its on the
777ce6676dbSmrg      <parameter class="function">list</parameter>. In all functions,
778ce6676dbSmrg      the <parameter class="function">address</parameter> will ignore
779ce6676dbSmrg      any value in the <structfield>next</structfield> field.
780ce6676dbSmrg    </para>
781ce6676dbSmrg    <para>Network addresses are used here to avoid issues with host
782ce6676dbSmrg      name aliases. The caller fills in the desired type, and an
783ce6676dbSmrg      address of that form is returned. This is highly OS-specific,
784ce6676dbSmrg      but values for the <structfield>type</structfield> and
785ce6676dbSmrg      <structfield>address</structfield> fields could include:
786ce6676dbSmrg
787ce6676dbSmrg      <synopsis>
788ce6676dbSmrg#define	HOST_AF_INET	1
789ce6676dbSmrgstruct in_addr	*address;
790ce6676dbSmrg
791ce6676dbSmrg#define	HOST_AF_DECnet	2
792ce6676dbSmrgstruct	dn_addr	*address;
793ce6676dbSmrg      </synopsis>
794ce6676dbSmrg    </para>
795ce6676dbSmrg
796ce6676dbSmrg    <para>The server will use a global host list, but having the
797ce6676dbSmrg    list as an argument will allow licensing schemes to have their
798ce6676dbSmrg    own host lists.</para>
799ce6676dbSmrg  </sect1>
800ce6676dbSmrg  <sect1 id='licensing'>
801ce6676dbSmrg    <title>Licensing</title>
802ce6676dbSmrg    <para>Licensing is a tricky issue, which each renderer will
803ce6676dbSmrg    support in a different way. The sample font server will attempt
804ce6676dbSmrg    to provide some guidelines, and present a possible
805ce6676dbSmrg    implementation of some simple licensing schemes.</para>
806ce6676dbSmrg    <sect2>
807ce6676dbSmrg      <title>Host Address licensing</title>
808ce6676dbSmrg      <para>This is simplistic licensing based on the client's host.
809ce6676dbSmrg	    With this form of licensing, a font may be accessible to some
810ce6676dbSmrg	    host but not others. To get the current client's host, the
811ce6676dbSmrg	    following is used:
812ce6676dbSmrg
813ce6676dbSmrg      <synopsis>
814ce6676dbSmrgvoid	GetHostAddress(HostAddress *<parameter>address</parameter>);
815ce6676dbSmrg      </synopsis>
816ce6676dbSmrg
817ce6676dbSmrg            A renderer can also use the host access functions to keep
818ce6676dbSmrg	    a list of the licensed hosts, and <function>ValidHost()</function>
819ce6676dbSmrg	    to check a client.</para>
820ce6676dbSmrg    </sect2>
821ce6676dbSmrg    <sect2>
822ce6676dbSmrg      <title>Simultaneous use license</title>
823ce6676dbSmrg      <para>This licensing allows for a limited number of copies of
824ce6676dbSmrg	    the font to be open at once. Since this should be a simple
825ce6676dbSmrg	    per-font counter, no support should be required outside of the
826ce6676dbSmrg	    renderer.</para>
827ce6676dbSmrg    </sect2>
828ce6676dbSmrg  </sect1>
829ce6676dbSmrg  <sect1 id='difs_contents'>
830ce6676dbSmrg    <title>DIFS contents</title>
831ce6676dbSmrg    <indexterm id='difs_functions' class='startofrange'>
832ce6676dbSmrg	<primary>difs layer</primary></indexterm>
833ce6676dbSmrg    <para>This contains the protocol dispatcher, interpreter and
834ce6676dbSmrg    reply encoding routines.</para>
835ce6676dbSmrg
836ce6676dbSmrg    <para>The interpreter is table driven off the request code. The
837ce6676dbSmrg    dispatcher gets a request from the os layer from
838ce6676dbSmrg    <function>WaitForSomething()</function>, and uses the
839ce6676dbSmrg    request code to determine which function to call. eg, a
840ce6676dbSmrg    <systemitem>CloseFont</systemitem> request would call
841ce6676dbSmrg    <function>ProcCloseFont()</function>.</para>
842ce6676dbSmrg
843ce6676dbSmrg    <para>Each request's routine handles any applicable error
844ce6676dbSmrg    checking, and then does as much work as it can. For font
845ce6676dbSmrg    related requests, this means converting the request to the
846ce6676dbSmrg    proper arguments for the renderers.</para>
847ce6676dbSmrg
848ce6676dbSmrg    <para>If any replies are generated, the reply data is gathered
849ce6676dbSmrg    into the bytestream format, and sent via
850ce6676dbSmrg    <emphasis remap='I'>os</emphasis> write functions to the
851ce6676dbSmrg    client.</para>
852ce6676dbSmrg
853ce6676dbSmrg    <para>If the byte order of the client and server differ, the
854ce6676dbSmrg    above is modified by having the dispatcher call an intermediate
855ce6676dbSmrg    function which re-orders the request to the proper byte order.
856ce6676dbSmrg    Replies go through similar swapping.</para>
857ce6676dbSmrg
858ce6676dbSmrg    <sect2>
859ce6676dbSmrg      <title>Client blocking</title>
860ce6676dbSmrg    <para>To minimize delay caused by font server request, clients
861ce6676dbSmrg    can be blocked while they wait for data to be produced. This is
862ce6676dbSmrg    primarily intended for
863ce6676dbSmrg    <emphasis remap='B'>FPEs</emphasis> using a remote font server,
864ce6676dbSmrg    but can be used anywhere where the font server can pause to
865ce6676dbSmrg    handle other client requests while data needed to satisfy
866ce6676dbSmrg    another is produced (possibly via multiple processes).</para>
867ce6676dbSmrg
868ce6676dbSmrg    <para>
869ce6676dbSmrg      <synopsis>
870ce6676dbSmrgBool	ClientSleep(ClientPtr <parameter>client</parameter>, Bool (*<parameter>function</parameter>)(), pointer <parameter>closure</parameter>)
871ce6676dbSmrg      </synopsis>
872ce6676dbSmrg
873ce6676dbSmrg      Puts a client to 'sleep'. This means the client will no
874ce6676dbSmrg      longer be considered while the server is dispatching requests.
875ce6676dbSmrg      <parameter class="function">function</parameter> will be called
876ce6676dbSmrg      when the client is signaled, with the
877ce6676dbSmrg      <parameter class="function">client</parameter> and
878ce6676dbSmrg      <parameter class="function">closure</parameter> as its arguments.
879ce6676dbSmrg    </para>
880ce6676dbSmrg
881ce6676dbSmrg    <para>
882ce6676dbSmrg      <synopsis>
883ce6676dbSmrg      Bool ClientSignal(ClientPtr <parameter>client</parameter>)
884ce6676dbSmrg      </synopsis>
885ce6676dbSmrg
886ce6676dbSmrg      This should be called when the client is ready to do more
887ce6676dbSmrg      work. At this point, the function given to
888ce6676dbSmrg      <function>ClientSleep()</function> will be called.
889ce6676dbSmrg    </para>
890ce6676dbSmrg
891ce6676dbSmrg    <para>
892ce6676dbSmrg      <synopsis>
893ce6676dbSmrg      void ClientWakeup(ClientPtr <parameter>client</parameter>)
894ce6676dbSmrg      </synopsis>
895ce6676dbSmrg
896ce6676dbSmrg      Puts the client back to its normal state processing requests.
897ce6676dbSmrg    </para>
898ce6676dbSmrg
899ce6676dbSmrg    <para>
900ce6676dbSmrg      <synopsis>
901ce6676dbSmrg      Bool ClientIsAsleep(ClientPtr <parameter>client</parameter>)
902ce6676dbSmrg      </synopsis>
903ce6676dbSmrg
904ce6676dbSmrg
905ce6676dbSmrg      Can be used to check if a client is asleep. This is
906ce6676dbSmrg      useful for handling client termination, so that any requests
907ce6676dbSmrg      the client is waiting upon can be properly cleaned up.
908ce6676dbSmrg    </para>
909ce6676dbSmrg    </sect2>
910ce6676dbSmrg    <sect2>
911ce6676dbSmrg      <title>Sample Usage</title>
912ce6676dbSmrg
913ce6676dbSmrg    <para>For handling a font server renderer request for
914ce6676dbSmrg    <function>OpenBitmapFont</function> the renderer will
915ce6676dbSmrg    send the request to the remote font server, and the call
916ce6676dbSmrg    <function>ClientSleep()</function>. The font server
917ce6676dbSmrg    will then continue processing requests from other clients,
918ce6676dbSmrg    while the one making the request is blocked. When the reply
919ce6676dbSmrg    returns, the renderer will notice when its
920ce6676dbSmrg    <function>wakeup_fpe()</function> function is called. At this
921ce6676dbSmrg    point the font server renderer will read and process the reply,
922ce6676dbSmrg    <function>ClientSignal()</function> will be called,
923ce6676dbSmrg    and the <parameter>closure</parameter> function will be called.
924ce6676dbSmrg    It will request the data from the renderer, completing the
925ce6676dbSmrg    request, and call
926ce6676dbSmrg    <function>ClientWakeup()</function> to return the
927ce6676dbSmrg    client to normal status.</para>
928ce6676dbSmrg
929ce6676dbSmrg    <para>This layer also contains the resource database, which
930ce6676dbSmrg    associates fonts with IDs, extension interface functions and
931ce6676dbSmrg    the server initialization and reset control.</para>
932ce6676dbSmrg    <indexterm startref='difs_functions' class='endofrange' />
933ce6676dbSmrg    </sect2>
934ce6676dbSmrg  </sect1>
935ce6676dbSmrg  <sect1 id='os_contents'>
936ce6676dbSmrg    <title>OS contents</title>
937ce6676dbSmrg    <indexterm id='os_functions' class='startofrange'>
938ce6676dbSmrg      <primary>os layer</primary></indexterm>
939ce6676dbSmrg    <para>This layer contains OS specific routines for
940ce6676dbSmrg    configuration, command line parsing, client/server
941ce6676dbSmrg    communications, and various OS-dependent utilities such as
942ce6676dbSmrg    memory management and error handling.</para>
943ce6676dbSmrg    <para><function>ReadRequestFromClient()</function>
944ce6676dbSmrg    returns a full request to the dispatcher.
945ce6676dbSmrg    <function>WaitForSomething()</function> is where the
946ce6676dbSmrg    server spends its idle time, waiting for any action from a
947ce6676dbSmrg    client or processing any work left from a blocked
948ce6676dbSmrg    client.</para>
949ce6676dbSmrg
950ce6676dbSmrg    <para>When a client attempts to connect, the server will
951ce6676dbSmrg    call
952ce6676dbSmrg
953ce6676dbSmrg      <synopsis>
954ce6676dbSmrgint	CheckClientAuthorization(ClientPtr <parameter>client</parameter>, AuthPtr <parameter>client_auth</parameter>,
955ce6676dbSmrg		int *<parameter>accept</parameter>, int *<parameter>index</parameter>, int *<parameter>size</parameter>, char **<parameter>authdata</parameter>)
956ce6676dbSmrg      </synopsis>
957ce6676dbSmrg
958ce6676dbSmrg      to see if the server is set to allow the client to connect. It
959ce6676dbSmrg      may use licensing or configuration information to determine if
960ce6676dbSmrg      the client can connect.
961ce6676dbSmrg    </para>
962ce6676dbSmrg
963ce6676dbSmrg    <para>When then connection is established, the server will use the
964ce6676dbSmrg
965ce6676dbSmrg      <synopsis>
966ce6676dbSmrgtypedef struct _alt_server {
967ce6676dbSmrg    char        subset;
968ce6676dbSmrg    char        namelen;
969ce6676dbSmrg    char       *name;
970ce6676dbSmrg}           AlternateServerRec, *AlternateServerPtr;
971ce6676dbSmrg
972ce6676dbSmrgint	ListAlternateServers(AlternateServerPtr *<parameter>servers</parameter>)
973ce6676dbSmrg      </synopsis>
974ce6676dbSmrg
975ce6676dbSmrg
976ce6676dbSmrg      to return any alternate server information it may have.
977ce6676dbSmrg    </para>
978ce6676dbSmrg    <para>When the client limit is reached, the font server may
979ce6676dbSmrg    attempt to copy itself, by calling
980ce6676dbSmrg
981ce6676dbSmrg    <synopsis>
982ce6676dbSmrgint	CloneMyself()
983ce6676dbSmrg    </synopsis>
984ce6676dbSmrg
985ce6676dbSmrg
986ce6676dbSmrg    This function will (if the configuration options allow)
987ce6676dbSmrg    start a new font server process. This is done in such a way
988ce6676dbSmrg    that no pending connections should be lost, and that the
989ce6676dbSmrg    original server will accept no new connections. Once the
990ce6676dbSmrg    original server has no more clients, it will exit.</para>
991ce6676dbSmrg
992ce6676dbSmrg    <sect2>
993ce6676dbSmrg      <title>Catalogue manipulation</title>
994ce6676dbSmrg
995ce6676dbSmrg    <para>Catalogues are configuration dependent, and hence sent by
996ce6676dbSmrg    OS-dependent methods. In order for the
997ce6676dbSmrg    <emphasis remap='I'>difs</emphasis> layer to get them, it
998ce6676dbSmrg    uses
999ce6676dbSmrg
1000ce6676dbSmrg      <synopsis>
1001ce6676dbSmrgint	ListCatalogues(char *<parameter>pattern</parameter>, int <parameter>pattern_length</parameter>,
1002ce6676dbSmrg		       int <parameter>maxnames</parameter>, char **<parameter>catalogues</parameter>, int *<parameter>len</parameter>)
1003ce6676dbSmrg      </synopsis>
1004ce6676dbSmrg
1005ce6676dbSmrg      which returns the list of all catalogues it supports which match
1006ce6676dbSmrg      the pattern. This function will be used by the catalogue
1007ce6676dbSmrg      manipulation requests, as well as by renderers when they give
1008ce6676dbSmrg      their <systemitem>ListFonts</systemitem> results.
1009ce6676dbSmrg    </para>
1010ce6676dbSmrg
1011ce6676dbSmrg    <para>
1012ce6676dbSmrg      <synopsis>
1013ce6676dbSmrgint ValidateCatalogues(int <parameter>number</parameter>, char *<parameter>catalogues</parameter>)
1014ce6676dbSmrg      </synopsis>
1015ce6676dbSmrg      Can be used to validate a list of catalogues, returning
1016ce6676dbSmrg      <constant>True</constant> if the list is acceptable.</para>
1017ce6676dbSmrg   <indexterm startref='os_functions' class='endofrange' />
1018ce6676dbSmrg   </sect2>
1019ce6676dbSmrg  </sect1>
1020ce6676dbSmrg  <sect1 id='utility_functions'>
1021ce6676dbSmrg    <title>Utility functions</title>
1022ce6676dbSmrg    <sect2>
1023ce6676dbSmrg      <title>Client data functions</title>
1024ce6676dbSmrg
1025ce6676dbSmrg      <para>These provide access to the current client's resolution
1026ce6676dbSmrg      and authorization data. This form of interface is supplied
1027ce6676dbSmrg      rather than passing it to all renderers in the <emphasis
1028ce6676dbSmrg      remap='B'>FPE</emphasis> functions because the data may be
1029ce6676dbSmrg      complex and/or uninteresting to all renderers.</para>
1030ce6676dbSmrg
1031ce6676dbSmrg      <para><synopsis>
1032ce6676dbSmrgAuthContextPtr	GetClientAuthorization()
1033ce6676dbSmrg      </synopsis>
1034ce6676dbSmrg
1035ce6676dbSmrg      <indexterm><primary><structname>AuthContext</structname></primary></indexterm>
1036ce6676dbSmrg      Returns the authorization data for the current client.</para>
1037ce6676dbSmrg
1038ce6676dbSmrg      <para><synopsis>
1039ce6676dbSmrgfsResolution	*GetClientResolutions(int  *<parameter>num_resolutions</parameter>)
1040ce6676dbSmrg      </synopsis>
1041ce6676dbSmrg
1042ce6676dbSmrg
1043ce6676dbSmrg      Returns the list of resolutions that the current client has set.</para>
1044ce6676dbSmrg    </sect2>
1045ce6676dbSmrg    <sect2>
1046ce6676dbSmrg      <title>Byte swapping</title>
1047ce6676dbSmrg
1048ce6676dbSmrg      <para>Functions for swapping a 4-byte quantity, a 2-byte
1049ce6676dbSmrg      quantity and inverting a byte.</para>
1050ce6676dbSmrg
1051ce6676dbSmrg    <synopsis>
1052ce6676dbSmrgvoid	BitOrderInvert(pointer <parameter>buffer</parameter>, unsigned long <parameter>num_bytes</parameter>)
1053ce6676dbSmrgvoid	TwoByteSwap(pointer <parameter>buffer</parameter>, unsigned long <parameter>num_shorts</parameter>)
1054ce6676dbSmrgvoid	FourByteSwap(pointer <parameter>buffer</parameter>, unsigned long <parameter>num_longs</parameter>)
1055ce6676dbSmrg    </synopsis>
1056ce6676dbSmrg
1057ce6676dbSmrg
1058ce6676dbSmrg    </sect2>
1059ce6676dbSmrg    <sect2>
1060ce6676dbSmrg      <title>Bitmap padding</title>
1061ce6676dbSmrg
1062ce6676dbSmrg      <para>Functions taking a desired extents and a bitmap that will
1063ce6676dbSmrg      return the bitmap properly padded.</para>
1064ce6676dbSmrg
1065ce6676dbSmrg      <para><synopsis>
1066ce6676dbSmrgint	RepadBitmap(pointer <parameter>src</parameter>, pointer <parameter>dst</parameter>, fsFormat <parameter>src_format</parameter>,
1067ce6676dbSmrg		 fsFormat <parameter>dst_format</parameter>, int <parameter>width</parameter>, int <parameter>height</parameter>)
1068ce6676dbSmrg        </synopsis>
1069ce6676dbSmrg
1070ce6676dbSmrg      Takes a bitmap in <parameter class="function">src_format</parameter>
1071ce6676dbSmrg      and converts it to one in
1072ce6676dbSmrg      <parameter class="function">dst_format</parameter>.</para>
1073ce6676dbSmrg
1074ce6676dbSmrg    </sect2>
1075ce6676dbSmrg    <sect2>
1076ce6676dbSmrg      <title>Atoms</title>
1077ce6676dbSmrg
1078ce6676dbSmrg      <para>Existing bitmap-based renderers use atoms to store strings
1079ce6676dbSmrg      for property information. Rather than duplicate this code in
1080ce6676dbSmrg      each renderer, it lives in the
1081ce6676dbSmrg      <filename class="directory">util</filename> directory.</para>
1082ce6676dbSmrg
1083ce6676dbSmrg      <para>Atoms will be especially useful for property information,
1084ce6676dbSmrg      to prevent many copies of the same strings from being saved.
1085ce6676dbSmrg      Using atoms for comparison when modifying properties after
1086ce6676dbSmrg      scaling is also more efficient. Since
1087ce6676dbSmrg      <emphasis remap='I'>atoms</emphasis> will will exist until the
1088ce6676dbSmrg      server is reset, they may want to be used sparingly for property
1089ce6676dbSmrg      values to avoid extraneous string data.</para>
1090ce6676dbSmrg
1091ce6676dbSmrg      <para><synopsis>
1092ce6676dbSmrgtypedef unsigned long	Atom;
1093ce6676dbSmrg
1094ce6676dbSmrgAtom	MakeAtom(char *<parameter>string</parameter>, unsigned int <parameter>length</parameter>, Bool <parameter>create</parameter>)
1095ce6676dbSmrg      </synopsis>
1096ce6676dbSmrg
1097ce6676dbSmrg
1098ce6676dbSmrg        Returns the atom associated with
1099ce6676dbSmrg        <parameter class='function'>string</parameter>. If
1100ce6676dbSmrg        <parameter>create</parameter> is true, a new atom will be
1101ce6676dbSmrg        created.
1102ce6676dbSmrg      </para>
1103ce6676dbSmrg
1104ce6676dbSmrg      <para><synopsis>
1105ce6676dbSmrgchar	*NameForAtom(Atom atom)
1106ce6676dbSmrg      </synopsis>
1107ce6676dbSmrg
1108ce6676dbSmrg        Returns the string associated with
1109ce6676dbSmrg        <parameter class="function">atom</parameter>.
1110ce6676dbSmrg      </para>
1111ce6676dbSmrg    </sect2>
1112ce6676dbSmrg  </sect1>
1113ce6676dbSmrg  <sect1 id='server_request_details'>
1114ce6676dbSmrg    <title>Server request details</title>
1115ce6676dbSmrg    <para>This section describes in-depth the action of each
1116ce6676dbSmrg    protocol request. In all cases, the request is first error
1117ce6676dbSmrg    checked for simple length or value errors, with the server
1118ce6676dbSmrg    immediately returning an error if one is encountered.</para>
1119ce6676dbSmrg    <sect2 id='connection'>
1120ce6676dbSmrg      <title>Connection</title>
1121ce6676dbSmrg      <para>When a new client attempts to connect, the server first
1122ce6676dbSmrg      checks its initial authorization information to see if the
1123ce6676dbSmrg      server is willing to talk to it. This will be handled in some
1124ce6676dbSmrg      OS-specific form using <function>CheckClientAuthorization()</function>.
1125ce6676dbSmrg      If it passes this test, and the server has sufficient to
1126ce6676dbSmrg      resources to talk to it, the server sends accepts the
1127ce6676dbSmrg      connection and returns its connection block. If the
1128ce6676dbSmrg      connection fails, the server returns the proper status and a
1129ce6676dbSmrg      list of any alternate servers it may know of (gathered from
1130ce6676dbSmrg      <function>
1131ce6676dbSmrg      ListAlternateServers().)</function></para>
1132ce6676dbSmrg    </sect2>
1133ce6676dbSmrg    <sect2 id='listextension'>
1134ce6676dbSmrg      <title>ListExtension</title>
1135ce6676dbSmrg      <para>Returns the list of extensions the server knows about.
1136ce6676dbSmrg      Any extensions will be initialized when the server is first
1137ce6676dbSmrg      started.</para>
1138ce6676dbSmrg    </sect2>
1139ce6676dbSmrg    <sect2 id='queryextension'>
1140ce6676dbSmrg      <title>QueryExtension</title>
1141ce6676dbSmrg      <para>Returns the information about the requested extension,
1142ce6676dbSmrg      which was set when the extension was initialized.</para>
1143ce6676dbSmrg    </sect2>
1144ce6676dbSmrg    <sect2 id='listcatalogues'>
1145ce6676dbSmrg      <title>ListCatalogues</title>
1146ce6676dbSmrg      <para>Returns the catalogues the server recognizes (the
1147ce6676dbSmrg      results of <function>ListCatalogues()</function>.)</para>
1148ce6676dbSmrg    </sect2>
1149ce6676dbSmrg    <sect2 id='setcatalogues'>
1150ce6676dbSmrg      <title>SetCatalogues</title>
1151ce6676dbSmrg      <para>Sets the requesting client's catalogues after verifying
1152ce6676dbSmrg      them with the supported catalogues.</para>
1153ce6676dbSmrg    </sect2>
1154ce6676dbSmrg    <sect2 id='getcatalogues'>
1155ce6676dbSmrg      <title>GetCatalogues</title>
1156ce6676dbSmrg      <para>Returns the requesting client's catalogues.</para>
1157ce6676dbSmrg    </sect2>
1158ce6676dbSmrg    <sect2 id='createac'>
1159ce6676dbSmrg      <title>CreateAC</title>
1160ce6676dbSmrg      <para>Creates a new authorization context and fills it in.
1161ce6676dbSmrg      The list of authorization protocols is then checked by the
1162ce6676dbSmrg      server with
1163ce6676dbSmrg      <function>CheckClientAuthorization()</function>. If
1164ce6676dbSmrg      any are accepted, the
1165ce6676dbSmrg      <emphasis remap='B'>AC</emphasis> is placed in the resource
1166ce6676dbSmrg      database and <constant>Success</constant> is returned with the
1167ce6676dbSmrg      name of the accepted protocol. If more than one is accepted,
1168ce6676dbSmrg      <constant>Continue</constant> is returned with each
1169ce6676dbSmrg      of the accepted protocols, until the last one which has
1170ce6676dbSmrg      status <constant>Success</constant>. Otherwise
1171ce6676dbSmrg      <constant>Denied</constant> is returned.</para>
1172ce6676dbSmrg    </sect2>
1173ce6676dbSmrg    <sect2 id='freeac'>
1174ce6676dbSmrg      <title>FreeAC</title>
1175ce6676dbSmrg      <para>Looks up the
1176ce6676dbSmrg      <emphasis remap='B'>AC</emphasis> in the resource database,
1177ce6676dbSmrg      and frees it if it finds it. Otherwise an
1178ce6676dbSmrg      <errorname>Access</errorname> error is returned.</para>
1179ce6676dbSmrg    </sect2>
1180ce6676dbSmrg    <sect2 id='setauthorization'>
1181ce6676dbSmrg      <title>SetAuthorization</title>
1182ce6676dbSmrg     <indexterm><primary><structname>AuthContext</structname></primary></indexterm>
1183ce6676dbSmrg      <para>Looks up the
1184ce6676dbSmrg      <emphasis remap='B'>AC</emphasis> in the resource database,
1185ce6676dbSmrg      and set the client's AuthContextPtr to its value if it is
1186ce6676dbSmrg      found. Otherwise it sends an
1187ce6676dbSmrg      <errorname>Access</errorname> error.</para>
1188ce6676dbSmrg    </sect2>
1189ce6676dbSmrg    <sect2 id='setresolution'>
1190ce6676dbSmrg      <title>SetResolution</title>
1191ce6676dbSmrg      <para>Sets the requesting client's resolution list to the
1192ce6676dbSmrg      supplied list.</para>
1193ce6676dbSmrg    </sect2>
1194ce6676dbSmrg    <sect2 id='getresolution'>
1195ce6676dbSmrg      <title>GetResolution</title>
1196ce6676dbSmrg      <para>Returns the requesting client's list of resolutions.</para>
1197ce6676dbSmrg    </sect2>
1198ce6676dbSmrg    <sect2 id='listfonts'>
1199ce6676dbSmrg      <title>ListFonts</title>
1200ce6676dbSmrg      <para>Iterates over each open FPE, calling the FPE's
1201ce6676dbSmrg      <function>list_fonts()</function>routine passing it the
1202ce6676dbSmrg      pattern. When all FPE's have been processed, the list that
1203ce6676dbSmrg      has been built up is returned. Note that the same
1204ce6676dbSmrg      <structname>FontNamesPtr</structname> is sent to each
1205ce6676dbSmrg      FPE in turn, so that one list is built up. An FPE may
1206ce6676dbSmrg      restrict the fonts it returns based on the client's
1207ce6676dbSmrg      catalogue.</para>
1208ce6676dbSmrg    </sect2>
1209ce6676dbSmrg    <sect2 id='listfontswithxinfo'>
1210ce6676dbSmrg      <title>ListFontsWithXInfo</title>
1211ce6676dbSmrg      <para>Iterates over each FPE, calling its
1212ce6676dbSmrg      <function>start_list_fonts_with_info()</function>function to
1213ce6676dbSmrg      prime the FPE's renderer. It then calls the FPE's
1214ce6676dbSmrg      <function>list_next_font_with_info()</function>, sending each font's
1215ce6676dbSmrg      data to the client until no more fonts remain. When all FPEs
1216ce6676dbSmrg      have been processed, the final reply with a zero-length name
1217ce6676dbSmrg      is then sent to mark the end of the replies. An FPE may
1218ce6676dbSmrg      restrict the fonts it returns based on the client's
1219ce6676dbSmrg      catalogue. Note: an issue exists with font aliases which may
1220ce6676dbSmrg      require this to change, since an FPE may contain an alias
1221ce6676dbSmrg      pointing to another FPE, and cannot therefore return the
1222ce6676dbSmrg      font's info.</para>
1223ce6676dbSmrg    </sect2>
1224ce6676dbSmrg    <sect2 id='openbitmapfont'>
1225ce6676dbSmrg      <title>OpenBitmapFont</title>
1226ce6676dbSmrg      <para>The pattern is first searched for in the font server's
1227ce6676dbSmrg      name cache. If it doesn't find it, the server iterates over
1228ce6676dbSmrg      each FPE, calling its
1229ce6676dbSmrg      <function>open_font</function> function with the
1230ce6676dbSmrg      supplied pattern. This will return one of the following
1231ce6676dbSmrg      values:</para>
1232ce6676dbSmrg      <itemizedlist remap='IP'>
1233ce6676dbSmrg          <listitem>
1234ce6676dbSmrg            <para>an <errorname>Access</errorname> error, which means
1235ce6676dbSmrg            the renderer has the font but the client does not have
1236ce6676dbSmrg            access to it because of some form of licensing
1237ce6676dbSmrg            restriction</para>
1238ce6676dbSmrg          </listitem>
1239ce6676dbSmrg          <listitem>
1240ce6676dbSmrg            <para>a <errorname>Font</errorname> error and a NULL
1241ce6676dbSmrg            <emphasis remap='I'>alias</emphasis> parameter, which
1242ce6676dbSmrg            will cause the next FPE to be tried</para>
1243ce6676dbSmrg          </listitem>
1244ce6676dbSmrg          <listitem>
1245ce6676dbSmrg            <para>a <errorname>Font</errorname> error but a non-NULL
1246ce6676dbSmrg            <emphasis remap='I'>alias</emphasis>, which will cause
1247ce6676dbSmrg            the search to start over with the first FPE using
1248ce6676dbSmrg            <emphasis remap='I'>alias</emphasis> as the new font
1249ce6676dbSmrg            pattern</para>
1250ce6676dbSmrg          </listitem>
1251ce6676dbSmrg          <listitem>
1252ce6676dbSmrg            <para><errorname>Success</errorname>,
1253ce6676dbSmrg            in which case a valid font has been found.</para>
1254ce6676dbSmrg          </listitem>
1255ce6676dbSmrg      </itemizedlist>
1256ce6676dbSmrg
1257ce6676dbSmrg      <para>If the end of the FPE list is reached without having found
1258ce6676dbSmrg        the font, an error is returned to the client. If an
1259ce6676dbSmrg        <errorname>Access</errorname> error was encountered, it is
1260ce6676dbSmrg        returned, otherwise a <errorname>Font</errorname> error is
1261ce6676dbSmrg        returned.  If a valid font is found, its reference count will
1262ce6676dbSmrg        be incremented and it will be checked to see if the client has
1263ce6676dbSmrg        already opened it before. If so, the previous ID will be
1264ce6676dbSmrg        returned. Otherwise the font will be placed in the resource
1265ce6676dbSmrg        database.</para>
1266ce6676dbSmrg
1267ce6676dbSmrg      <para>The renderer will fill in the font's header and property
1268ce6676dbSmrg        information, and may also choose to load or create the font's
1269ce6676dbSmrg        metrics or glyphs. If the glyphs are built, they will use any
1270ce6676dbSmrg        supplied <emphasis remap='I'>format hint</emphasis>.</para>
1271ce6676dbSmrg
127276028eb6Smrg      <para>Whenever a new font is successfully opened, the font and
1273ce6676dbSmrg        its name pattern will be placed in a name cache. This cache
1274ce6676dbSmrg        exists to minimize the amount of work spent searching for a
1275ce6676dbSmrg        font. It will be flushed when the font catalogue is
1276ce6676dbSmrg        modified. Client's with private font catalogues will require
1277ce6676dbSmrg        private name caches.</para>
1278ce6676dbSmrg
1279ce6676dbSmrg    </sect2>
1280ce6676dbSmrg    <sect2 id='queryxinfo'>
1281ce6676dbSmrg      <title>QueryXInfo</title>
1282ce6676dbSmrg      <para>The
1283ce6676dbSmrg      <emphasis remap='I'>fontid</emphasis> is looked up in the
1284ce6676dbSmrg      resource database, and the font's header and property info is
1285ce6676dbSmrg      returned.</para>
1286ce6676dbSmrg    </sect2>
1287ce6676dbSmrg    <sect2 id='queryxextents8_queryxextents16'>
1288ce6676dbSmrg      <title>QueryXExtents8 QueryXExtents16</title>
1289ce6676dbSmrg      <para>The
1290ce6676dbSmrg      <emphasis remap='I'>fontid</emphasis> is looked up in the
1291ce6676dbSmrg      resource database. The supplied list of characters
1292ce6676dbSmrg      (interpreted according to request type) is then translated
1293ce6676dbSmrg      into a list of ranges. The font's
1294ce6676dbSmrg      <function>get_extents()</function>function is then called. It
1295ce6676dbSmrg      builds the requested list of extents, and returns them along
1296ce6676dbSmrg      with the number of extents. The results are properly swapped
1297ce6676dbSmrg      and sent to the client.</para>
1298ce6676dbSmrg    </sect2>
1299ce6676dbSmrg    <sect2 id='queryxbitmaps8_queryxbitmaps16'>
1300ce6676dbSmrg      <title>QueryXBitmaps8 QueryXBitmaps16</title>
1301ce6676dbSmrg      <para>The
1302ce6676dbSmrg      <emphasis remap='I'>fontid</emphasis> is looked up in the
1303ce6676dbSmrg      resource database. The supplied list of characters
1304ce6676dbSmrg      (interpreted according to request type) is then translated
1305ce6676dbSmrg      into a list of ranges. The font's
1306ce6676dbSmrg      <function>get_bitmaps()</function>function is called, and the
1307ce6676dbSmrg      renderer will build up the requested bitmaps, using the
1308ce6676dbSmrg      specified
1309ce6676dbSmrg      <emphasis remap='I'>format</emphasis>, and returns the
1310ce6676dbSmrg      bitmaps, the number of glyphs and the offsets. The offsets
1311ce6676dbSmrg      are properly swapped and the offsets and bitmaps are sent to
1312ce6676dbSmrg      the clients.</para>
1313ce6676dbSmrg    </sect2>
1314ce6676dbSmrg    <sect2 id='closefont'>
1315ce6676dbSmrg      <title>CloseFont</title>
1316ce6676dbSmrg      <para>The font's reference count is decremented. If this was
1317ce6676dbSmrg      the last reference, the font's
1318ce6676dbSmrg      <function>unload_font()</function>function is called to free
1319ce6676dbSmrg      the renderer's data, and the font's FPE
1320ce6676dbSmrg      <function>close_font()</function>function is called to free
1321ce6676dbSmrg      up any FPE specific data.</para>
1322ce6676dbSmrg    </sect2>
1323ce6676dbSmrg  </sect1>
1324ce6676dbSmrg  <sect1 id='configuration'>
1325ce6676dbSmrg    <title>Configuration</title>
1326ce6676dbSmrg	<indexterm><primary>configuration file</primary></indexterm>
1327ce6676dbSmrg    <para>The configuration mechanism is a simple keyword-value
1328ce6676dbSmrg    pair, separated by an '<literal>=</literal>'.</para>
1329ce6676dbSmrg    <variablelist>
1330ce6676dbSmrg      <title>Configuration types:</title>
1331ce6676dbSmrg      <varlistentry>
1332ce6676dbSmrg	<term><type>cardinal</type></term>
1333ce6676dbSmrg	<listitem><para>non-negative number</para></listitem>
1334ce6676dbSmrg      </varlistentry>
1335ce6676dbSmrg      <varlistentry>
1336ce6676dbSmrg	<term><type>boolean</type></term>
1337ce6676dbSmrg	<listitem><para>"[Yy]es", "[Yy]" "on", "1", "[Nn]o", "[Nn]", "off", "0"</para></listitem>
1338ce6676dbSmrg      </varlistentry>
1339ce6676dbSmrg      <varlistentry>
1340ce6676dbSmrg	<term><type>resolution</type></term>
1341ce6676dbSmrg	<listitem><para><type>cardinal</type><literal>,</literal><type>cardinal</type></para></listitem>
1342ce6676dbSmrg      </varlistentry>
1343ce6676dbSmrg      <varlistentry>
1344ce6676dbSmrg	<term><type>list of foo</type></term>
1345ce6676dbSmrg	<listitem><para>1 or more of foo, separated by commas</para></listitem>
1346ce6676dbSmrg      </varlistentry>
1347ce6676dbSmrg    </variablelist>
1348ce6676dbSmrg    <variablelist>
1349ce6676dbSmrg      <title>Here is an incomplete list of the supported keywords:</title>
1350ce6676dbSmrg      <varlistentry>
1351ce6676dbSmrg	<term><literal>#</literal></term>
1352ce6676dbSmrg	<listitem><para>in the first column, a comment character</para></listitem>
1353ce6676dbSmrg      </varlistentry>
1354ce6676dbSmrg<!--
1355ce6676dbSmrg      <varlistentry>
1356ce6676dbSmrg	<term><literal>cache-size</literal> <type>(cardinal)</type></term>
1357ce6676dbSmrg	<listitem><para>Size in bytes of the FS cache.r</para></listitem>
1358ce6676dbSmrg      </varlistentry>
1359ce6676dbSmrg -->
1360ce6676dbSmrg      <varlistentry>
1361ce6676dbSmrg	<term><literal>catalogue</literal> <type>(list of string)</type></term>
1362ce6676dbSmrg	<listitem><para>Ordered list of font path element names.</para></listitem>
1363ce6676dbSmrg      </varlistentry>
1364ce6676dbSmrg      <varlistentry>
1365ce6676dbSmrg	<term><literal>alternate-servers</literal> <type>(list of string)</type></term>
1366ce6676dbSmrg	<listitem><para>List of alternate servers for this FS.</para></listitem>
1367ce6676dbSmrg      </varlistentry>
1368ce6676dbSmrg      <varlistentry>
1369ce6676dbSmrg	<term><literal>client-limit</literal> <type>(cardinal)</type></term>
1370ce6676dbSmrg	<listitem><para>Number of clients this FS will support before refusing
1371ce6676dbSmrg		service.</para></listitem>
1372ce6676dbSmrg      </varlistentry>
1373ce6676dbSmrg      <varlistentry>
1374ce6676dbSmrg	<term><literal>clone-self</literal> <type>(boolean)</type></term>
1375ce6676dbSmrg	<listitem><para>Whether this FS should attempt to clone itself or
137676028eb6Smrg		use delegates when it reaches the client-limit.</para></listitem>
1377ce6676dbSmrg      </varlistentry>
1378ce6676dbSmrg      <varlistentry>
1379ce6676dbSmrg	<term><literal>default-point-size</literal> <type>(cardinal)</type></term>
1380ce6676dbSmrg	<listitem><para>The default pointsize (in decipoints) for fonts that
1381ce6676dbSmrg		don't specify.</para></listitem>
1382ce6676dbSmrg      </varlistentry>
1383ce6676dbSmrg      <varlistentry>
1384ce6676dbSmrg	<term><literal>default-resolutions</literal> <type>(list of resolutions)</type></term>
1385ce6676dbSmrg	<listitem><para>Resolutions the server supports by default.
1386ce6676dbSmrg		This information may be used as a hint for pre-rendering.</para></listitem>
1387ce6676dbSmrg      </varlistentry>
1388ce6676dbSmrg      <varlistentry>
1389ce6676dbSmrg	<term><literal>error-file</literal> <type>(string)</type></term>
1390ce6676dbSmrg	<listitem><para>Filename of the error file.  All warnings and errors
1391ce6676dbSmrg		will be logged here. This information may be used as a hint
1392ce6676dbSmrg		for pre-rendering.</para></listitem>
1393ce6676dbSmrg      </varlistentry>
1394ce6676dbSmrg      <varlistentry>
1395ce6676dbSmrg	<term><literal>port</literal> <type>(cardinal)</type></term>
1396ce6676dbSmrg	<listitem><para>
1397ce6676dbSmrg		The TCP port on which the server will listen for connections.
1398ce6676dbSmrg	</para></listitem>
1399ce6676dbSmrg      </varlistentry>
1400ce6676dbSmrg      <varlistentry>
1401ce6676dbSmrg	<term><literal>use-syslog</literal> <type>(boolean)</type></term>
1402ce6676dbSmrg	<listitem><para>
1403ce6676dbSmrg		Whether syslog(3) is to be used for errors.
1404ce6676dbSmrg	</para></listitem>
1405ce6676dbSmrg      </varlistentry>
1406ce6676dbSmrg<!--
1407ce6676dbSmrg      <varlistentry>
1408ce6676dbSmrg	<term><literal>trusted-clients</literal> <type>(list of string)</type></term>
1409ce6676dbSmrg	<listitem><para>
1410ce6676dbSmrg		Those clients the fontserver will talk to.  Others
1411ce6676dbSmrg		will be refused for the initial connection.  An empty
1412ce6676dbSmrg		list means the server will talk to any client.
1413ce6676dbSmrg	</para></listitem>
1414ce6676dbSmrg      </varlistentry>
1415ce6676dbSmrg -->
1416ce6676dbSmrg    </variablelist>
1417ce6676dbSmrg    <para>Each renderer may also want private configuration
1418ce6676dbSmrg    options. The names should be prefixed by the renderer name, ie
1419ce6676dbSmrg    <literal>pcf-</literal>, <literal>atm-</literal>.</para>
1420ce6676dbSmrg    <example>
1421ce6676dbSmrg      <title>Sample Configuration Entries:</title>
1422ce6676dbSmrg      <programlisting>
1423ce6676dbSmrg# allow a ~a megabyte of memory to be reserved for cache data
1424ce6676dbSmrgcache-size = 1000000
1425ce6676dbSmrg
1426ce6676dbSmrgcatalogue = pcf:/usr/lib/X11/fonts/misc,speedo:/usr/lib/fonts/speedo
1427ce6676dbSmrg      </programlisting>
1428ce6676dbSmrg    </example>
1429ce6676dbSmrg  </sect1>
1430ce6676dbSmrg  <index/>
1431ce6676dbSmrg</article>
1432