summaryrefslogtreecommitdiff
path: root/libs/gtkmm2/pango/pangomm/fontdescription.cc
blob: af866dc9cbbb06b35caf5b82af33749640af0ecb (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Generated by gtkmmproc -- DO NOT MODIFY!

#include <pangomm/fontdescription.h>
#include <pangomm/private/fontdescription_p.h>

#include <pango/pango-enum-types.h>
// -*- c++ -*-
/* $Id$ */

/*
 *
 * Copyright 1998-2002 The gtkmm Development Team
 *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/utility.h>


namespace Pango
{

FontDescription::FontDescription(const Glib::ustring& font_name)
{
  gobject_ = pango_font_description_from_string(font_name.c_str());
}

} // namespace Pango


namespace
{
} // anonymous namespace

// static
GType Glib::Value<Pango::Style>::value_type()
{
  return pango_style_get_type();
}

// static
GType Glib::Value<Pango::Variant>::value_type()
{
  return pango_variant_get_type();
}

// static
GType Glib::Value<Pango::Stretch>::value_type()
{
  return pango_stretch_get_type();
}

// static
GType Glib::Value<Pango::Weight>::value_type()
{
  return pango_weight_get_type();
}

// static
GType Glib::Value<Pango::FontMask>::value_type()
{
  return pango_font_mask_get_type();
}


namespace Glib
{

Pango::FontDescription wrap(PangoFontDescription* object, bool take_copy)
{
  return Pango::FontDescription(object, take_copy);
}

} // namespace Glib


namespace Pango
{


// static
GType FontDescription::get_type()
{
  return pango_font_description_get_type();
}

FontDescription::FontDescription()
:
  gobject_ (pango_font_description_new())
{}

FontDescription::FontDescription(const FontDescription& other)
:
  gobject_ ((other.gobject_) ? pango_font_description_copy(other.gobject_) : 0)
{}

FontDescription::FontDescription(PangoFontDescription* gobject, bool make_a_copy)
:
  // For BoxedType wrappers, make_a_copy is true by default.  The static
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
  // ensures identical behaviour if the default argument is used.
  gobject_ ((make_a_copy && gobject) ? pango_font_description_copy(gobject) : gobject)
{}

FontDescription& FontDescription::operator=(const FontDescription& other)
{
  FontDescription temp (other);
  swap(temp);
  return *this;
}

FontDescription::~FontDescription()
{
  if(gobject_)
    pango_font_description_free(gobject_);
}

void FontDescription::swap(FontDescription& other)
{
  PangoFontDescription *const temp = gobject_;
  gobject_ = other.gobject_;
  other.gobject_ = temp;
}

PangoFontDescription* FontDescription::gobj_copy() const
{
  return pango_font_description_copy(gobject_);
}


guint FontDescription::hash() const
{
  return pango_font_description_hash(const_cast<PangoFontDescription*>(gobj()));
}

void FontDescription::set_family(const Glib::ustring& family)
{
  pango_font_description_set_family(gobj(), family.c_str());
}

Glib::ustring FontDescription::get_family() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(pango_font_description_get_family(const_cast<PangoFontDescription*>(gobj())));
}

void FontDescription::set_style(Style style)
{
  pango_font_description_set_style(gobj(), ((PangoStyle)(style)));
}

Style FontDescription::get_style() const
{
  return ((Style)(pango_font_description_get_style(const_cast<PangoFontDescription*>(gobj()))));
}

void FontDescription::set_variant(Variant variant)
{
  pango_font_description_set_variant(gobj(), ((PangoVariant)(variant)));
}

Variant FontDescription::get_variant() const
{
  return ((Variant)(pango_font_description_get_variant(const_cast<PangoFontDescription*>(gobj()))));
}

void FontDescription::set_weight(Weight weight)
{
  pango_font_description_set_weight(gobj(), ((PangoWeight)(weight)));
}

Weight FontDescription::get_weight() const
{
  return ((Weight)(pango_font_description_get_weight(const_cast<PangoFontDescription*>(gobj()))));
}

void FontDescription::set_stretch(Stretch stretch)
{
  pango_font_description_set_stretch(gobj(), ((PangoStretch)(stretch)));
}

Stretch FontDescription::get_stretch() const
{
  return ((Stretch)(pango_font_description_get_stretch(const_cast<PangoFontDescription*>(gobj()))));
}

void FontDescription::set_size(int size)
{
  pango_font_description_set_size(gobj(), size);
}

int FontDescription::get_size() const
{
  return pango_font_description_get_size(const_cast<PangoFontDescription*>(gobj()));
}

FontMask FontDescription::get_set_fields() const
{
  return ((FontMask)(pango_font_description_get_set_fields(const_cast<PangoFontDescription*>(gobj()))));
}

void FontDescription::unset_fields(FontMask to_unset)
{
  pango_font_description_unset_fields(gobj(), ((PangoFontMask)(to_unset)));
}

void FontDescription::merge(const FontDescription& desc_to_merge, bool replace_existing)
{
  pango_font_description_merge(gobj(), (desc_to_merge).gobj(), static_cast<int>(replace_existing));
}

bool FontDescription::better_match(const FontDescription& old_match, const FontDescription& new_match) const
{
  return pango_font_description_better_match(const_cast<PangoFontDescription*>(gobj()), (old_match).gobj(), (new_match).gobj());
}

Glib::ustring FontDescription::to_string() const
{
  return Glib::convert_return_gchar_ptr_to_ustring(pango_font_description_to_string(const_cast<PangoFontDescription*>(gobj())));
}

Glib::ustring FontDescription::to_filename() const
{
  return Glib::convert_return_gchar_ptr_to_ustring(pango_font_description_to_filename(const_cast<PangoFontDescription*>(gobj())));
}


bool operator==(const FontDescription& lhs, const FontDescription& rhs)
{
  return (pango_font_description_equal(lhs.gobj(), rhs.gobj()) != 0);
}

bool operator!=(const FontDescription& lhs, const FontDescription& rhs)
{
  return (pango_font_description_equal(lhs.gobj(), rhs.gobj()) == 0);
}


} // namespace Pango