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  = pango-Fonts.html
27  * outPack = pango
28  * outFile = PgFont
29  * strct   = PangoFont
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgFont
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_font_
41  * omit structs:
42  * omit prefixes:
43  * 	- pango_font_description_
44  * 	- pango_font_descriptions_
45  * 	- pango_font_metrics_
46  * 	- pango_font_family_
47  * 	- pango_font_face_
48  * 	- pango_font_map_
49  * 	- pango_fontset_
50  * 	- pango_fontset_simple_
51  * omit code:
52  * omit signals:
53  * imports:
54  * 	- pango.PgEngineShape
55  * 	- pango.PgFontDescription
56  * 	- pango.PgCoverage
57  * 	- pango.PgFontMetrics
58  * 	- pango.PgFontMap
59  * 	- pango.PgLanguage
60  * structWrap:
61  * 	- PangoCoverage* -> PgCoverage
62  * 	- PangoEngineShape* -> PgEngineShape
63  * 	- PangoFontDescription* -> PgFontDescription
64  * 	- PangoFontMap* -> PgFontMap
65  * 	- PangoFontMetrics* -> PgFontMetrics
66  * 	- PangoLanguage* -> PgLanguage
67  * module aliases:
68  * local aliases:
69  * overrides:
70  */
71 
72 module pango.PgFont;
73 
74 public  import gtkc.pangotypes;
75 
76 private import gtkc.pango;
77 private import glib.ConstructionException;
78 private import gobject.ObjectG;
79 
80 
81 private import pango.PgEngineShape;
82 private import pango.PgFontDescription;
83 private import pango.PgCoverage;
84 private import pango.PgFontMetrics;
85 private import pango.PgFontMap;
86 private import pango.PgLanguage;
87 
88 
89 
90 private import gobject.ObjectG;
91 
92 /**
93  * Description
94  * Pango supports a flexible architecture where a
95  * particular rendering architecture can supply an
96  * implementation of fonts. The PangoFont structure
97  * represents an abstract rendering-system-independent font.
98  * Pango provides routines to list available fonts, and
99  * to load a font of a given description.
100  */
101 public class PgFont : ObjectG
102 {
103 	
104 	/** the main Gtk struct */
105 	protected PangoFont* pangoFont;
106 	
107 	
108 	public PangoFont* getPgFontStruct()
109 	{
110 		return pangoFont;
111 	}
112 	
113 	
114 	/** the main Gtk struct as a void* */
115 	protected override void* getStruct()
116 	{
117 		return cast(void*)pangoFont;
118 	}
119 	
120 	/**
121 	 * Sets our main struct and passes it to the parent class
122 	 */
123 	public this (PangoFont* pangoFont)
124 	{
125 		super(cast(GObject*)pangoFont);
126 		this.pangoFont = pangoFont;
127 	}
128 	
129 	protected override void setStruct(GObject* obj)
130 	{
131 		super.setStruct(obj);
132 		pangoFont = cast(PangoFont*)obj;
133 	}
134 	
135 	/**
136 	 */
137 	
138 	/**
139 	 * Finds the best matching shaper for a font for a particular
140 	 * language tag and character point.
141 	 * Params:
142 	 * language = the language tag
143 	 * ch = a Unicode character.
144 	 * Returns: the best matching shaper.
145 	 */
146 	public PgEngineShape findShaper(PgLanguage language, uint ch)
147 	{
148 		// PangoEngineShape * pango_font_find_shaper (PangoFont *font,  PangoLanguage *language,  guint32 ch);
149 		auto p = pango_font_find_shaper(pangoFont, (language is null) ? null : language.getPgLanguageStruct(), ch);
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return ObjectG.getDObject!(PgEngineShape)(cast(PangoEngineShape*) p);
157 	}
158 	
159 	/**
160 	 * Returns a description of the font, with font size set in points.
161 	 * Use pango_font_describe_with_absolute_size() if you want the font
162 	 * size in device units.
163 	 * Returns: a newly-allocated PangoFontDescription object.
164 	 */
165 	public PgFontDescription describe()
166 	{
167 		// PangoFontDescription * pango_font_describe (PangoFont *font);
168 		auto p = pango_font_describe(pangoFont);
169 		
170 		if(p is null)
171 		{
172 			return null;
173 		}
174 		
175 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
176 	}
177 	
178 	/**
179 	 * Returns a description of the font, with absolute font size set
180 	 * (in device units). Use pango_font_describe() if you want the font
181 	 * size in points.
182 	 * Since 1.14
183 	 * Returns: a newly-allocated PangoFontDescription object.
184 	 */
185 	public PgFontDescription describeWithAbsoluteSize()
186 	{
187 		// PangoFontDescription * pango_font_describe_with_absolute_size  (PangoFont *font);
188 		auto p = pango_font_describe_with_absolute_size(pangoFont);
189 		
190 		if(p is null)
191 		{
192 			return null;
193 		}
194 		
195 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
196 	}
197 	
198 	/**
199 	 * Computes the coverage map for a given font and language tag.
200 	 * Params:
201 	 * language = the language tag
202 	 * Returns: a newly-allocated PangoCoverage object.
203 	 */
204 	public PgCoverage getCoverage(PgLanguage language)
205 	{
206 		// PangoCoverage * pango_font_get_coverage (PangoFont *font,  PangoLanguage *language);
207 		auto p = pango_font_get_coverage(pangoFont, (language is null) ? null : language.getPgLanguageStruct());
208 		
209 		if(p is null)
210 		{
211 			return null;
212 		}
213 		
214 		return ObjectG.getDObject!(PgCoverage)(cast(PangoCoverage*) p);
215 	}
216 	
217 	/**
218 	 * Gets the logical and ink extents of a glyph within a font. The
219 	 * coordinate system for each rectangle has its origin at the
220 	 * base line and horizontal origin of the character with increasing
221 	 * coordinates extending to the right and down. The macros PANGO_ASCENT(),
222 	 * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert
223 	 * from the extents rectangle to more traditional font metrics. The units
224 	 * of the rectangles are in 1/PANGO_SCALE of a device unit.
225 	 * If font is NULL, this function gracefully sets some sane values in the
226 	 * output variables and returns.
227 	 * Params:
228 	 * glyph = the glyph index
229 	 * inkRect = rectangle used to store the extents of the glyph as drawn
230 	 *  or NULL to indicate that the result is not needed.
231 	 * logicalRect = rectangle used to store the logical extents of the glyph
232 	 *  or NULL to indicate that the result is not needed.
233 	 */
234 	public void getGlyphExtents(PangoGlyph glyph, PangoRectangle* inkRect, PangoRectangle* logicalRect)
235 	{
236 		// void pango_font_get_glyph_extents (PangoFont *font,  PangoGlyph glyph,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
237 		pango_font_get_glyph_extents(pangoFont, glyph, inkRect, logicalRect);
238 	}
239 	
240 	/**
241 	 * Gets overall metric information for a font. Since the metrics may be
242 	 * substantially different for different scripts, a language tag can
243 	 * be provided to indicate that the metrics should be retrieved that
244 	 * correspond to the script(s) used by that language.
245 	 * If font is NULL, this function gracefully sets some sane values in the
246 	 * output variables and returns.
247 	 * Params:
248 	 * language = language tag used to determine which script to get the metrics
249 	 *  for, or NULL to indicate to get the metrics for the entire
250 	 *  font.
251 	 * Returns: a PangoFontMetrics object. The caller must call pango_font_metrics_unref() when finished using the object.
252 	 */
253 	public PgFontMetrics getMetrics(PgLanguage language)
254 	{
255 		// PangoFontMetrics * pango_font_get_metrics (PangoFont *font,  PangoLanguage *language);
256 		auto p = pango_font_get_metrics(pangoFont, (language is null) ? null : language.getPgLanguageStruct());
257 		
258 		if(p is null)
259 		{
260 			return null;
261 		}
262 		
263 		return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) p);
264 	}
265 	
266 	/**
267 	 * Gets the font map for which the font was created.
268 	 * Note that the font maintains a weak reference
269 	 * to the font map, so if all references to font map are dropped, the font
270 	 * map will be finalized even if there are fonts created with the font
271 	 * map that are still alive. In that case this function will return NULL.
272 	 * It is the responsibility of the user to ensure that the font map is kept
273 	 * alive. In most uses this is not an issue as a PangoContext holds
274 	 * a reference to the font map.
275 	 * Since 1.10
276 	 * Returns: the PangoFontMap for the font, or NULL if font is NULL.
277 	 */
278 	public PgFontMap getFontMap()
279 	{
280 		// PangoFontMap * pango_font_get_font_map (PangoFont *font);
281 		auto p = pango_font_get_font_map(pangoFont);
282 		
283 		if(p is null)
284 		{
285 			return null;
286 		}
287 		
288 		return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p);
289 	}
290 }