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  * Conversion parameters:
26  * inFile  = 
27  * outPack = pango
28  * outFile = PgFontMap
29  * strct   = PangoFontMap
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgFontMap
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GObject
38  * implements:
39  * prefixes:
40  * 	- pango_font_map_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- pango.PgFont
48  * 	- pango.PgFontset
49  * 	- pango.PgContext
50  * 	- pango.PgFontDescription
51  * 	- pango.PgLanguage
52  * 	- pango.PgFontFamily
53  * structWrap:
54  * 	- PangoContext* -> PgContext
55  * 	- PangoFont* -> PgFont
56  * 	- PangoFontDescription* -> PgFontDescription
57  * 	- PangoFontFamily* -> PgFontFamily
58  * 	- PangoFontset* -> PgFontset
59  * 	- PangoLanguage* -> PgLanguage
60  * module aliases:
61  * local aliases:
62  * overrides:
63  */
64 
65 module pango.PgFontMap;
66 
67 public  import gtkc.pangotypes;
68 
69 private import gtkc.pango;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 private import glib.Str;
74 private import pango.PgFont;
75 private import pango.PgFontset;
76 private import pango.PgContext;
77 private import pango.PgFontDescription;
78 private import pango.PgLanguage;
79 private import pango.PgFontFamily;
80 
81 
82 private import gobject.ObjectG;
83 
84 /**
85  * Pango supports a flexible architecture where a
86  * particular rendering architecture can supply an
87  * implementation of fonts. The PangoFont structure
88  * represents an abstract rendering-system-independent font.
89  * Pango provides routines to list available fonts, and
90  * to load a font of a given description.
91  */
92 public class PgFontMap : ObjectG
93 {
94 	
95 	/** the main Gtk struct */
96 	protected PangoFontMap* pangoFontMap;
97 	
98 	
99 	/** Get the main Gtk struct */
100 	public PangoFontMap* getPgFontMapStruct()
101 	{
102 		return pangoFontMap;
103 	}
104 	
105 	
106 	/** the main Gtk struct as a void* */
107 	protected override void* getStruct()
108 	{
109 		return cast(void*)pangoFontMap;
110 	}
111 	
112 	/**
113 	 * Sets our main struct and passes it to the parent class
114 	 */
115 	public this (PangoFontMap* pangoFontMap)
116 	{
117 		super(cast(GObject*)pangoFontMap);
118 		this.pangoFontMap = pangoFontMap;
119 	}
120 	
121 	protected override void setStruct(GObject* obj)
122 	{
123 		super.setStruct(obj);
124 		pangoFontMap = cast(PangoFontMap*)obj;
125 	}
126 	
127 	/**
128 	 */
129 	
130 	/**
131 	 * Creates a PangoContext connected to fontmap. This is equivalent
132 	 * to pango_context_new() followed by pango_context_set_font_map().
133 	 * If you are using Pango as part of a higher-level system,
134 	 * that system may have it's own way of create a PangoContext.
135 	 * For instance, the GTK+ toolkit has, among others,
136 	 * gdk_pango_context_get_for_screen(), and
137 	 * gtk_widget_get_pango_context(). Use those instead.
138 	 * Since 1.22
139 	 * Returns: the newly allocated PangoContext, which should be freed with g_object_unref(). [transfer full]
140 	 */
141 	public PgContext createContext()
142 	{
143 		// PangoContext * pango_font_map_create_context (PangoFontMap *fontmap);
144 		auto p = pango_font_map_create_context(pangoFontMap);
145 		
146 		if(p is null)
147 		{
148 			return null;
149 		}
150 		
151 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p);
152 	}
153 	
154 	/**
155 	 * Load the font in the fontmap that is the closest match for desc.
156 	 * Params:
157 	 * context = the PangoContext the font will be used with
158 	 * desc = a PangoFontDescription describing the font to load
159 	 * Returns: the newly allocated PangoFont loaded, or NULL if no font matched. [transfer full]
160 	 */
161 	public PgFont loadFont(PgContext context, PgFontDescription desc)
162 	{
163 		// PangoFont * pango_font_map_load_font (PangoFontMap *fontmap,  PangoContext *context,  const PangoFontDescription *desc);
164 		auto p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct());
165 		
166 		if(p is null)
167 		{
168 			return null;
169 		}
170 		
171 		return ObjectG.getDObject!(PgFont)(cast(PangoFont*) p);
172 	}
173 	
174 	/**
175 	 * Load a set of fonts in the fontmap that can be used to render
176 	 * a font matching desc.
177 	 * Params:
178 	 * context = the PangoContext the font will be used with
179 	 * desc = a PangoFontDescription describing the font to load
180 	 * language = a PangoLanguage the fonts will be used for
181 	 * Returns: the newly allocated PangoFontset loaded, or NULL if no font matched. [transfer full]
182 	 */
183 	public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language)
184 	{
185 		// PangoFontset * pango_font_map_load_fontset (PangoFontMap *fontmap,  PangoContext *context,  const PangoFontDescription *desc,  PangoLanguage *language);
186 		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());
187 		
188 		if(p is null)
189 		{
190 			return null;
191 		}
192 		
193 		return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) p);
194 	}
195 	
196 	/**
197 	 * List all families for a fontmap.
198 	 * Params:
199 	 * families = location to store a pointer to an array of PangoFontFamily *.
200 	 * This array should be freed with g_free(). [out][array length=n_families][transfer container]
201 	 */
202 	public void listFamilies(out PgFontFamily[] families)
203 	{
204 		// void pango_font_map_list_families (PangoFontMap *fontmap,  PangoFontFamily ***families,  int *n_families);
205 		PangoFontFamily** outfamilies = null;
206 		int nFamilies;
207 		
208 		pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies);
209 		
210 		
211 		families = new PgFontFamily[nFamilies];
212 		for(int i = 0; i < nFamilies; i++)
213 		{
214 			families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]);
215 		}
216 	}
217 	
218 	/**
219 	 * Returns the render ID for shape engines for this fontmap.
220 	 * See the render_type field of
221 	 * PangoEngineInfo.
222 	 * Since 1.4
223 	 * Returns: the ID string for shape engines for this fontmap. Owned by Pango, should not be modified or freed.
224 	 */
225 	public string getShapeEngineType()
226 	{
227 		// const char * pango_font_map_get_shape_engine_type  (PangoFontMap *fontmap);
228 		return Str.toString(pango_font_map_get_shape_engine_type(pangoFontMap));
229 	}
230 	
231 	/**
232 	 * Returns the current serial number of fontmap. The serial number is
233 	 * initialized to an small number larger than zero when a new fontmap
234 	 * is created and is increased whenever the fontmap is changed. It may
235 	 * wrap, but will never have the value 0. Since it can wrap, never compare
236 	 * it with "less than", always use "not equals".
237 	 * The fontmap can only be changed using backend-specific API, like changing
238 	 * fontmap resolution.
239 	 * This can be used to automatically detect changes to a PangoFontMap, like
240 	 * in PangoContext.
241 	 * Since 1.32.4
242 	 * Returns: The current serial number of fontmap.
243 	 */
244 	public uint getSerial()
245 	{
246 		// guint pango_font_map_get_serial (PangoFontMap *fontmap);
247 		return pango_font_map_get_serial(pangoFontMap);
248 	}
249 }