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 public  import gtkc.pangotypes;
31 private import pango.PgFontMap;
32 private import pango.c.functions;
33 public  import pango.c.types;
34 
35 
36 /**
37  * #PangoCairoFontMap is an interface exported by font maps for
38  * use with Cairo. The actual type of the font map will depend
39  * on the particular font technology Cairo was compiled to use.
40  *
41  * Since: 1.10
42  */
43 public class PgCairoFontMap : PgFontMap
44 {
45 	/** the main Gtk struct */
46 	protected PangoCairoFontMap* pangoCairoFontMap;
47 
48 	/** Get the main Gtk struct */
49 	public PangoCairoFontMap* getPgCairoFontMapStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return pangoCairoFontMap;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)pangoCairoFontMap;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (PangoCairoFontMap* pangoCairoFontMap, bool ownedRef = false)
66 	{
67 		this.pangoCairoFontMap = pangoCairoFontMap;
68 		super(cast(PangoFontMap*)pangoCairoFontMap, ownedRef);
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return pango_cairo_font_get_type();
76 	}
77 
78 	/**
79 	 * Gets a default #PangoCairoFontMap to use with Cairo.
80 	 *
81 	 * Note that the type of the returned object will depend
82 	 * on the particular font backend Cairo was compiled to use;
83 	 * You generally should only use the #PangoFontMap and
84 	 * #PangoCairoFontMap interfaces on the returned object.
85 	 *
86 	 * The default Cairo fontmap can be changed by using
87 	 * pango_cairo_font_map_set_default().  This can be used to
88 	 * change the Cairo font backend that the default fontmap
89 	 * uses for example.
90 	 *
91 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
92 	 * Each thread gets its own default fontmap.  In this way,
93 	 * PangoCairo can be used safely from multiple threads.
94 	 *
95 	 * Returns: the default PangoCairo fontmap
96 	 *     for the current thread. This object is owned by Pango and must not be freed.
97 	 *
98 	 * Since: 1.10
99 	 */
100 	public static PgFontMap getDefault()
101 	{
102 		auto p = pango_cairo_font_map_get_default();
103 
104 		if(p is null)
105 		{
106 			return null;
107 		}
108 
109 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p);
110 	}
111 
112 	/**
113 	 * Creates a new #PangoCairoFontMap object; a fontmap is used
114 	 * to cache information about available fonts, and holds
115 	 * certain global parameters such as the resolution.
116 	 * In most cases, you can use pango_cairo_font_map_get_default()
117 	 * instead.
118 	 *
119 	 * Note that the type of the returned object will depend
120 	 * on the particular font backend Cairo was compiled to use;
121 	 * You generally should only use the #PangoFontMap and
122 	 * #PangoCairoFontMap interfaces on the returned object.
123 	 *
124 	 * You can override the type of backend returned by using an
125 	 * environment variable %PANGOCAIRO_BACKEND.  Supported types,
126 	 * based on your build, are fc (fontconfig), win32, and coretext.
127 	 * If requested type is not available, NULL is returned. Ie.
128 	 * this is only useful for testing, when at least two backends
129 	 * are compiled in.
130 	 *
131 	 * Returns: the newly allocated #PangoFontMap,
132 	 *     which should be freed with g_object_unref().
133 	 *
134 	 * Since: 1.10
135 	 *
136 	 * Throws: ConstructionException GTK+ fails to create the object.
137 	 */
138 	public this()
139 	{
140 		auto p = pango_cairo_font_map_new();
141 
142 		if(p is null)
143 		{
144 			throw new ConstructionException("null returned by new");
145 		}
146 
147 		this(cast(PangoCairoFontMap*) p, true);
148 	}
149 
150 	/**
151 	 * Creates a new #PangoCairoFontMap object of the type suitable
152 	 * to be used with cairo font backend of type @fonttype.
153 	 *
154 	 * In most cases one should simply use @pango_cairo_font_map_new(),
155 	 * or in fact in most of those cases, just use
156 	 * @pango_cairo_font_map_get_default().
157 	 *
158 	 * Params:
159 	 *     fonttype = desired #cairo_font_type_t
160 	 *
161 	 * Returns: the newly allocated
162 	 *     #PangoFontMap of suitable type which should be freed
163 	 *     with g_object_unref(), or %NULL if the requested
164 	 *     cairo font backend is not supported / compiled in.
165 	 *
166 	 * Since: 1.18
167 	 *
168 	 * Throws: ConstructionException GTK+ fails to create the object.
169 	 */
170 	public this(cairo_font_type_t fonttype)
171 	{
172 		auto p = pango_cairo_font_map_new_for_font_type(fonttype);
173 
174 		if(p is null)
175 		{
176 			throw new ConstructionException("null returned by new_for_font_type");
177 		}
178 
179 		this(cast(PangoCairoFontMap*) p, true);
180 	}
181 
182 	/**
183 	 * Gets the type of Cairo font backend that @fontmap uses.
184 	 *
185 	 * Returns: the #cairo_font_type_t cairo font backend type
186 	 *
187 	 * Since: 1.18
188 	 */
189 	public cairo_font_type_t getFontType()
190 	{
191 		return pango_cairo_font_map_get_font_type(cast(PangoCairoFontMap*)pangoCairoFontMap);
192 	}
193 
194 	/**
195 	 * Gets the resolution for the fontmap. See pango_cairo_font_map_set_resolution()
196 	 *
197 	 * Returns: the resolution in "dots per inch"
198 	 *
199 	 * Since: 1.10
200 	 */
201 	public double getResolution()
202 	{
203 		return pango_cairo_font_map_get_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap);
204 	}
205 
206 	/**
207 	 * Sets a default #PangoCairoFontMap to use with Cairo.
208 	 *
209 	 * This can be used to change the Cairo font backend that the
210 	 * default fontmap uses for example.  The old default font map
211 	 * is unreffed and the new font map referenced.
212 	 *
213 	 * Note that since Pango 1.32.6, the default fontmap is per-thread.
214 	 * This function only changes the default fontmap for
215 	 * the current thread.   Default fontmaps of exisiting threads
216 	 * are not changed.  Default fontmaps of any new threads will
217 	 * still be created using pango_cairo_font_map_new().
218 	 *
219 	 * A value of %NULL for @fontmap will cause the current default
220 	 * font map to be released and a new default font
221 	 * map to be created on demand, using pango_cairo_font_map_new().
222 	 *
223 	 * Since: 1.22
224 	 */
225 	public void setDefault()
226 	{
227 		pango_cairo_font_map_set_default(cast(PangoCairoFontMap*)pangoCairoFontMap);
228 	}
229 
230 	/**
231 	 * Sets the resolution for the fontmap. This is a scale factor between
232 	 * points specified in a #PangoFontDescription and Cairo units. The
233 	 * default value is 96, meaning that a 10 point font will be 13
234 	 * units high. (10 * 96. / 72. = 13.3).
235 	 *
236 	 * Params:
237 	 *     dpi = the resolution in "dots per inch". (Physical inches aren't actually
238 	 *         involved; the terminology is conventional.)
239 	 *
240 	 * Since: 1.10
241 	 */
242 	public void setResolution(double dpi)
243 	{
244 		pango_cairo_font_map_set_resolution(cast(PangoCairoFontMap*)pangoCairoFontMap, dpi);
245 	}
246 
247 	/**
248 	 * Gets the #cairo_scaled_font_t used by @font.
249 	 * The scaled font can be referenced and kept using
250 	 * cairo_scaled_font_reference().
251 	 *
252 	 * Returns: the #cairo_scaled_font_t used by @font,
253 	 *     or %NULL if @font is %NULL.
254 	 *
255 	 * Since: 1.18
256 	 */
257 	public ScaledFont getScaledFont()
258 	{
259 		auto p = pango_cairo_font_get_scaled_font(cast(PangoCairoFont*)pangoCairoFontMap);
260 
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 
266 		return new ScaledFont(cast(cairo_scaled_font_t*) p);
267 	}
268 }