1/*
2
3Copyright 1991, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25*/
26
27/*
28 * Author:  Keith Packard, MIT X Consortium
29 */
30
31#ifndef _FONTFILEST_H_
32#define _FONTFILEST_H_
33
34#include <X11/Xos.h>
35#ifndef XP_PSTEXT
36#include <X11/fonts/fontmisc.h>
37#endif
38#include <X11/fonts/fontstruct.h>
39#include <X11/fonts/fontxlfd.h>
40#include <X11/fonts/fntfil.h>
41
42typedef struct _FontName {
43    char	*name;
44    short	length;
45    short	ndashes;
46} FontNameRec;
47
48typedef struct _FontScaled {
49    FontScalableRec	vals;
50    FontEntryPtr	bitmap;
51    FontPtr		pFont;
52} FontScaledRec;
53
54typedef struct _FontScalableExtra {
55    FontScalableRec	defaults;
56    int			numScaled;
57    int			sizeScaled;
58    FontScaledPtr	scaled;
59    pointer		private;
60} FontScalableExtraRec;
61
62typedef struct _FontScalableEntry {
63    FontRendererPtr	    renderer;
64    char		    *fileName;
65    FontScalableExtraPtr   extra;
66} FontScalableEntryRec;
67
68/*
69 * This "can't" work yet - the returned alias string must be permanent,
70 * but this layer would need to generate the appropriate name from the
71 * resolved scalable + the XLFD values passed in.  XXX
72 */
73
74typedef struct _FontScaleAliasEntry {
75    char		*resolved;
76} FontScaleAliasEntryRec;
77
78typedef struct _FontBitmapEntry {
79    FontRendererPtr	renderer;
80    char		*fileName;
81    FontPtr		pFont;
82} FontBitmapEntryRec;
83
84typedef struct _FontAliasEntry {
85    char	*resolved;
86} FontAliasEntryRec;
87
88typedef struct _FontBCEntry {
89    FontScalableRec	    vals;
90    FontEntryPtr	    entry;
91} FontBCEntryRec;
92
93typedef struct _FontEntry {
94    FontNameRec	name;
95    int		type;
96    union _FontEntryParts {
97	FontScalableEntryRec	scalable;
98	FontBitmapEntryRec	bitmap;
99	FontAliasEntryRec	alias;
100	FontBCEntryRec		bc;
101    } u;
102} FontEntryRec;
103
104typedef struct _FontTable {
105    int		    used;
106    int		    size;
107    FontEntryPtr    entries;
108    Bool	    sorted;
109} FontTableRec;
110
111typedef struct _FontDirectory {
112    char	    *directory;
113    unsigned long   dir_mtime;
114    unsigned long   alias_mtime;
115    FontTableRec    scalable;
116    FontTableRec    nonScalable;
117    char	    *attributes;
118} FontDirectoryRec;
119
120/* Capability bits: for definition of capabilities bitmap in the
121   FontRendererRec to indicate support of XLFD enhancements */
122
123#define CAP_MATRIX		0x1
124#define CAP_CHARSUBSETTING	0x2
125
126typedef struct _FontRenderer {
127    const char    *fileSuffix;
128    int	    fileSuffixLen;
129    int	    (*OpenBitmap)(FontPathElementPtr /* fpe */,
130			  FontPtr * /* pFont */,
131			  int /* flags */,
132			  FontEntryPtr /* entry */,
133			  char * /* fileName */,
134			  fsBitmapFormat /* format */,
135			  fsBitmapFormatMask /* mask */,
136			  FontPtr /* non_cachable_font */);
137    int	    (*OpenScalable)(FontPathElementPtr /* fpe */,
138			    FontPtr * /* pFont */,
139			    int /* flags */,
140			    FontEntryPtr /* entry */,
141			    char * /* fileName */,
142			    FontScalablePtr /* vals */,
143			    fsBitmapFormat /* format */,
144			    fsBitmapFormatMask /* fmask */,
145			    FontPtr /* non_cachable_font */);
146    int	    (*GetInfoBitmap)(FontPathElementPtr /* fpe */,
147			     FontInfoPtr /* pFontInfo */,
148			     FontEntryPtr /* entry */,
149			     char * /*fileName */);
150    int	    (*GetInfoScalable)(FontPathElementPtr /* fpe */,
151			       FontInfoPtr /* pFontInfo */,
152			       FontEntryPtr /* entry */,
153			       FontNamePtr /* fontName */,
154			       char * /* fileName */,
155			       FontScalablePtr /* vals */);
156    int	    number;
157    int     capabilities;	/* Bitmap components defined above */
158} FontRendererRec;
159
160typedef struct _FontRenders {
161    int		    number;
162    struct _FontRenderersElement {
163        /* In order to preserve backward compatibility, the
164           priority field is made invisible to renderers */
165        FontRendererPtr renderer;
166        int priority;
167    } *renderers;
168} FontRenderersRec, *FontRenderersPtr;
169
170typedef struct _BitmapInstance {
171    FontScalableRec	vals;
172    FontBitmapEntryPtr	bitmap;
173} BitmapInstanceRec, *BitmapInstancePtr;
174
175typedef struct _BitmapScalablePrivate {
176    int			numInstances;
177    BitmapInstancePtr	instances;
178} BitmapScalablePrivateRec, *BitmapScalablePrivatePtr;
179
180typedef struct _BitmapSources {
181    FontPathElementPtr	*fpe;
182    int			size;
183    int			count;
184} BitmapSourcesRec, *BitmapSourcesPtr;
185
186extern BitmapSourcesRec	FontFileBitmapSources;
187
188/* Defines for FontFileFindNamesInScalableDir() behavior */
189#define NORMAL_ALIAS_BEHAVIOR		0
190#define LIST_ALIASES_AND_TARGET_NAMES   (1<<0)
191#define IGNORE_SCALABLE_ALIASES		(1<<1)
192
193#endif /* _FONTFILEST_H_ */
194