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.PgFontset;
26 
27 private import gobject.ObjectG;
28 private import gtkc.pango;
29 public  import gtkc.pangotypes;
30 private import pango.PgFont;
31 private import pango.PgFontMetrics;
32 
33 
34 /**
35  * A #PangoFontset represents a set of #PangoFont to use
36  * when rendering text. It is the result of resolving a
37  * #PangoFontDescription against a particular #PangoContext.
38  * It has operations for finding the component font for
39  * a particular Unicode character, and for finding a composite
40  * set of metrics for the entire fontset.
41  */
42 public class PgFontset : ObjectG
43 {
44 	/** the main Gtk struct */
45 	protected PangoFontset* pangoFontset;
46 
47 	/** Get the main Gtk struct */
48 	public PangoFontset* getPgFontsetStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return pangoFontset;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected override void* getStruct()
57 	{
58 		return cast(void*)pangoFontset;
59 	}
60 
61 	protected override void setStruct(GObject* obj)
62 	{
63 		pangoFontset = cast(PangoFontset*)obj;
64 		super.setStruct(obj);
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (PangoFontset* pangoFontset, bool ownedRef = false)
71 	{
72 		this.pangoFontset = pangoFontset;
73 		super(cast(GObject*)pangoFontset, ownedRef);
74 	}
75 
76 
77 	/** */
78 	public static GType getType()
79 	{
80 		return pango_fontset_get_type();
81 	}
82 
83 	/**
84 	 * Iterates through all the fonts in a fontset, calling @func for
85 	 * each one. If @func returns %TRUE, that stops the iteration.
86 	 *
87 	 * Params:
88 	 *     func = Callback function
89 	 *     data = data to pass to the callback function
90 	 *
91 	 * Since: 1.4
92 	 */
93 	public void foreac(PangoFontsetForeachFunc func, void* data)
94 	{
95 		pango_fontset_foreach(pangoFontset, func, data);
96 	}
97 
98 	/**
99 	 * Returns the font in the fontset that contains the best glyph for the
100 	 * Unicode character @wc.
101 	 *
102 	 * Params:
103 	 *     wc = a Unicode character
104 	 *
105 	 * Returns: a #PangoFont. The caller must call
106 	 *     g_object_unref when finished with the font.
107 	 */
108 	public PgFont getFont(uint wc)
109 	{
110 		auto p = pango_fontset_get_font(pangoFontset, wc);
111 		
112 		if(p is null)
113 		{
114 			return null;
115 		}
116 		
117 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true);
118 	}
119 
120 	/**
121 	 * Get overall metric information for the fonts in the fontset.
122 	 *
123 	 * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
124 	 *     when finished using the object.
125 	 */
126 	public PgFontMetrics getMetrics()
127 	{
128 		auto p = pango_fontset_get_metrics(pangoFontset);
129 		
130 		if(p is null)
131 		{
132 			return null;
133 		}
134 		
135 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true);
136 	}
137 }