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