1 /*
2  * Copyright 1999 SuSE, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name of SuSE not be used in advertising or
9  * publicity pertaining to distribution of the software without specific,
10  * written prior permission.  SuSE makes no representations about the
11  * suitability of this software for any purpose.  It is provided "as is"
12  * without express or implied warranty.
13  *
14  * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
16  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  *
21  * Author:  Keith Packard, SuSE, Inc.
22  */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 #include "libxfontint.h"
28 #include    <X11/fonts/fntfilst.h>
29 #include "builtin.h"
30 
31 static int  font_file_type;
32 
33 static const char builtin_fonts[] = "built-ins";
34 
35 static int
BuiltinNameCheck(const char * name)36 BuiltinNameCheck (const char *name)
37 {
38     return (strcmp (name, builtin_fonts) == 0);
39 }
40 
41 static int
BuiltinInitFPE(FontPathElementPtr fpe)42 BuiltinInitFPE (FontPathElementPtr fpe)
43 {
44     int			status;
45     FontDirectoryPtr	dir;
46 
47     status = BuiltinReadDirectory (fpe->name, &dir);
48 
49     if (status == Successful)
50 	fpe->private = (pointer) dir;
51     return status;
52 }
53 
54 /* ARGSUSED */
55 static int
BuiltinResetFPE(FontPathElementPtr fpe)56 BuiltinResetFPE (FontPathElementPtr fpe)
57 {
58     /* builtins can't change! */
59     return Successful;
60 }
61 
62 static int
BuiltinFreeFPE(FontPathElementPtr fpe)63 BuiltinFreeFPE (FontPathElementPtr fpe)
64 {
65     FontFileFreeDir ((FontDirectoryPtr) fpe->private);
66     return Successful;
67 }
68 
69 static const xfont2_fpe_funcs_rec builtin_fpe_funcs = {
70 	.version = XFONT2_FPE_FUNCS_VERSION,
71 	.name_check = BuiltinNameCheck,
72 	.init_fpe = BuiltinInitFPE,
73 	.free_fpe = BuiltinFreeFPE,
74 	.reset_fpe = BuiltinResetFPE,
75 	.open_font = FontFileOpenFont,
76 	.close_font = FontFileCloseFont,
77 	.list_fonts = FontFileListFonts,
78 	.start_list_fonts_with_info = FontFileStartListFontsWithInfo,
79 	.list_next_font_with_info = FontFileListNextFontWithInfo,
80 	.wakeup_fpe = 0,
81 	.client_died = 0,
82 	.load_glyphs = 0,
83 	.start_list_fonts_and_aliases = 0,
84 	.list_next_font_or_alias = 0,
85 	.set_path_hook = 0
86 };
87 
88 void
BuiltinRegisterFpeFunctions(void)89 BuiltinRegisterFpeFunctions(void)
90 {
91     BuiltinRegisterFontFileFunctions ();
92 
93     font_file_type = register_fpe_funcs(&builtin_fpe_funcs);
94 }
95