Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xnest / Font.c
CommitLineData
a09e091a
JB
1/*
2
3Copyright 1993 by Davor Matic
4
5Permission to use, copy, modify, distribute, and sell this software
6and its documentation for any purpose is hereby granted without fee,
7provided that the above copyright notice appear in all copies and that
8both that copyright notice and this permission notice appear in
9supporting documentation. Davor Matic makes no representations about
10the suitability of this software for any purpose. It is provided "as
11is" 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 "scrnintstr.h"
27
28#include "Xnest.h"
29
30#include "Display.h"
31#include "XNFont.h"
32
33int xnestFontPrivateIndex;
34
35Bool
36xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
37{
38 pointer priv;
39 Atom name_atom, value_atom;
40 int nprops;
41 FontPropPtr props;
42 int i;
43 const char *name;
44
45 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
46
47 name_atom = MakeAtom("FONT", 4, True);
48 value_atom = 0L;
49
50 nprops = pFont->info.nprops;
51 props = pFont->info.props;
52
53 for (i = 0; i < nprops; i++)
54 if (props[i].name == name_atom) {
55 value_atom = props[i].value;
56 break;
57 }
58
59 if (!value_atom)
60 return False;
61
62 name = NameForAtom(value_atom);
63
64 if (!name)
65 return False;
66
67 priv = (pointer) malloc(sizeof(xnestPrivFont));
68 FontSetPrivate(pFont, xnestFontPrivateIndex, priv);
69
70 xnestFontPriv(pFont)->font_struct = XLoadQueryFont(xnestDisplay, name);
71
72 if (!xnestFontStruct(pFont))
73 return False;
74
75 return True;
76}
77
78Bool
79xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
80{
81 if (xnestFontPriv(pFont)) {
82 if (xnestFontStruct(pFont))
83 XFreeFont(xnestDisplay, xnestFontStruct(pFont));
84 free(xnestFontPriv(pFont));
85 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL);
86 }
87 return True;
88}