1a96d7823Smrg<?xml version="1.0" encoding="UTF-8" ?> 2a96d7823Smrg<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 3a96d7823Smrg "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" 4a96d7823Smrg[ 5a96d7823Smrg<!ENTITY % defs SYSTEM "defs.ent"> %defs; 6a96d7823Smrg]> 7a96d7823Smrg<!-- lifted from troff+ms by doclifter --> 8a96d7823Smrg<!-- previous version was in xorg-docs/specs/Xserver/fontlib.ms --> 9a96d7823Smrg 10a96d7823Smrg <article id='fontlib'> 11a96d7823Smrg<!-- .ps 12 --> 12a96d7823Smrg<!-- .EF 'Font Library Interface'\- % \-'July 27, 1991' --> 13a96d7823Smrg<!-- .OF 'Font Library Interface'\- % \-'July 27, 1991' --> 14a96d7823Smrg<!-- .EH '''' --> 15a96d7823Smrg<!-- .OH '''' --> 16a96d7823Smrg<!-- body begins here --> 17a96d7823Smrg <articleinfo> 18a96d7823Smrg <title> 19a96d7823Smrg The X Font Library 20a96d7823Smrg </title> 21a96d7823Smrg <authorgroup> 22a96d7823Smrg <author> 23a96d7823Smrg <firstname>Keith</firstname> 24a96d7823Smrg <surname>Packard</surname> 25a96d7823Smrg <affiliation> 26a96d7823Smrg <orgname>MIT X Consortium</orgname> 27a96d7823Smrg </affiliation> 28a96d7823Smrg </author> 29a96d7823Smrg <author> 30a96d7823Smrg <firstname>David</firstname> 31a96d7823Smrg <surname>Lemke</surname> 32a96d7823Smrg <affiliation> 33a96d7823Smrg <orgname>Network Computing Devices</orgname> 34a96d7823Smrg </affiliation> 35a96d7823Smrg </author> 36a96d7823Smrg </authorgroup> 37a96d7823Smrg <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo> 38a96d7823Smrg <copyright><year>1993</year><holder>Network Computing Devices</holder></copyright> 39a96d7823Smrg 40a96d7823Smrg <legalnotice> 41a96d7823Smrg <para> 42a96d7823Smrg Permission to use, copy, modify, distribute, and sell this 43a96d7823Smrg software and its documentation for any purpose is hereby 44a96d7823Smrg granted without fee, provided that the above copyright 45a96d7823Smrg notice appear in all copies and that both that copyright 46a96d7823Smrg notice and this permission notice appear in supporting 47a96d7823Smrg documentation, and that the name of Network Computing 48a96d7823Smrg Devices not be used in advertising or publicity pertaining 49a96d7823Smrg to distribution of the software without specific, written 50a96d7823Smrg prior permission. Network Computing Devices makes no 51a96d7823Smrg representations about the suitability of this software for 52a96d7823Smrg any purpose. It is provided “as is” without 53a96d7823Smrg express or implied warranty. 54a96d7823Smrg </para> 55a96d7823Smrg <para role="multiLicensing"> 56a96d7823Smrg Copyright © 1993, 1994 X Consortium 57a96d7823Smrg </para> 58a96d7823Smrg <para> 59a96d7823Smrg Permission is hereby granted, free of charge, to any person 60a96d7823Smrg obtaining a copy of this software and associated 61a96d7823Smrg documentation files (the “Software”), to deal in the 62a96d7823Smrg Software without restriction, including without limitation 63a96d7823Smrg the rights to use, copy, modify, merge, publish, distribute, 64a96d7823Smrg sublicense, and/or sell copies of the Software, and to 65a96d7823Smrg permit persons to whom the Software is furnished to do so, 66a96d7823Smrg subject to the following conditions: 67a96d7823Smrg </para><para> 68a96d7823Smrg The above copyright notice and this permission notice shall be 69a96d7823Smrg included in all copies or substantial portions of the Software. 70a96d7823Smrg </para><para> 71a96d7823Smrg THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY 72a96d7823Smrg OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 73a96d7823Smrg THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 74a96d7823Smrg PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X 75a96d7823Smrg CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 76a96d7823Smrg LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 77a96d7823Smrg OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 78a96d7823Smrg SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 79a96d7823Smrg </para><para> 80a96d7823Smrg Except as contained in this notice, the name of the X 81a96d7823Smrg Consortium shall not be used in advertising or otherwise to 82a96d7823Smrg promote the sale, use or other dealings in this Software 83a96d7823Smrg without prior written authorization from the X Consortium. 84a96d7823Smrg </para> 85a96d7823Smrg <para>X Window System is a trademark of The Open Group.</para> 86a96d7823Smrg </legalnotice> 87a96d7823Smrg <pubdate>July 27, 1991</pubdate> 88a96d7823Smrg </articleinfo> 89a96d7823Smrg 90a96d7823Smrg <warning> 91a96d7823Smrg <para> 92a96d7823Smrg This document has not been updated since X11R6, and is likely 93a96d7823Smrg to be somewhat out of date for the current libXfont. 94a96d7823Smrg </para> 95a96d7823Smrg </warning> 96a96d7823Smrg 97a96d7823Smrg <para> 98a96d7823Smrg This document describes the data structures and interfaces for 99a96d7823Smrg using the X Font library. It is intended as a reference for 100a96d7823Smrg programmers building X and Font servers. You may want to refer 101a96d7823Smrg to the following documents: 102a96d7823Smrg </para> 103a96d7823Smrg 104a96d7823Smrg <itemizedlist> 105a96d7823Smrg <listitem> 106a96d7823Smrg <para> 107a96d7823Smrg <citetitle pubwork="article">Definition of the Porting Layer for 108a96d7823Smrg the X v11 Sample Server</citetitle> for a discussion on how this 109a96d7823Smrg library interacts with the X server 110a96d7823Smrg </para> 111a96d7823Smrg </listitem> 112a96d7823Smrg <listitem> 113a96d7823Smrg <para> 114a96d7823Smrg <olink targetdoc='xfs-design' targetptr='xfs-design'> 115a96d7823Smrg <citetitle pubwork="article">Font Server Implementation 116a96d7823Smrg Overview</citetitle></olink> which discusses the design of the font 117a96d7823Smrg server. 118a96d7823Smrg </para> 119a96d7823Smrg </listitem> 120a96d7823Smrg <listitem> 121a96d7823Smrg <para> 122a96d7823Smrg <citetitle pubwork="article">Bitmap Distribution Format</citetitle> 123a96d7823Smrg which covers the contents of the bitmap font files which this 124a96d7823Smrg library reads; although the library is capable of reading other 125a96d7823Smrg formats as well, including non-bitmap fonts. 126a96d7823Smrg </para> 127a96d7823Smrg </listitem> 128a96d7823Smrg <listitem> 129a96d7823Smrg <para> 130a96d7823Smrg <olink targetdoc='fsproto' targetptr='fsproto'> 131a96d7823Smrg <citetitle pubwork="article">The X Font Service Protocol</citetitle> 132a96d7823Smrg </olink> 133a96d7823Smrg for a description of the constraints placed on the design by 134a96d7823Smrg including support for this font service mechanism. 135a96d7823Smrg </para> 136a96d7823Smrg </listitem> 137a96d7823Smrg </itemizedlist> 138a96d7823Smrg 139a96d7823Smrg <para> 140a96d7823Smrg This document assumes the reader is familiar with the X server design, 141a96d7823Smrg the X protocol as it relates to fonts and the C programming language. 142a96d7823Smrg As with most MIT produced documentation, this relies heavily on the 143a96d7823Smrg source code, so have a listing handy. 144a96d7823Smrg </para> 145a96d7823Smrg 146a96d7823Smrg <sect1 id='Requirements_for_the_Font_library'> 147a96d7823Smrg<title>Requirements for the Font library</title> 148a96d7823Smrg 149a96d7823Smrg <para> 150a96d7823Smrg To avoid miles of duplicate code in the X server, the font server 151a96d7823Smrg and the various font manipulation tools, the font library should 152a96d7823Smrg provide interfaces appropriate for all of these tasks. In 153a96d7823Smrg particular, the X server and font server should be able to both 154a96d7823Smrg use the library to access disk based fonts, and to communicate 155a96d7823Smrg with a font server. By providing a general library, we hoped to 156a96d7823Smrg avoid duplicating code between the X server and font server. 157a96d7823Smrg </para> 158a96d7823Smrg 159a96d7823Smrg <para> 160a96d7823Smrg Another requirement is that the X server (or even a font server) 161a96d7823Smrg be able to continue servicing requests from other clients while 162a96d7823Smrg awaiting a response from the font server on behalf of one client. 163a96d7823Smrg This is the strongest requirement placed on the font library, and 164a96d7823Smrg has warped the design in curious ways. Because both the X server 165a96d7823Smrg and font server are single threaded, the font library must not 166a96d7823Smrg suspend internally, rather it returns an indication of suspension 167a96d7823Smrg to the application which continues processing other things, until 168a96d7823Smrg the font data is ready, at which time it restarts the suspended 169a96d7823Smrg request. 170a96d7823Smrg </para> 171a96d7823Smrg 172a96d7823Smrg <para> 173a96d7823Smrg Because the code for reading and manipulating bitmap font data is 174a96d7823Smrg used by the font applications <command>mkfontdir</command> and 175a96d7823Smrg <command>bdftopcf</command>, the font library includes 176a96d7823Smrg bitmap-font specific interfaces which those applications use, 177a96d7823Smrg instead of the more general interfaces used by the X and font 178a96d7823Smrg servers, which are unaware of the source of the font data. 1799c9cb266Smrg These routines will be referred to as the bitmap font access 180a96d7823Smrg methods. 181a96d7823Smrg </para> 182a96d7823Smrg 183a96d7823Smrg </sect1> 184a96d7823Smrg 185a96d7823Smrg <sect1 id='General_Font_Library_Interface_details'> 186a96d7823Smrg<title>General Font Library Interface details.</title> 187a96d7823Smrg 188a96d7823Smrg <para> 189a96d7823Smrg To avoid collision between the #define name space for errors, the Font 190a96d7823Smrg library defines a new set of return values: 191a96d7823Smrg </para> 192a96d7823Smrg 193a96d7823Smrg <programlisting remap='.nf'> 194a96d7823Smrg#define AllocError 80 195a96d7823Smrg#define StillWorking 81 196a96d7823Smrg#define FontNameAlias 82 197a96d7823Smrg#define BadFontName 83 198a96d7823Smrg#define Suspended 84 199a96d7823Smrg#define Successful 85 200a96d7823Smrg#define BadFontPath 86 201a96d7823Smrg#define BadCharRange 87 202a96d7823Smrg#define BadFontFormat 88 203a96d7823Smrg#define FPEResetFailed 89 204a96d7823Smrg </programlisting> <!-- .fi --> 205a96d7823Smrg 206a96d7823Smrg <para> 207a96d7823Smrg Whenever a routine returns <errorname>Suspended</errorname>, 208a96d7823Smrg the font library will notify the caller (via the ClientSignal 209a96d7823Smrg interface described below) who should then reinvoke the same routine 210a96d7823Smrg again with the same arguments. 211a96d7823Smrg </para> 212a96d7823Smrg 213a96d7823Smrg </sect1> 214a96d7823Smrg 215a96d7823Smrg <sect1 id='Font_Path_Elements'> 216a96d7823Smrg<title>Font Path Elements</title> 217a96d7823Smrg 218a96d7823Smrg <para> 219a96d7823Smrg At the center of the general font access methods used by X and 220a96d7823Smrg <command>xfs</command> is the Font Path Element data structure. 221a96d7823Smrg Like most structures in the X server, this contains a collection 222a96d7823Smrg of data and some function pointers for manipulating this data: 223a96d7823Smrg </para> 224a96d7823Smrg 225a96d7823Smrg <programlisting remap='.nf'> 226a96d7823Smrg/* External view of font paths */ 227a96d7823Smrgtypedef struct _FontPathElement { 228a96d7823Smrg int name_length; 229a96d7823Smrg char *name; 230a96d7823Smrg int type; 231a96d7823Smrg int refcount; 232a96d7823Smrg pointer private; 233a96d7823Smrg} FontPathElementRec, *FontPathElementPtr; 234a96d7823Smrg 235a96d7823Smrgtypedef struct _FPEFunctions { 236a96d7823Smrg int (*name_check) ( /* name */ ); 237a96d7823Smrg int (*init_fpe) ( /* fpe */ ); 238a96d7823Smrg int (*reset_fpe) ( /* fpe */ ); 239a96d7823Smrg int (*free_fpe) ( /* fpe */ ); 240a96d7823Smrg int (*open_font) ( /* client, fpe, flags, 241a96d7823Smrg name, namelen, format, 242a96d7823Smrg fid, ppfont, alias */ ); 243a96d7823Smrg int (*close_font) ( /* pfont */ ); 244a96d7823Smrg int (*list_fonts) ( /* client, fpe, pattern, 245a96d7823Smrg patlen, maxnames, paths */ ); 246a96d7823Smrg int (*start_list_fonts_with_info) ( 247a96d7823Smrg /* client, fpe, name, namelen, 248a96d7823Smrg maxnames, data */ ); 249a96d7823Smrg int (*list_next_font_with_info) ( 250a96d7823Smrg /* client, fpe, name, namelen, 251a96d7823Smrg info, num, data */ ); 252a96d7823Smrg int (*wakeup_fpe) ( /* fpe, mask */ ); 253a96d7823Smrg int (*client_died) ( /* client, fpe */ ); 254a96d7823Smrg} FPEFunctionsRec, FPEFunctions; 255a96d7823Smrg </programlisting> <!-- .fi --> 256a96d7823Smrg 257a96d7823Smrg <para> 258a96d7823Smrg The function pointers are split out from the data structure to 259a96d7823Smrg save memory; additionally, this avoids any complications when 260a96d7823Smrg initializing the data structure as there would not be any way 261a96d7823Smrg to discover the appropriate function to call (a chicken and 262a96d7823Smrg egg problem). 263a96d7823Smrg </para> 264a96d7823Smrg 265a96d7823Smrg <para> 266a96d7823Smrg When a font path type is initialized, it passes the function 267a96d7823Smrg pointers to the server which are then stored in an 268a96d7823Smrg <structname>FPEFunctionsRec</structname>. Each function is 269a96d7823Smrg described below in turn. 270a96d7823Smrg </para> 271a96d7823Smrg 272a96d7823Smrg <sect2 id='name_check'> 273a96d7823Smrg <title>(*name_check)</title> 274a96d7823Smrg 275a96d7823Smrg <para> 276a96d7823Smrg Each new font path member is passed to this function; if 277a96d7823Smrg the return value is <errorname>Successful</errorname>, then 278a96d7823Smrg the FPE recognises the format of the string. This does not 279a96d7823Smrg guarantee that the FPE will be able to successfully use this 280a96d7823Smrg member. For example, the disk-based font directory file 281a96d7823Smrg <filename>fonts.dir</filename> may be corrupted, this will 282a96d7823Smrg not be detected until the font path is initialized. This 283a96d7823Smrg routine never returns <errorname>Suspended</errorname>. 284a96d7823Smrg </para> 285a96d7823Smrg </sect2> 286a96d7823Smrg 287a96d7823Smrg <sect2 id='init_fpe'> 288a96d7823Smrg <title>(*init_fpe)</title> 289a96d7823Smrg 290a96d7823Smrg <para> 291a96d7823Smrg Initialize a new font path element. This function prepares 292a96d7823Smrg a new font path element for other requests: the disk font 293a96d7823Smrg routine reads the <filename>fonts.dir</filename> and 294a96d7823Smrg <filename>fonts.alias</filename> files into the internal 295a96d7823Smrg format, while the font server routine connects to the 296a96d7823Smrg requested font server and prepares for using it. This 297a96d7823Smrg routine returns <errorname>Successful</errorname> if 298a96d7823Smrg everything went OK, otherwise the return value indicates the 299a96d7823Smrg source of the problem. This routine never returns 300a96d7823Smrg <errorname>Suspended</errorname>. 301a96d7823Smrg </para> 302a96d7823Smrg </sect2> 303a96d7823Smrg 304a96d7823Smrg <sect2 id='reset_fpe'> 305a96d7823Smrg <title>(*reset_fpe)</title> 306a96d7823Smrg 307a96d7823Smrg <para> 308a96d7823Smrg When the X font path is reset, and some of the new members 309a96d7823Smrg are also in the old font path, this function is called to 310a96d7823Smrg reinitialize those FPEs. This routine returns 311a96d7823Smrg <errorname>Successful</errorname> if everything went OK. It 312a96d7823Smrg returns <errorname>FPEResetFailed</errorname> if (for some 313a96d7823Smrg reason) the reset failed, and the caller should remove the 314a96d7823Smrg old FPE and simply create a new one in its place. This is 315a96d7823Smrg used by the disk-based fonts routine as resetting the 316a96d7823Smrg internal directory structures would be more complicated than 317a96d7823Smrg simply having destroying the old and creating a new. 318a96d7823Smrg </para> 319a96d7823Smrg </sect2> 320a96d7823Smrg 321a96d7823Smrg <sect2 id='free_fpe'> 322a96d7823Smrg <title>(*free_fpe)</title> 323a96d7823Smrg 324a96d7823Smrg <para> 325a96d7823Smrg When the server is finished with an FPE, this function is 326a96d7823Smrg called to dispose of any internal state. It should return 327a96d7823Smrg <errorname>Successful</errorname>, unless something terrible 328a96d7823Smrg happens. 329a96d7823Smrg </para> 330a96d7823Smrg </sect2> 331a96d7823Smrg 332a96d7823Smrg <sect2 id='open_font'> 333a96d7823Smrg <title>(*open_font)</title> 334a96d7823Smrg 335a96d7823Smrg <para> 336a96d7823Smrg This routine requests that a font be opened. The <parameter 337a96d7823Smrg class='function'>client</parameter> argument is used by the 338a96d7823Smrg font library only in connection with suspending/restarting 339a96d7823Smrg the request. The <parameter class='function'>flags</parameter> 340a96d7823Smrg argument specifies some behaviour for the library and can be 341a96d7823Smrg any of: 342a96d7823Smrg </para> 343a96d7823Smrg 344a96d7823Smrg <programlisting remap='.nf'> 345a96d7823Smrg/* OpenFont flags */ 346a96d7823Smrg#define FontLoadInfo 0x0001 347a96d7823Smrg#define FontLoadProps 0x0002 348a96d7823Smrg#define FontLoadMetrics 0x0004 349a96d7823Smrg#define FontLoadBitmaps 0x0008 350a96d7823Smrg#define FontLoadAll 0x000f 351a96d7823Smrg#define FontOpenSync 0x0010 352a96d7823Smrg </programlisting> <!-- .fi --> 353a96d7823Smrg 354a96d7823Smrg <para> 355a96d7823Smrg The various fields specify which portions of the font should 356a96d7823Smrg be loaded at this time. When <constant>FontOpenSync</constant> 357a96d7823Smrg is specified, this routine will not return until all of the 358a96d7823Smrg requested portions are loaded. Otherwise, this routine may 359a96d7823Smrg return <errorname>Suspended</errorname>. When the presented 360a96d7823Smrg font name is actually an alias for some other font name, 361a96d7823Smrg <errorname>FontNameAlias</errorname> is returned, and the 362a96d7823Smrg actual font name is stored in the location pointed to by the 363a96d7823Smrg <parameter class='function'>alias</parameter> argument as a 364a96d7823Smrg null-terminated string. 365a96d7823Smrg </para> 366a96d7823Smrg </sect2> 367a96d7823Smrg 368a96d7823Smrg <sect2 id='close_font'> 369a96d7823Smrg <title>(*close_font)</title> 370a96d7823Smrg 371a96d7823Smrg <para> 372a96d7823Smrg When the server is finished with a font, this routine 373a96d7823Smrg disposes of any internal state and frees the font data 374a96d7823Smrg structure. 375a96d7823Smrg </para> 376a96d7823Smrg </sect2> 377a96d7823Smrg 378a96d7823Smrg <sect2 id='list_fonts'> 379a96d7823Smrg <title>(*list_fonts)</title> 380a96d7823Smrg 381a96d7823Smrg <para> 382a96d7823Smrg The <parameter class='function'>paths</parameter> argument is 383a96d7823Smrg a data structure which will be filled with all of the font names 384a96d7823Smrg from this directory which match the specified 385a96d7823Smrg <parameter class='function'>pattern</parameter>. At 386a96d7823Smrg most <parameter class='function'>maxnames</parameter> will be added. 387a96d7823Smrg This routine may return <errorname>Suspended</errorname>. 388a96d7823Smrg </para> 389a96d7823Smrg </sect2> 390a96d7823Smrg 391a96d7823Smrg <sect2 id='start_list_fonts_with_info'> 392a96d7823Smrg <title>(*start_list_fonts_with_info)</title> 393a96d7823Smrg 394a96d7823Smrg <para> 395a96d7823Smrg This routine sets any internal state for a verbose listing of 396a96d7823Smrg all fonts matching the specified pattern. This routine may 397a96d7823Smrg return <errorname>Suspended</errorname>. 398a96d7823Smrg </para> 399a96d7823Smrg </sect2> 400a96d7823Smrg 401a96d7823Smrg <sect2 id='list_next_font_with_info'> 402a96d7823Smrg <title>(*list_next_font_with_info)</title> 403a96d7823Smrg 404a96d7823Smrg <para> 405a96d7823Smrg To avoid storing huge amounts of data, the interface for 406a96d7823Smrg ListFontsWithInfo allows the server to get one reply at a time 407a96d7823Smrg and forward that to the client. When the font name returned 408a96d7823Smrg is actually an alias for some other font, 409a96d7823Smrg <errorname>FontNameAlias</errorname> will be returned. The 410a96d7823Smrg actual font name is return instead, and the font alias which 411a96d7823Smrg matched the pattern is returned in the location pointed to by 412a96d7823Smrg data as a null-terminated string. The caller can then get the 413a96d7823Smrg information by recursively listing that font name with a 414a96d7823Smrg maxnames of 1. When <errorname>Successful</errorname> is 415a96d7823Smrg returned, the matching font name is returned, and a 416a96d7823Smrg FontInfoPtr is stored in the location pointed to by 417a96d7823Smrg <parameter class='function'>data</parameter>. 418a96d7823Smrg <parameter class='function'>Data</parameter> must be initialized 419a96d7823Smrg with a pointer to a FontInfoRec allocated by the caller. When the 420a96d7823Smrg pointer pointed to by <parameter class='function'>data</parameter> 421a96d7823Smrg is not left pointing at that storage, the caller mustn't free the 422a96d7823Smrg associated property data. This routine may return 423a96d7823Smrg <errorname>Suspended</errorname>. 424a96d7823Smrg </para> 425a96d7823Smrg </sect2> 426a96d7823Smrg 427a96d7823Smrg <sect2 id='wakeup_fpe'> 428a96d7823Smrg <title>(*wakeup_fpe)</title> 429a96d7823Smrg 430a96d7823Smrg <para> 431a96d7823Smrg Whenever an FPE function has returned 432a96d7823Smrg <errorname>Suspended</errorname>, this routine is called 433a96d7823Smrg whenever the application wakes up from waiting for input 434a96d7823Smrg (from <citerefentry><refentrytitle>select</refentrytitle> 435a96d7823Smrg <manvolnum>2</manvolnum></citerefentry>). This 436a96d7823Smrg <parameter class='function'>mask</parameter> argument should be 437a96d7823Smrg the value returned from <function>select(2)</function>. 438a96d7823Smrg </para> 439a96d7823Smrg </sect2> 440a96d7823Smrg 441a96d7823Smrg <sect2 id='client_died'> 442a96d7823Smrg <title>(*client_died)</title> 443a96d7823Smrg 444a96d7823Smrg <para> 445a96d7823Smrg When an FPE function has returned <errorname>Suspended</errorname> 446a96d7823Smrg and the associated client is being destroyed, this function 447a96d7823Smrg allows the font library to dispose of any state associated 448a96d7823Smrg with that client. 449a96d7823Smrg </para> 450a96d7823Smrg </sect2> 451a96d7823Smrg </sect1> 452a96d7823Smrg 453a96d7823Smrg <sect1 id='Fonts'> 454a96d7823Smrg<title>Fonts</title> 455a96d7823Smrg 456a96d7823Smrg <para> 457a96d7823Smrg The data structure which actually contains the font information has 458a96d7823Smrg changed significantly since previous releases; it now attempts to 459a96d7823Smrg hide the actual storage format for the data from the application, 460a96d7823Smrg providing accessor functions to get at the data. This allows a 461a96d7823Smrg range of internal details for different font sources. The structure 462a96d7823Smrg is split into two pieces, so that ListFontsWithInfo can share 463a96d7823Smrg information from the font when it has been loaded. The 464a96d7823Smrg <structname>FontInfo</structname> structure, then, contains only 465a96d7823Smrg information germane to LFWI. 466a96d7823Smrg </para> 467a96d7823Smrg 468a96d7823Smrg <programlisting remap='.nf'> 469a96d7823Smrgtypedef struct _FontInfo { 470a96d7823Smrg unsigned short firstCol; /* range of glyphs for this font */ 471a96d7823Smrg unsigned short lastCol; 472a96d7823Smrg unsigned short firstRow; 473a96d7823Smrg unsigned short lastRow; 474a96d7823Smrg unsigned short defaultCh; /* default character index */ 475a96d7823Smrg unsigned int noOverlap:1; /* no combination of glyphs overlap */ 476a96d7823Smrg unsigned int terminalFont:1; /* Character cell font */ 477a96d7823Smrg unsigned int constantMetrics:1; /* all metrics are the same */ 478a96d7823Smrg unsigned int constantWidth:1; /* all character widths are the same*/ 479a96d7823Smrg unsigned int inkInside:1; /* all ink inside character cell */ 480a96d7823Smrg unsigned int inkMetrics:1; /* font has ink metrics */ 481a96d7823Smrg unsigned int allExist:1; /* no missing chars in range */ 482a96d7823Smrg unsigned int drawDirection:2; /* left-to-right/right-to-left*/ 483a96d7823Smrg unsigned int cachable:1; /* font needn't be opened each time*/ 484a96d7823Smrg unsigned int anamorphic:1; /* font is strangely scaled */ 485a96d7823Smrg short maxOverlap; /* maximum overlap amount */ 486a96d7823Smrg short pad; /* unused */ 487a96d7823Smrg xCharInfo maxbounds; /* glyph metrics maximums */ 488a96d7823Smrg xCharInfo minbounds; /* glyph metrics minimums */ 489a96d7823Smrg xCharInfo ink_maxbounds; /* ink metrics maximums */ 490a96d7823Smrg xCharInfo ink_minbounds; /* ink metrics minimums */ 491a96d7823Smrg short fontAscent; /* font ascent amount */ 492a96d7823Smrg short fontDescent; /* font descent amount */ 493a96d7823Smrg int nprops; /* number of font properties */ 494a96d7823Smrg FontPropPtr props; /* font properties */ 495a96d7823Smrg char *isStringProp; /* boolean array */ 496a96d7823Smrg} FontInfoRec, *FontInfoPtr; 497a96d7823Smrg </programlisting> <!-- .fi --> 498a96d7823Smrg 499a96d7823Smrg <para> 500a96d7823Smrg The font structure, then, contains a font info record, the format of 501a96d7823Smrg the bits in each bitmap and the functions which access the font 502a96d7823Smrg records (which are stored in an opaque format hung off of 503a96d7823Smrg <structfield>fontPrivate</structfield>). 504a96d7823Smrg </para> 505a96d7823Smrg 506a96d7823Smrg <programlisting remap='.nf'> 507a96d7823Smrgtypedef struct _Font { 508a96d7823Smrg int refcnt; 509a96d7823Smrg FontInfoRec info; 510a96d7823Smrg char bit; /* bit order: LSBFirst/MSBFirst */ 511a96d7823Smrg char byte; /* byte order: LSBFirst/MSBFirst */ 512a96d7823Smrg char glyph; /* glyph pad: 1, 2, 4 or 8 */ 513a96d7823Smrg char scan; /* glyph scan unit: 1, 2 or 4 */ 514a96d7823Smrg fsBitmapFormat format; /* FS-style format (packed) */ 515a96d7823Smrg int (*get_glyphs) ( /* font, count, chars, encoding, count, glyphs */ ); 516a96d7823Smrg int (*get_metrics) ( /* font, count, chars, encoding, count, glyphs */ ); 517a96d7823Smrg int (*get_bitmaps) ( /* client, font, flags, format, 518a96d7823Smrg flags, nranges, ranges, data_sizep, 519a96d7823Smrg num_glyphsp, offsetsp, glyph_datap, 520a96d7823Smrg free_datap */ ); 521a96d7823Smrg int (*get_extents) ( /* client, font, flags, nranges, 522a96d7823Smrg ranges, nextentsp, extentsp */); 523a96d7823Smrg void (*unload_font) ( /* font */ ); 524a96d7823Smrg FontPathElementPtr fpe; /* FPE associated with this font */ 525a96d7823Smrg pointer svrPrivate; /* X/FS private data */ 526a96d7823Smrg pointer fontPrivate; /* private to font */ 527a96d7823Smrg pointer fpePrivate; /* private to FPE */ 528a96d7823Smrg int maxPrivate; /* devPrivates (see below) */ 529a96d7823Smrg pointer *devPrivates; /* ... */ 530a96d7823Smrg} FontRec, *FontPtr; 531a96d7823Smrg </programlisting> <!-- .fi --> 532a96d7823Smrg 533a96d7823Smrg <para> 534a96d7823Smrg Yes, there are several different private pointers in the 535a96d7823Smrg <structfield>Font</structfield> structure; they were added 536a96d7823Smrg haphazardly until the devPrivate pointers were added. Future 537a96d7823Smrg releases may remove some (or all) of the specific pointers, 538a96d7823Smrg leaving only the <structfield>devPrivates</structfield>mechanism. 539a96d7823Smrg </para> 540a96d7823Smrg 541a96d7823Smrg <para> 542a96d7823Smrg There are two similar interfaces implemented - 543a96d7823Smrg <structfield>get_glyphs</structfield>/<structfield>get_metrics</structfield> 544a96d7823Smrg and 545a96d7823Smrg <structfield>get_bitmaps</structfield>/<structfield>get_extents</structfield>. 546a96d7823Smrg Too little time caused the font-server specific interfaces to 547a96d7823Smrg be placed in the font library (and portions duplicated in each 548a96d7823Smrg renderer) instead of having them integrated into the font server 549a96d7823Smrg itself. This may change. The X server uses only 550a96d7823Smrg <structfield>get_glyphs</structfield>/<structfield>get_metrics</structfield>, 551a96d7823Smrg and those will not change dramatically. Each of the routines 552a96d7823Smrg is described below. 553a96d7823Smrg </para> 554a96d7823Smrg 555a96d7823Smrg <sect2 id='get_glyphs'> 556a96d7823Smrg <title>(*get_glyphs)</title> 557a96d7823Smrg 558a96d7823Smrg <para> 559a96d7823Smrg This routine returns <structname>CharInfoPtrs</structname> 560a96d7823Smrg for each of the requested characters in the font. If the 561a96d7823Smrg character does not exist in the font, the default character 562a96d7823Smrg will be returned, unless no default character exists in 563a96d7823Smrg which case that character is skipped. Thus, the number of 564a96d7823Smrg glyphs returned will not always be the same as the number of 565a96d7823Smrg characters passed in. 566a96d7823Smrg </para> 567a96d7823Smrg </sect2> 568a96d7823Smrg 569a96d7823Smrg <sect2 id='get_metrics'> 570a96d7823Smrg <title>(*get_metrics)</title> 571a96d7823Smrg 572a96d7823Smrg <para> 573a96d7823Smrg This is similar to <structfield>(*get_glyphs)</structfield> 574a96d7823Smrg except that pointers to <structname>xCharInfo</structname> 575a96d7823Smrg structures are returned, and, if the font has ink metrics, 576a96d7823Smrg those are returned instead of the bitmap metrics. 577a96d7823Smrg </para> 578a96d7823Smrg </sect2> 579a96d7823Smrg 580a96d7823Smrg <sect2 id='get_bitmaps'> 581a96d7823Smrg<title>(*get_bitmaps)</title> 582a96d7823Smrg 583a96d7823Smrg <para> 584a96d7823Smrg This packs the glyph image data in the requested 585a96d7823Smrg <parameter class='function'>format</parameter> and returns it. The 586a96d7823Smrg <parameter class='function'>ranges</parameter>/<parameter class='function'>nranges</parameter> 587a96d7823Smrg argument specify the set of glyphs from the font to pack together. 588a96d7823Smrg </para> 589a96d7823Smrg </sect2> 590a96d7823Smrg 591a96d7823Smrg <sect2 id='get_extents'> 592a96d7823Smrg <title>(*get_extents)</title> 593a96d7823Smrg 594a96d7823Smrg <para> 595a96d7823Smrg This returns the metrics for the specified font from the 596a96d7823Smrg specified <parameter class='function'>ranges</parameter>. 597a96d7823Smrg </para> 598a96d7823Smrg 599a96d7823Smrg </sect2> 600a96d7823Smrg 601a96d7823Smrg <sect2 id='unload_font'> 602a96d7823Smrg <title>(*unload_font)</title> 603a96d7823Smrg 604a96d7823Smrg <para> 605a96d7823Smrg This is called from the FPE routine 606a96d7823Smrg <function>(*close_font)</function>, and so should not ever be 607a96d7823Smrg called from the application. 608a96d7823Smrg </para> 609a96d7823Smrg </sect2> 610a96d7823Smrg 611a96d7823Smrg <sect2 id='maxPrivate'> 612a96d7823Smrg<title>maxPrivate</title> 613a96d7823Smrg 614a96d7823Smrg <para> 615a96d7823Smrg When initializing a new font structure, 616a96d7823Smrg <structfield>maxPrivate</structfield> should be set to -1 so 617a96d7823Smrg that the <function>FontSetPrivate()</function> macro works 618a96d7823Smrg properly with an index of 0. Initializing 619a96d7823Smrg <structfield>maxPrivate</structfield> to 0 can cause 620a96d7823Smrg problems if the server tries to set something at index 0. 621a96d7823Smrg </para> 622a96d7823Smrg </sect2> 623a96d7823Smrg </sect1> 624a96d7823Smrg </article> 625