1a96d7823Smrg/*
2a96d7823Smrg
3a96d7823SmrgCopyright 1990, 1998  The Open Group
4a96d7823Smrg
5a96d7823SmrgPermission to use, copy, modify, distribute, and sell this software and its
6a96d7823Smrgdocumentation for any purpose is hereby granted without fee, provided that
7a96d7823Smrgthe above copyright notice appear in all copies and that both that
8a96d7823Smrgcopyright notice and this permission notice appear in supporting
9a96d7823Smrgdocumentation.
10a96d7823Smrg
11a96d7823SmrgThe above copyright notice and this permission notice shall be included
12a96d7823Smrgin all copies or substantial portions of the Software.
13a96d7823Smrg
14a96d7823SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15a96d7823SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16a96d7823SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17a96d7823SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18a96d7823SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19a96d7823SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20a96d7823SmrgOTHER DEALINGS IN THE SOFTWARE.
21a96d7823Smrg
22a96d7823SmrgExcept as contained in this notice, the name of The Open Group shall
23a96d7823Smrgnot be used in advertising or otherwise to promote the sale, use or
24a96d7823Smrgother dealings in this Software without prior written authorization
25a96d7823Smrgfrom The Open Group.
26a96d7823Smrg
27a96d7823Smrg*/
28a96d7823Smrg
29a96d7823Smrg/*
30a96d7823Smrg * Author:  Keith Packard, MIT X Consortium
31a96d7823Smrg */
32a96d7823Smrg
33a96d7823Smrg#ifndef _BITMAP_H_
34a96d7823Smrg#define _BITMAP_H_
35a96d7823Smrg
36a96d7823Smrg#include <X11/fonts/fntfilio.h>
37a96d7823Smrg#include <stdio.h>  /* just for NULL */
38a96d7823Smrg
39a96d7823Smrg/*
40a96d7823Smrg * Internal format used to store bitmap fonts
41a96d7823Smrg */
42a96d7823Smrg
43a96d7823Smrg/* number of encoding entries in one segment */
44a96d7823Smrg#define BITMAP_FONT_SEGMENT_SIZE 128
45a96d7823Smrg
46a96d7823Smrgtypedef struct _BitmapExtra {
47a96d7823Smrg    Atom       *glyphNames;
48a96d7823Smrg    int        *sWidths;
49a96d7823Smrg    CARD32      bitmapsSizes[GLYPHPADOPTIONS];
50a96d7823Smrg    FontInfoRec info;
51a96d7823Smrg}           BitmapExtraRec, *BitmapExtraPtr;
52a96d7823Smrg
53a96d7823Smrgtypedef struct _BitmapFont {
54a96d7823Smrg    unsigned    version_num;
55a96d7823Smrg    int         num_chars;
56a96d7823Smrg    int         num_tables;
57a96d7823Smrg    CharInfoPtr metrics;	/* font metrics, including glyph pointers */
58a96d7823Smrg    xCharInfo  *ink_metrics;	/* ink metrics */
59a96d7823Smrg    char       *bitmaps;	/* base of bitmaps, useful only to free */
60a96d7823Smrg    CharInfoPtr **encoding;	/* array of arrays of char info pointers */
61a96d7823Smrg    CharInfoPtr pDefault;	/* default character */
62a96d7823Smrg    BitmapExtraPtr bitmapExtra;	/* stuff not used by X server */
63a96d7823Smrg}           BitmapFontRec, *BitmapFontPtr;
64a96d7823Smrg
65a96d7823Smrg#define ACCESSENCODING(enc,i) \
66a96d7823Smrg(enc[(i)/BITMAP_FONT_SEGMENT_SIZE]?\
67a96d7823Smrg(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE]):\
68a96d7823Smrg0)
69a96d7823Smrg#define ACCESSENCODINGL(enc,i) \
70a96d7823Smrg(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE])
71a96d7823Smrg
72a96d7823Smrg#define SEGMENT_MAJOR(n) ((n)/BITMAP_FONT_SEGMENT_SIZE)
73a96d7823Smrg#define SEGMENT_MINOR(n) ((n)%BITMAP_FONT_SEGMENT_SIZE)
74a96d7823Smrg#define NUM_SEGMENTS(n) \
75a96d7823Smrg  (((n)+BITMAP_FONT_SEGMENT_SIZE-1)/BITMAP_FONT_SEGMENT_SIZE)
76a96d7823Smrg
77a96d7823Smrgextern int bitmapGetGlyphs ( FontPtr pFont, unsigned long count,
78a96d7823Smrg			     unsigned char *chars, FontEncoding charEncoding,
79a96d7823Smrg			     unsigned long *glyphCount, CharInfoPtr *glyphs );
80a96d7823Smrgextern int bitmapGetMetrics ( FontPtr pFont, unsigned long count,
81a96d7823Smrg			      unsigned char *chars, FontEncoding charEncoding,
82a96d7823Smrg			      unsigned long *glyphCount, xCharInfo **glyphs );
83a96d7823Smrg
84a96d7823Smrgextern void bitmapComputeFontBounds ( FontPtr pFont );
85a96d7823Smrgextern void bitmapComputeFontInkBounds ( FontPtr pFont );
86a96d7823Smrgextern Bool bitmapAddInkMetrics ( FontPtr pFont );
87a96d7823Smrgextern int bitmapComputeWeight ( FontPtr pFont );
88a96d7823Smrg
89a96d7823Smrgextern void BitmapRegisterFontFileFunctions ( void );
90a96d7823Smrg
91a96d7823Smrgextern int BitmapOpenScalable ( FontPathElementPtr fpe, FontPtr *pFont,
92a96d7823Smrg				int flags, FontEntryPtr entry, char *fileName,
93a96d7823Smrg				FontScalablePtr vals, fsBitmapFormat format,
94a96d7823Smrg				fsBitmapFormatMask fmask,
95a96d7823Smrg				FontPtr non_cachable_font );
96a96d7823Smrgextern int BitmapGetInfoScalable ( FontPathElementPtr fpe,
97a96d7823Smrg				   FontInfoPtr pFontInfo, FontEntryPtr entry,
98a96d7823Smrg				   FontNamePtr fontName, char *fileName,
99a96d7823Smrg				   FontScalablePtr vals );
100a96d7823Smrg
101a96d7823Smrg#endif				/* _BITMAP_H_ */
102