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