2 * fontconfig/src/fcfs.c
4 * Copyright © 2000 Keith Packard
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the author(s) not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. The authors make no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
29 FcFontSetCreate (void)
33 s = (FcFontSet *) malloc (sizeof (FcFontSet));
43 FcFontSetDestroy (FcFontSet *s)
49 for (i = 0; i < s->nfont; i++)
50 FcPatternDestroy (s->fonts[i]);
58 FcFontSetAdd (FcFontSet *s, FcPattern *font)
63 if (s->nfont == s->sfont)
65 sfont = s->sfont + 32;
67 f = (FcPattern **) realloc (s->fonts, sfont * sizeof (FcPattern *));
69 f = (FcPattern **) malloc (sfont * sizeof (FcPattern *));
75 s->fonts[s->nfont++] = font;
80 FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s)
84 if (!FcSerializeAlloc (serialize, s, sizeof (FcFontSet)))
86 if (!FcSerializeAlloc (serialize, s->fonts, s->nfont * sizeof (FcPattern *)))
88 for (i = 0; i < s->nfont; i++)
90 if (!FcPatternSerializeAlloc (serialize, s->fonts[i]))
97 FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s)
100 FcFontSet *s_serialize;
101 FcPattern **fonts_serialize;
102 FcPattern *p_serialize;
104 s_serialize = FcSerializePtr (serialize, s);
108 s_serialize->sfont = s_serialize->nfont;
110 fonts_serialize = FcSerializePtr (serialize, s->fonts);
111 if (!fonts_serialize)
113 s_serialize->fonts = FcPtrToEncodedOffset (s_serialize,
114 fonts_serialize, FcPattern *);
116 for (i = 0; i < s->nfont; i++)
118 p_serialize = FcPatternSerialize (serialize, s->fonts[i]);
121 fonts_serialize[i] = FcPtrToEncodedOffset (s_serialize,
130 FcFontSetDeserialize (const FcFontSet *set)
133 FcFontSet *new = FcFontSetCreate ();
137 for (i = 0; i < set->nfont; i++)
139 if (!FcFontSetAdd (new, FcPatternDuplicate (FcFontSetFont (set, i))))
145 FcFontSetDestroy (new);
151 #include "fcaliastail.h"