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 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (PangoFontset* pangoFontset, bool ownedRef = false)
66 	{
67 		this.pangoFontset = pangoFontset;
68 		super(cast(GObject*)pangoFontset, ownedRef);
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return pango_fontset_get_type();
76 	}
77 
78 	alias foreac = foreach_;
79 	/**
80 	 * Iterates through all the fonts in a fontset, calling @func for
81 	 * each one. If @func returns %TRUE, that stops the iteration.
82 	 *
83 	 * Params:
84 	 *     func = Callback function
85 	 *     data = data to pass to the callback function
86 	 *
87 	 * Since: 1.4
88 	 */
89 	public void foreach_(PangoFontsetForeachFunc func, void* data)
90 	{
91 		pango_fontset_foreach(pangoFontset, func, data);
92 	}
93 
94 	/**
95 	 * Returns the font in the fontset that contains the best glyph for the
96 	 * Unicode character @wc.
97 	 *
98 	 * Params:
99 	 *     wc = a Unicode character
100 	 *
101 	 * Returns: a #PangoFont. The caller must call
102 	 *     g_object_unref when finished with the font.
103 	 */
104 	public PgFont getFont(uint wc)
105 	{
106 		auto p = pango_fontset_get_font(pangoFontset, wc);
107 
108 		if(p is null)
109 		{
110 			return null;
111 		}
112 
113 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true);
114 	}
115 
116 	/**
117 	 * Get overall metric information for the fonts in the fontset.
118 	 *
119 	 * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
120 	 *     when finished using the object.
121 	 */
122 	public PgFontMetrics getMetrics()
123 	{
124 		auto p = pango_fontset_get_metrics(pangoFontset);
125 
126 		if(p is null)
127 		{
128 			return null;
129 		}
130 
131 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p, true);
132 	}
133 }