1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* Pango
* fonts.c:
*
* Copyright (C) 1999 Red Hat Software
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "pango.h"
/**
* pango_font_init:
* @font: a #PangoFont
*
* Initialize a #PangoFont structure. This should
* only be called from the "new" routine of code which
* is implementing a "subclass" of #PangoFont
*/
void
pango_font_init (PangoFont *font)
{
g_return_if_fail (font != NULL);
g_datalist_init (&font->data);
font->ref_count = 1;
}
/**
* pango_font_ref:
* @font: a #PangoFont
*
* Increase the reference count of a #PangoFont.
*/
void
pango_font_ref (PangoFont *font)
{
g_return_if_fail (font != NULL);
font->ref_count++;
}
/**
* pango_font_unref:
* @font: a #PangoFont
*
* Decrease the reference count of a #PangoFont.
* if the result is zero, destroy the font
* and free the associated memory.
*/
void
pango_font_unref (PangoFont *font)
{
g_return_if_fail (font != NULL);
g_return_if_fail (font->ref_count > 0);
font->ref_count--;
if (font->ref_count == 0)
{
g_datalist_clear (&font->data);
font->klass->destroy (font);
}
}
/**
* pango_font_set_data:
* @font: a #PangoFont
* @key: a string identifying the type of user data.
* @data: the data to store. If %NULL, the current
* data for the key will be removed.
* @destroy_func: a function to call when the data is no
* longer stored, either because the font has
* been destroyed, or because the data has
* been replaced. This can be %NULL, in which
* case no function will be called.
*
* Associate user data, tagged with a string id, with a particular
* font.
*/
void
pango_font_set_data (PangoFont *font,
gchar *key,
gpointer data,
GDestroyNotify destroy_func)
{
g_datalist_set_data_full (&font->data, key, data, destroy_func);
}
/**
* pango_font_get_data:
* @font: a #PangoFont
* @key: a string identifying the type of user data.
*
* Look up user data tagged with a particular key.
*
* Returns the data, or NULL if that key does not exist.
*/
gpointer
pango_font_get_data (PangoFont *font,
gchar *key)
{
return g_datalist_get_data (&font->data, key);
}
|