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