Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xnest / Font.c
blob72edcee9a053724d0990a8b2c20332f9655a6395
1 /*
3 Copyright 1993 by Davor Matic
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.
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
17 #endif
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 "scrnintstr.h"
28 #include "Xnest.h"
30 #include "Display.h"
31 #include "XNFont.h"
33 int xnestFontPrivateIndex;
35 Bool
36 xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
38 pointer priv;
39 Atom name_atom, value_atom;
40 int nprops;
41 FontPropPtr props;
42 int i;
43 char *name;
45 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
47 if (requestingClient && XpClientIsPrintClient(requestingClient, NULL))
48 return True;
50 name_atom = MakeAtom("FONT", 4, True);
51 value_atom = 0L;
53 nprops = pFont->info.nprops;
54 props = pFont->info.props;
56 for (i = 0; i < nprops; i++)
57 if (props[i].name == name_atom) {
58 value_atom = props[i].value;
59 break;
62 if (!value_atom) return False;
64 name = (char *)NameForAtom(value_atom);
66 if (!name) return False;
68 priv = (pointer)xalloc(sizeof(xnestPrivFont));
69 FontSetPrivate(pFont, xnestFontPrivateIndex, priv);
71 xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);
73 if (!xnestFontStruct(pFont)) return False;
75 return True;
79 Bool
80 xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
82 if (xnestFontPriv(pFont)) {
83 if (xnestFontStruct(pFont))
84 XFreeFont(xnestDisplay, xnestFontStruct(pFont));
85 xfree(xnestFontPriv(pFont));
86 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
88 return True;