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.PgFontMap;
26 
27 private import glib.Str;
28 private import gobject.ObjectG;
29 public  import gtkc.pangotypes;
30 private import pango.PgContext;
31 private import pango.PgFont;
32 private import pango.PgFontDescription;
33 private import pango.PgFontFamily;
34 private import pango.PgFontset;
35 private import pango.PgLanguage;
36 private import pango.c.functions;
37 public  import pango.c.types;
38 
39 
40 /**
41  * The #PangoFontMap represents the set of fonts available for a
42  * particular rendering system. This is a virtual object with
43  * implementations being specific to particular rendering systems.  To
44  * create an implementation of a #PangoFontMap, the rendering-system
45  * specific code should allocate a larger structure that contains a nested
46  * #PangoFontMap, fill in the <structfield>klass</structfield> member of the nested #PangoFontMap with a
47  * pointer to a appropriate #PangoFontMapClass, then call
48  * pango_font_map_init() on the structure.
49  * 
50  * The #PangoFontMap structure contains one member which the implementation
51  * fills in.
52  */
53 public class PgFontMap : ObjectG
54 {
55 	/** the main Gtk struct */
56 	protected PangoFontMap* pangoFontMap;
57 
58 	/** Get the main Gtk struct */
59 	public PangoFontMap* getPgFontMapStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return pangoFontMap;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)pangoFontMap;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (PangoFontMap* pangoFontMap, bool ownedRef = false)
76 	{
77 		this.pangoFontMap = pangoFontMap;
78 		super(cast(GObject*)pangoFontMap, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return pango_font_map_get_type();
86 	}
87 
88 	/**
89 	 * Forces a change in the context, which will cause any #PangoContext
90 	 * using this fontmap to change.
91 	 *
92 	 * This function is only useful when implementing a new backend
93 	 * for Pango, something applications won't do. Backends should
94 	 * call this function if they have attached extra data to the context
95 	 * and such data is changed.
96 	 *
97 	 * Since: 1.34
98 	 */
99 	public void changed()
100 	{
101 		pango_font_map_changed(pangoFontMap);
102 	}
103 
104 	/**
105 	 * Creates a #PangoContext connected to @fontmap.  This is equivalent
106 	 * to pango_context_new() followed by pango_context_set_font_map().
107 	 *
108 	 * If you are using Pango as part of a higher-level system,
109 	 * that system may have it's own way of create a #PangoContext.
110 	 * For instance, the GTK+ toolkit has, among others,
111 	 * gdk_pango_context_get_for_screen(), and
112 	 * gtk_widget_get_pango_context().  Use those instead.
113 	 *
114 	 * Returns: the newly allocated #PangoContext,
115 	 *     which should be freed with g_object_unref().
116 	 *
117 	 * Since: 1.22
118 	 */
119 	public PgContext createContext()
120 	{
121 		auto p = pango_font_map_create_context(pangoFontMap);
122 
123 		if(p is null)
124 		{
125 			return null;
126 		}
127 
128 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
129 	}
130 
131 	/**
132 	 * Returns the current serial number of @fontmap.  The serial number is
133 	 * initialized to an small number larger than zero when a new fontmap
134 	 * is created and is increased whenever the fontmap is changed. It may
135 	 * wrap, but will never have the value 0. Since it can wrap, never compare
136 	 * it with "less than", always use "not equals".
137 	 *
138 	 * The fontmap can only be changed using backend-specific API, like changing
139 	 * fontmap resolution.
140 	 *
141 	 * This can be used to automatically detect changes to a #PangoFontMap, like
142 	 * in #PangoContext.
143 	 *
144 	 * Returns: The current serial number of @fontmap.
145 	 *
146 	 * Since: 1.32.4
147 	 */
148 	public uint getSerial()
149 	{
150 		return pango_font_map_get_serial(pangoFontMap);
151 	}
152 
153 	/**
154 	 * Returns the render ID for shape engines for this fontmap.
155 	 * See the <structfield>render_type</structfield> field of
156 	 * #PangoEngineInfo.
157 	 *
158 	 * Returns: the ID string for shape engines for
159 	 *     this fontmap. Owned by Pango, should not be modified
160 	 *     or freed.
161 	 *
162 	 * Since: 1.4
163 	 */
164 	public string getShapeEngineType()
165 	{
166 		return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap));
167 	}
168 
169 	/**
170 	 * List all families for a fontmap.
171 	 *
172 	 * Params:
173 	 *     families = location to store a pointer to an array of #PangoFontFamily *.
174 	 *         This array should be freed with g_free().
175 	 */
176 	public void listFamilies(out PgFontFamily[] families)
177 	{
178 		PangoFontFamily** outfamilies = null;
179 		int nFamilies;
180 
181 		pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies);
182 
183 		families = new PgFontFamily[nFamilies];
184 		for(size_t i = 0; i < nFamilies; i++)
185 		{
186 			families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]);
187 		}
188 	}
189 
190 	/**
191 	 * Load the font in the fontmap that is the closest match for @desc.
192 	 *
193 	 * Params:
194 	 *     context = the #PangoContext the font will be used with
195 	 *     desc = a #PangoFontDescription describing the font to load
196 	 *
197 	 * Returns: the newly allocated #PangoFont
198 	 *     loaded, or %NULL if no font matched.
199 	 */
200 	public PgFont loadFont(PgContext context, PgFontDescription desc)
201 	{
202 		auto p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct());
203 
204 		if(p is null)
205 		{
206 			return null;
207 		}
208 
209 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true);
210 	}
211 
212 	/**
213 	 * Load a set of fonts in the fontmap that can be used to render
214 	 * a font matching @desc.
215 	 *
216 	 * Params:
217 	 *     context = the #PangoContext the font will be used with
218 	 *     desc = a #PangoFontDescription describing the font to load
219 	 *     language = a #PangoLanguage the fonts will be used for
220 	 *
221 	 * Returns: the newly allocated
222 	 *     #PangoFontset loaded, or %NULL if no font matched.
223 	 */
224 	public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language)
225 	{
226 		auto p = pango_font_map_load_fontset(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct());
227 
228 		if(p is null)
229 		{
230 			return null;
231 		}
232 
233 		return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p, true);
234 	}
235 }