1 /*
2
3 Copyright 1993 by Davor Matic
4
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
12
13 */
14
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
17 #endif
18
19 #include <X11/X.h>
20 #include <X11/Xatom.h>
21 #include <X11/Xproto.h>
22 #include "misc.h"
23 #include "regionstr.h"
24 #include <X11/fonts/font.h>
25 #include <X11/fonts/fontstruct.h>
26 #include "dixfontstr.h"
27 #include "scrnintstr.h"
28
29 #include "Xnest.h"
30
31 #include "Display.h"
32 #include "XNFont.h"
33
34 int xnestFontPrivateIndex;
35
36 Bool
xnestRealizeFont(ScreenPtr pScreen,FontPtr pFont)37 xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
38 {
39 void *priv;
40 Atom name_atom, value_atom;
41 int nprops;
42 FontPropPtr props;
43 int i;
44 const char *name;
45
46 xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL);
47
48 name_atom = MakeAtom("FONT", 4, True);
49 value_atom = 0L;
50
51 nprops = pFont->info.nprops;
52 props = pFont->info.props;
53
54 for (i = 0; i < nprops; i++)
55 if (props[i].name == name_atom) {
56 value_atom = props[i].value;
57 break;
58 }
59
60 if (!value_atom)
61 return False;
62
63 name = NameForAtom(value_atom);
64
65 if (!name)
66 return False;
67
68 priv = (void *) malloc(sizeof(xnestPrivFont));
69 xfont2_font_set_private(pFont, xnestFontPrivateIndex, priv);
70
71 xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);
72
73 if (!xnestFontStruct(pFont))
74 return False;
75
76 return True;
77 }
78
79 Bool
xnestUnrealizeFont(ScreenPtr pScreen,FontPtr pFont)80 xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
81 {
82 if (xnestFontPriv(pFont)) {
83 if (xnestFontStruct(pFont))
84 XFreeFont(xnestDisplay, xnestFontStruct(pFont));
85 free(xnestFontPriv(pFont));
86 xfont2_font_set_private(pFont, xnestFontPrivateIndex, NULL);
87 }
88 return True;
89 }
90