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