1a96d7823Smrg/*
2a96d7823Smrg * Copyright © 2015 Keith Packard
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 copyright
7a96d7823Smrg * notice and this permission notice appear in supporting documentation, and
8a96d7823Smrg * that the name of the copyright holders not be used in advertising or
9a96d7823Smrg * publicity pertaining to distribution of the software without specific,
10a96d7823Smrg * written prior permission.  The copyright holders make no representations
11a96d7823Smrg * about the suitability of this software for any purpose.  It is provided "as
12a96d7823Smrg * is" without express or implied warranty.
13a96d7823Smrg *
14a96d7823Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15a96d7823Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16a96d7823Smrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17a96d7823Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18a96d7823Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19a96d7823Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20a96d7823Smrg * OF THIS SOFTWARE.
21a96d7823Smrg */
22a96d7823Smrg
23a96d7823Smrg#ifndef _LIBXFONT2_H_
24a96d7823Smrg#define _LIBXFONT2_H_
25a96d7823Smrg
266a46240fSmrg#include	<stddef.h>
27a96d7823Smrg#include	<stdarg.h>
28a96d7823Smrg#include	<stdint.h>
29a96d7823Smrg#include	<X11/Xfuncproto.h>
30a96d7823Smrg#include	<X11/fonts/font.h>
316a46240fSmrg#include	<X11/fonts/fontproto.h>
32a96d7823Smrg
33a96d7823Smrg#define XFONT2_FPE_FUNCS_VERSION	1
34a96d7823Smrg
35a96d7823Smrgtypedef int (*WakeupFpe) (FontPathElementPtr fpe);
36a96d7823Smrg
37a96d7823Smrgtypedef struct _xfont2_fpe_funcs {
38a96d7823Smrg	int		version;
39a96d7823Smrg	NameCheckFunc	name_check;
40a96d7823Smrg	InitFpeFunc	init_fpe;
41a96d7823Smrg	FreeFpeFunc	free_fpe;
42a96d7823Smrg	ResetFpeFunc	reset_fpe;
43a96d7823Smrg	OpenFontFunc	open_font;
44a96d7823Smrg	CloseFontFunc	close_font;
45a96d7823Smrg	ListFontsFunc	list_fonts;
46a96d7823Smrg	StartLfwiFunc	start_list_fonts_with_info;
47a96d7823Smrg	NextLfwiFunc	list_next_font_with_info;
48a96d7823Smrg	WakeupFpe	wakeup_fpe;
49a96d7823Smrg	ClientDiedFunc	client_died;
50a96d7823Smrg	LoadGlyphsFunc	load_glyphs;
51a96d7823Smrg	StartLaFunc	start_list_fonts_and_aliases;
52a96d7823Smrg	NextLaFunc	list_next_font_or_alias;
53a96d7823Smrg	SetPathFunc	set_path_hook;
54a96d7823Smrg} xfont2_fpe_funcs_rec, *xfont2_fpe_funcs_ptr;
55a96d7823Smrg
56a96d7823Smrgtypedef void (*FontBlockHandlerProcPtr) (void *timeout);
57a96d7823Smrg
58a96d7823Smrgtypedef void (*FontFdHandlerProcPtr) (int fd, void *data);
59a96d7823Smrg
60a96d7823Smrg#define XFONT2_CLIENT_FUNCS_VERSION	1
61a96d7823Smrg
62a96d7823Smrgtypedef struct _xfont2_client_funcs {
63a96d7823Smrg	int			version;
64a96d7823Smrg	int			(*client_auth_generation)(ClientPtr client);
65a96d7823Smrg	Bool			(*client_signal)(ClientPtr client);
66a96d7823Smrg	void			(*delete_font_client_id)(Font id);
67a96d7823Smrg	void			(*verrorf)(const char *f, va_list ap) _X_ATTRIBUTE_PRINTF(1,0);
68a96d7823Smrg	FontPtr			(*find_old_font)(FSID id);
69a96d7823Smrg	FontResolutionPtr	(*get_client_resolutions)(int *num);
70a96d7823Smrg	int			(*get_default_point_size)(void);
71a96d7823Smrg	Font			(*get_new_font_client_id)(void);
72a96d7823Smrg	uint32_t		(*get_time_in_millis)(void);
73a96d7823Smrg	int			(*init_fs_handlers)(FontPathElementPtr fpe,
74a96d7823Smrg						    FontBlockHandlerProcPtr block_handler);
75a96d7823Smrg	int			(*register_fpe_funcs)(const xfont2_fpe_funcs_rec *funcs);
76a96d7823Smrg	void			(*remove_fs_handlers)(FontPathElementPtr fpe,
77a96d7823Smrg						      FontBlockHandlerProcPtr block_handler,
78a96d7823Smrg						      Bool all );
79a96d7823Smrg	void			*(*get_server_client)(void);
80a96d7823Smrg	int			(*set_font_authorizations)(char **authorizations,
81a96d7823Smrg							   int *authlen, void *client);
82a96d7823Smrg	int			(*store_font_client_font)(FontPtr pfont, Font id);
83a96d7823Smrg	Atom			(*make_atom)(const char *string, unsigned len, int makeit);
84a96d7823Smrg	int			(*valid_atom)(Atom atom);
85a96d7823Smrg	const char		*(*name_for_atom)(Atom atom);
86a96d7823Smrg	unsigned long		(*get_server_generation)(void);
87a96d7823Smrg	int			(*add_fs_fd)(int fd, FontFdHandlerProcPtr handler, void *data);
88a96d7823Smrg	void			(*remove_fs_fd)(int fd);
89a96d7823Smrg	void			(*adjust_fs_wait_for_delay)(void *wt, unsigned long newdelay);
90a96d7823Smrg} xfont2_client_funcs_rec, *xfont2_client_funcs_ptr;
91a96d7823Smrg
92a96d7823Smrg_X_EXPORT int
93a96d7823Smrgxfont2_init(xfont2_client_funcs_rec const *client_funcs);
94a96d7823Smrg
95a96d7823Smrg_X_EXPORT void
96a96d7823Smrgxfont2_query_glyph_extents(FontPtr pFont, CharInfoPtr *charinfo,
97a96d7823Smrg			   unsigned long count, ExtentInfoRec *info);
98a96d7823Smrg
99a96d7823Smrg_X_EXPORT Bool
100a96d7823Smrgxfont2_query_text_extents(FontPtr pFont, unsigned long count,
101a96d7823Smrg			  unsigned char *chars, ExtentInfoRec *info);
102a96d7823Smrg
103a96d7823Smrg_X_EXPORT Bool
104a96d7823Smrgxfont2_parse_glyph_caching_mode(char *str);
105a96d7823Smrg
106a96d7823Smrg_X_EXPORT void
107a96d7823Smrgxfont2_init_glyph_caching(void);
108a96d7823Smrg
109a96d7823Smrg_X_EXPORT void
110a96d7823Smrgxfont2_set_glyph_caching_mode(int newmode);
111a96d7823Smrg
112a96d7823Smrg_X_EXPORT FontNamesPtr
113a96d7823Smrgxfont2_make_font_names_record(unsigned size);
114a96d7823Smrg
115a96d7823Smrg_X_EXPORT void
116a96d7823Smrgxfont2_free_font_names(FontNamesPtr pFN);
117a96d7823Smrg
118a96d7823Smrg_X_EXPORT int
119a96d7823Smrgxfont2_add_font_names_name(FontNamesPtr names,
120a96d7823Smrg			   char *name,
121a96d7823Smrg			   int length);
122a96d7823Smrg
123a96d7823Smrgtypedef struct _xfont2_pattern_cache    *xfont2_pattern_cache_ptr;
124a96d7823Smrg
125a96d7823Smrg_X_EXPORT xfont2_pattern_cache_ptr
126a96d7823Smrgxfont2_make_font_pattern_cache(void);
127a96d7823Smrg
128a96d7823Smrg_X_EXPORT void
129a96d7823Smrgxfont2_free_font_pattern_cache(xfont2_pattern_cache_ptr cache);
130a96d7823Smrg
131a96d7823Smrg_X_EXPORT void
132a96d7823Smrgxfont2_empty_font_pattern_cache(xfont2_pattern_cache_ptr cache);
133a96d7823Smrg
134a96d7823Smrg_X_EXPORT void
135a96d7823Smrgxfont2_cache_font_pattern(xfont2_pattern_cache_ptr cache,
136a96d7823Smrg			  const char * pattern,
137a96d7823Smrg			  int patlen,
138a96d7823Smrg			  FontPtr pFont);
139a96d7823Smrg
140a96d7823Smrg_X_EXPORT FontPtr
141a96d7823Smrgxfont2_find_cached_font_pattern(xfont2_pattern_cache_ptr cache,
142a96d7823Smrg				const char * pattern,
143a96d7823Smrg				int patlen);
144a96d7823Smrg
145a96d7823Smrg_X_EXPORT void
146a96d7823Smrgxfont2_remove_cached_font_pattern(xfont2_pattern_cache_ptr cache,
147a96d7823Smrg				  FontPtr pFont);
148a96d7823Smrg
149a96d7823Smrg/* private.c */
150a96d7823Smrg
151a96d7823Smrg_X_EXPORT int
152a96d7823Smrgxfont2_allocate_font_private_index (void);
153a96d7823Smrg
154a96d7823Smrgstatic inline void *
155a96d7823Smrgxfont2_font_get_private(FontPtr pFont, int n)
156a96d7823Smrg{
157a96d7823Smrg	if (n > pFont->maxPrivate)
158a96d7823Smrg		return NULL;
159a96d7823Smrg	return pFont->devPrivates[n];
160a96d7823Smrg}
161a96d7823Smrg
162a96d7823Smrg_X_EXPORT Bool
163a96d7823Smrgxfont2_font_set_private(FontPtr pFont, int n, void *ptr);
164a96d7823Smrg
165a96d7823Smrg#endif /* _LIBXFONT2_H_ */
166