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