]> git.sesse.net Git - rdpsrv/blob - Xserver/lib/font/fontfile/printerfont.c
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / lib / font / fontfile / printerfont.c
1 /* $XConsortium: printerfont.c /main/1 1996/09/28 16:49:21 rws $ */
2
3 /*
4
5 Copyright (c) 1991  X Consortium
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
27
28 */
29
30 /*
31  * Author:  Keith Packard, MIT X Consortium
32  */
33 /* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
34
35 #include    "fntfilst.h"
36
37 /*
38  * Map FPE functions to renderer functions
39  */
40
41 extern int FontFileInitFPE();
42 extern int FontFileResetFPE();
43 extern int FontFileFreeFPE();
44 extern void FontFileCloseFont();
45 #define PRINTERPATHPREFIX  "PRINTER:"
46
47 /* STUB
48 int XpClientIsPrintClient(client,fpe)
49 pointer         client;
50 FontPathElementPtr      fpe;
51 { return 1; }
52  */
53
54 int
55 PrinterFontNameCheck (name)
56     char    *name;
57 {
58     if (strncmp(name,PRINTERPATHPREFIX,strlen(PRINTERPATHPREFIX)) != 0)
59         return 0;
60     name += strlen(PRINTERPATHPREFIX);
61 #ifndef NCD
62     return *name == '/';
63 #else
64     return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
65 #endif
66 }
67
68 int
69 PrinterFontInitFPE (fpe)
70     FontPathElementPtr  fpe;
71 {
72     int                 status;
73     FontDirectoryPtr    dir;
74     char *              name;
75
76     name = fpe->name + strlen(PRINTERPATHPREFIX);
77     status = FontFileReadDirectory (name, &dir);
78     if (status == Successful)
79     {
80         if (dir->nonScalable.used > 0)
81             if (!FontFileRegisterBitmapSource (fpe))
82             {
83                 FontFileFreeFPE (fpe);
84                 return AllocError;
85             }
86         fpe->private = (pointer) dir;
87     }
88     return status;
89 }
90
91 /* Here we must check the client to see if it has a context attached to
92  * it that allows us to access the printer fonts
93  */
94
95 int
96 PrinterFontOpenFont (client, fpe, flags, name, namelen, format, fmask,
97                   id, pFont, aliasName, non_cachable_font)
98     pointer             client;
99     FontPathElementPtr  fpe;
100     int                 flags;
101     char                *name;
102     int                 namelen;
103     fsBitmapFormat      format;
104     fsBitmapFormatMask  fmask;
105     XID                 id;
106     FontPtr             *pFont;
107     char                **aliasName;
108     FontPtr             non_cachable_font;
109 {
110     if (XpClientIsPrintClient(client,fpe))
111         return (FontFileOpenFont  (client, fpe, flags, name, namelen, format, 
112                 fmask, id, pFont, aliasName, non_cachable_font));
113     return BadFontName;
114 }
115
116 PrinterFontListFonts (client, fpe, pat, len, max, names)
117     pointer     client;
118     FontPathElementPtr fpe;
119     char       *pat;
120     int         len;
121     int         max;
122     FontNamesPtr names;
123 {
124     if (XpClientIsPrintClient(client,fpe))
125         return FontFileListFonts (client, fpe, pat, len, max, names);
126     return BadFontName;
127 }
128
129 PrinterFontStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
130     pointer     client;
131     FontPathElementPtr fpe;
132     char       *pat;
133     int         len;
134     int         max;
135     pointer    *privatep;
136 {
137     if (XpClientIsPrintClient(client,fpe))
138         return FontFileStartListFontsWithInfo(client, fpe, pat, len, 
139                                 max, privatep);
140     return BadFontName;
141 }
142
143 PrinterFontListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
144                              numFonts, private)
145     pointer             client;
146     FontPathElementPtr  fpe;
147     char                **namep;
148     int                 *namelenp;
149     FontInfoPtr         *pFontInfo;
150     int                 *numFonts;
151     pointer             private;
152 {
153     if (XpClientIsPrintClient(client,fpe))
154         return FontFileListNextFontWithInfo(client, fpe, namep, namelenp, 
155                                 pFontInfo, numFonts, private);
156     return BadFontName;
157 }
158
159 PrinterFontStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
160     pointer     client;
161     FontPathElementPtr fpe;
162     char       *pat;
163     int         len;
164     int         max;
165     pointer    *privatep;
166 {
167     if (XpClientIsPrintClient(client,fpe))
168         return FontFileStartListFontsAndAliases(client, fpe, pat, len, 
169                                 max, privatep);
170     return BadFontName;
171 }
172
173 int
174 PrinterFontListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
175                             resolvedlenp, private)
176     pointer             client;
177     FontPathElementPtr  fpe;
178     char                **namep;
179     int                 *namelenp;
180     char                **resolvedp;
181     int                 *resolvedlenp;
182     pointer             private;
183 {
184     if (XpClientIsPrintClient(client,fpe))
185         return FontFileListNextFontOrAlias(client, fpe, namep, namelenp, 
186                                 resolvedp, resolvedlenp, private);
187     return BadFontName;
188 }
189
190 extern void FontFileEmptyBitmapSource();
191 typedef int (*IntFunc) ();
192 static int  printer_font_type;
193
194 PrinterFontRegisterFpeFunctions ()
195 {
196     /* what is the use of printer font type? */
197     printer_font_type = RegisterFPEFunctions(PrinterFontNameCheck,
198                                           PrinterFontInitFPE,
199                                           FontFileFreeFPE,
200                                           FontFileResetFPE,
201                                           PrinterFontOpenFont,
202                                           FontFileCloseFont,
203                                           PrinterFontListFonts,
204                                           PrinterFontStartListFontsWithInfo,
205                                           PrinterFontListNextFontWithInfo,
206                                           (IntFunc) 0,
207                                           (IntFunc) 0,
208                                           (IntFunc) 0,
209                                           PrinterFontStartListFontsAndAliases,
210                                           PrinterFontListNextFontOrAlias,
211                                           FontFileEmptyBitmapSource);
212 }