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