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 
87 	public static GType getType()
88 	{
89 		return pango_font_map_get_type();
90 	}
91 
92 	/**
93 	 * Forces a change in the context, which will cause any #PangoContext
94 	 * using this fontmap to change.
95 	 *
96 	 * This function is only useful when implementing a new backend
97 	 * for Pango, something applications won't do. Backends should
98 	 * call this function if they have attached extra data to the context
99 	 * and such data is changed.
100 	 *
101 	 * Since: 1.34
102 	 */
103 	public void changed()
104 	{
105 		pango_font_map_changed(pangoFontMap);
106 	}
107 
108 	/**
109 	 * Creates a #PangoContext connected to @fontmap.  This is equivalent
110 	 * to pango_context_new() followed by pango_context_set_font_map().
111 	 *
112 	 * If you are using Pango as part of a higher-level system,
113 	 * that system may have it's own way of create a #PangoContext.
114 	 * For instance, the GTK+ toolkit has, among others,
115 	 * gdk_pango_context_get_for_screen(), and
116 	 * gtk_widget_get_pango_context().  Use those instead.
117 	 *
118 	 * Return: the newly allocated #PangoContext,
119 	 *     which should be freed with g_object_unref().
120 	 *
121 	 * Since: 1.22
122 	 */
123 	public PgContext createContext()
124 	{
125 		auto p = pango_font_map_create_context(pangoFontMap);
126 		
127 		if(p is null)
128 		{
129 			return null;
130 		}
131 		
132 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true);
133 	}
134 
135 	/**
136 	 * Returns the current serial number of @fontmap.  The serial number is
137 	 * initialized to an small number larger than zero when a new fontmap
138 	 * is created and is increased whenever the fontmap is changed. It may
139 	 * wrap, but will never have the value 0. Since it can wrap, never compare
140 	 * it with "less than", always use "not equals".
141 	 *
142 	 * The fontmap can only be changed using backend-specific API, like changing
143 	 * fontmap resolution.
144 	 *
145 	 * This can be used to automatically detect changes to a #PangoFontMap, like
146 	 * in #PangoContext.
147 	 *
148 	 * Return: The current serial number of @fontmap.
149 	 *
150 	 * Since: 1.32.4
151 	 */
152 	public uint getSerial()
153 	{
154 		return pango_font_map_get_serial(pangoFontMap);
155 	}
156 
157 	/**
158 	 * Returns the render ID for shape engines for this fontmap.
159 	 * See the <structfield>render_type</structfield> field of
160 	 * #PangoEngineInfo.
161 	 *
162 	 * Return: the ID string for shape engines for
163 	 *     this fontmap. Owned by Pango, should not be modified
164 	 *     or freed.
165 	 *
166 	 * Since: 1.4
167 	 */
168 	public string getShapeEngineType()
169 	{
170 		return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap));
171 	}
172 
173 	/**
174 	 * List all families for a fontmap.
175 	 *
176 	 * Params:
177 	 *     families = location to store a pointer to an array of #PangoFontFamily *.
178 	 *         This array should be freed with g_free().
179 	 *     nFamilies = location to store the number of elements in @families
180 	 */
181 	public void listFamilies(out PgFontFamily[] families)
182 	{
183 		PangoFontFamily** outfamilies = null;
184 		int nFamilies;
185 		
186 		pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies);
187 		
188 		families = new PgFontFamily[nFamilies];
189 		for(size_t i = 0; i < nFamilies; i++)
190 		{
191 			families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]);
192 		}
193 	}
194 
195 	/**
196 	 * Load the font in the fontmap that is the closest match for @desc.
197 	 *
198 	 * Params:
199 	 *     context = the #PangoContext the font will be used with
200 	 *     desc = a #PangoFontDescription describing the font to load
201 	 *
202 	 * Return: the newly allocated #PangoFont loaded,
203 	 *     or %NULL if no font matched.
204 	 */
205 	public PgFont loadFont(PgContext context, PgFontDescription desc)
206 	{
207 		auto p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct());
208 		
209 		if(p is null)
210 		{
211 			return null;
212 		}
213 		
214 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p, true);
215 	}
216 
217 	/**
218 	 * Load a set of fonts in the fontmap that can be used to render
219 	 * a font matching @desc.
220 	 *
221 	 * Params:
222 	 *     context = the #PangoContext the font will be used with
223 	 *     desc = a #PangoFontDescription describing the font to load
224 	 *     language = a #PangoLanguage the fonts will be used for
225 	 *
226 	 * Return: the newly allocated #PangoFontset
227 	 *     loaded, or %NULL if no font matched.
228 	 */
229 	public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language)
230 	{
231 		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());
232 		
233 		if(p is null)
234 		{
235 			return null;
236 		}
237 		
238 		return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p, true);
239 	}
240 }