1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module pango.PgCairoFontMap;
26 
27 private import cairo.ScaledFont;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import pango.PgFontMap;
31 private import pango.c.functions;
32 public  import pango.c.types;
33 
34 
35 /**
36  * `PangoCairoFontMap` is an interface exported by font maps for
37  * use with Cairo.
38  * 
39  * The actual type of the font map will depend on the particular
40  * font technology Cairo was compiled to use.
41  *
42  * Since: 1.10
43  */
44 public class PgCairoFontMap : PgFontMap
45 {
46 	/** the main Gtk struct */
47 	protected PangoCairoFontMap* pangoCairoFontMap;
48 
49 	/** Get the main Gtk struct */
50 	public PangoCairoFontMap* getPgCairoFontMapStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return pangoCairoFontMap;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)pangoCairoFontMap;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (PangoCairoFontMap* pangoCairoFontMap, bool ownedRef = false)
67 	{
68 		this.pangoCairoFontMap = pangoCairoFontMap;
69 		super(cast(PangoFontMap*)pangoCairoFontMap, ownedRef);
70 	}
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return pango_cairo_font_get_type();
77 	}
78 
79 	/**
80 	 * Gets a default `PangoCairoFontMap` to use with Cairo.
81 	 *
82 	 * Note that the type of the returned object will depend on the
83 	 * particular font backend Cairo was compiled to use; you generally
84 	 * should only use the `PangoFontMap` and `PangoCairoFontMap`
85 	 * interfaces on the returned object.
86 	 *
87 	 * The default Cairo fontmap can be changed by using
88 	 * [method@PangoCairo.FontMap.set_default]. This can be used to
89 	 * change the Cairo font backend that the default fontmap uses
90 	 * for example.
91 	 *
92 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
93 	 * Each thread gets its own default fontmap. In this way, PangoCairo
94 	 * can be used safely from multiple threads.
95 	 *
96 	 * Returns: the default PangoCairo fontmap
97 	 *     for the current thread. This object is owned by Pango and must
98 	 *     not be freed.
99 	 *
100 	 * Since: 1.10
101 	 */
102 	public static PgFontMap getDefault()
103 	{
104 		auto __p = pango_cairo_font_map_get_default();
105 
106 		if(__p is null)
107 		{
108 			return null;
109 		}
110 
111 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) __p);
112 	}
113 
114 	/**
115 	 * Creates a new `PangoCairoFontMap` object.
116 	 *
117 	 * A fontmap is used to cache information about available fonts,
118 	 * and holds certain global parameters such as the resolution.
119 	 * In most cases, you can use `func@PangoCairo.font_map_get_default]
120 	 * instead.
121 	 *
122 	 * Note that the type of the returned object will depend
123 	 * on the particular font backend Cairo was compiled to use;
124 	 * You generally should only use the `PangoFontMap` and
125 	 * `PangoCairoFontMap` interfaces on the returned object.
126 	 *
127 	 * You can override the type of backend returned by using an
128 	 * environment variable %PANGOCAIRO_BACKEND. Supported types,
129 	 * based on your build, are fc (fontconfig), win32, and coretext.
130 	 * If requested type is not available, NULL is returned. Ie.
131 	 * this is only useful for testing, when at least two backends
132 	 * are compiled in.
133 	 *
134 	 * Returns: the newly allocated `PangoFontMap`,
135 	 *     which should be freed with g_object_unref().
136 	 *
137 	 * Since: 1.10
138 	 *
139 	 * Throws: ConstructionException GTK+ fails to create the object.
140 	 */
141 	public this()
142 	{
143 		auto __p = pango_cairo_font_map_new();
144 
145 		if(__p is null)
146 		{
147 			throw new ConstructionException("null returned by new");
148 		}
149 
150 		this(cast(PangoCairoFontMap*) __p, true);
151 	}
152 
153 	/**
154 	 * Creates a new `PangoCairoFontMap` object of the type suitable
155 	 * to be used with cairo font backend of type @fonttype.
156 	 *
157 	 * In most cases one should simply use [type_func@PangoCairo.FontMap.new], or
158 	 * in fact in most of those cases, just use [func@PangoCairo.FontMap.get_default].
159 	 *
160 	 * Params:
161 	 *     fonttype = desired #cairo_font_type_t
162 	 *
163 	 * Returns: the newly allocated
164 	 *     `PangoFontMap` of suitable type which should be freed with
165 	 *     g_object_unref(), or %NULL if the requested cairo font backend
166 	 *     is not supported / compiled in.
167 	 *
168 	 * Since: 1.18
169 	 *
170 	 * Throws: ConstructionException GTK+ fails to create the object.
171 	 */
172 	public this(cairo_font_type_t fonttype)
173 	{
174 		auto __p = pango_cairo_font_map_new_for_font_type(fonttype);
175 
176 		if(__p is null)
177 		{
178 			throw new ConstructionException("null returned by new_for_font_type");
179 		}
180 
181 		this(cast(PangoCairoFontMap*) __p, true);
182 	}
183 
184 	/**
185 	 * Gets the type of Cairo font backend that @fontmap uses.
186 	 *
187 	 * Returns: the `cairo_font_type_t` cairo font backend type
188 	 *
189 	 * Since: 1.18
190 	 */
191 	public cairo_font_type_t getFontType()
192 	{
193 		return pango_cairo_font_map_get_font_type(cast(PangoCairoFontMap*)pangoCairoFontMap);
194 	}
195 
196 	/**
197 	 * Gets the resolution for the fontmap.
198 	 *
199 	 * See [method@PangoCairo.FontMap.set_resolution].
200 	 *
201 	 * Returns: the resolution in "dots per inch"
202 	 *
203 	 * Since: 1.10
204 	 */
205 	public double getResolution()
206 	{
207 		return pango_cairo_font_map_get_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap);
208 	}
209 
210 	/**
211 	 * Sets a default `PangoCairoFontMap` to use with Cairo.
212 	 *
213 	 * This can be used to change the Cairo font backend that the
214 	 * default fontmap uses for example. The old default font map
215 	 * is unreffed and the new font map referenced.
216 	 *
217 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
218 	 * This function only changes the default fontmap for
219 	 * the current thread. Default fontmaps of existing threads
220 	 * are not changed. Default fontmaps of any new threads will
221 	 * still be created using [type_func@PangoCairo.FontMap.new].
222 	 *
223 	 * A value of %NULL for @fontmap will cause the current default
224 	 * font map to be released and a new default font map to be created
225 	 * on demand, using [type_func@PangoCairo.FontMap.new].
226 	 *
227 	 * Since: 1.22
228 	 */
229 	public void setDefault()
230 	{
231 		pango_cairo_font_map_set_default(cast(PangoCairoFontMap*)pangoCairoFontMap);
232 	}
233 
234 	/**
235 	 * Sets the resolution for the fontmap.
236 	 *
237 	 * This is a scale factor between
238 	 * points specified in a `PangoFontDescription` and Cairo units. The
239 	 * default value is 96, meaning that a 10 point font will be 13
240 	 * units high. (10 * 96. / 72. = 13.3).
241 	 *
242 	 * Params:
243 	 *     dpi = the resolution in "dots per inch". (Physical inches aren't actually
244 	 *         involved; the terminology is conventional.)
245 	 *
246 	 * Since: 1.10
247 	 */
248 	public void setResolution(double dpi)
249 	{
250 		pango_cairo_font_map_set_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap, dpi);
251 	}
252 
253 	/**
254 	 * Gets the `cairo_scaled_font_t` used by @font.
255 	 * The scaled font can be referenced and kept using
256 	 * cairo_scaled_font_reference().
257 	 *
258 	 * Returns: the `cairo_scaled_font_t`
259 	 *     used by @font, or %NULL if @font is %NULL.
260 	 *
261 	 * Since: 1.18
262 	 */
263 	public ScaledFont getScaledFont()
264 	{
265 		auto __p = pango_cairo_font_get_scaled_font(cast(PangoCairoFont*)pangoCairoFontMap);
266 
267 		if(__p is null)
268 		{
269 			return null;
270 		}
271 
272 		return new ScaledFont(cast(cairo_scaled_font_t*) __p);
273 	}
274 }