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 = PgFontDescription
29  * strct   = PangoFontDescription
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgFontDescription
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_font_description_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * 	- PangoFontDescription* -> PgFontDescription
49  * module aliases:
50  * local aliases:
51  * overrides:
52  * 	- toString
53  */
54 
55 module pango.PgFontDescription;
56 
57 public  import gtkc.pangotypes;
58 
59 private import gtkc.pango;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import glib.Str;
64 
65 
66 private import gobject.Boxed;
67 
68 /**
69  * Pango supports a flexible architecture where a
70  * particular rendering architecture can supply an
71  * implementation of fonts. The PangoFont structure
72  * represents an abstract rendering-system-independent font.
73  * Pango provides routines to list available fonts, and
74  * to load a font of a given description.
75  */
76 public class PgFontDescription : Boxed
77 {
78 	
79 	/** the main Gtk struct */
80 	protected PangoFontDescription* pangoFontDescription;
81 	
82 	
83 	/** Get the main Gtk struct */
84 	public PangoFontDescription* getPgFontDescriptionStruct()
85 	{
86 		return pangoFontDescription;
87 	}
88 	
89 	
90 	/** the main Gtk struct as a void* */
91 	protected void* getStruct()
92 	{
93 		return cast(void*)pangoFontDescription;
94 	}
95 	
96 	/**
97 	 * Sets our main struct and passes it to the parent class
98 	 */
99 	public this (PangoFontDescription* pangoFontDescription)
100 	{
101 		this.pangoFontDescription = pangoFontDescription;
102 	}
103 	
104 	/**
105 	 * Creates a nwe font description and set the family nd the size
106 	 * Params:
107 	 *  family = Family
108 	 *  size = Size
109 	 */
110 	public this(string family, int size)
111 	{
112 		this();
113 		setFamily(family);
114 		setSize(size * PANGO_SCALE);
115 	}
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Creates a new font description structure with all fields unset.
122 	 * Throws: ConstructionException GTK+ fails to create the object.
123 	 */
124 	public this ()
125 	{
126 		// PangoFontDescription * pango_font_description_new (void);
127 		auto p = pango_font_description_new();
128 		if(p is null)
129 		{
130 			throw new ConstructionException("null returned by pango_font_description_new()");
131 		}
132 		this(cast(PangoFontDescription*) p);
133 	}
134 	
135 	/**
136 	 * Make a copy of a PangoFontDescription.
137 	 * Returns: the newly allocated PangoFontDescription, which should be freed with pango_font_description_free(), or NULL if desc was NULL.
138 	 */
139 	public PgFontDescription copy()
140 	{
141 		// PangoFontDescription * pango_font_description_copy (const PangoFontDescription *desc);
142 		auto p = pango_font_description_copy(pangoFontDescription);
143 		
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 		
149 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
150 	}
151 	
152 	/**
153 	 * Like pango_font_description_copy(), but only a shallow copy is made
154 	 * of the family name and other allocated fields. The result can only
155 	 * be used until desc is modified or freed. This is meant to be used
156 	 * when the copy is only needed temporarily.
157 	 * Returns: the newly allocated PangoFontDescription, which should be freed with pango_font_description_free(), or NULL if desc was NULL.
158 	 */
159 	public PgFontDescription copyStatic()
160 	{
161 		// PangoFontDescription * pango_font_description_copy_static  (const PangoFontDescription *desc);
162 		auto p = pango_font_description_copy_static(pangoFontDescription);
163 		
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 		
169 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
170 	}
171 	
172 	/**
173 	 * Computes a hash of a PangoFontDescription structure suitable
174 	 * to be used, for example, as an argument to g_hash_table_new().
175 	 * The hash value is independent of desc->mask.
176 	 * Returns: the hash value.
177 	 */
178 	public uint hash()
179 	{
180 		// guint pango_font_description_hash (const PangoFontDescription *desc);
181 		return pango_font_description_hash(pangoFontDescription);
182 	}
183 	
184 	/**
185 	 * Compares two font descriptions for equality. Two font descriptions
186 	 * are considered equal if the fonts they describe are provably identical.
187 	 * This means that their masks do not have to match, as long as other fields
188 	 * are all the same. (Two font descriptions may result in identical fonts
189 	 * being loaded, but still compare FALSE.)
190 	 * Params:
191 	 * desc2 = another PangoFontDescription
192 	 * Returns: TRUE if the two font descriptions are identical, FALSE otherwise.
193 	 */
194 	public int equal(PgFontDescription desc2)
195 	{
196 		// gboolean pango_font_description_equal (const PangoFontDescription *desc1,  const PangoFontDescription *desc2);
197 		return pango_font_description_equal(pangoFontDescription, (desc2 is null) ? null : desc2.getPgFontDescriptionStruct());
198 	}
199 	
200 	/**
201 	 * Frees a font description.
202 	 */
203 	public void free()
204 	{
205 		// void pango_font_description_free (PangoFontDescription *desc);
206 		pango_font_description_free(pangoFontDescription);
207 	}
208 	
209 	/**
210 	 * Sets the family name field of a font description. The family
211 	 * name represents a family of related font styles, and will
212 	 * resolve to a particular PangoFontFamily. In some uses of
213 	 * PangoFontDescription, it is also possible to use a comma
214 	 * separated list of family names for this field.
215 	 * Params:
216 	 * family = a string representing the family name.
217 	 */
218 	public void setFamily(string family)
219 	{
220 		// void pango_font_description_set_family (PangoFontDescription *desc,  const char *family);
221 		pango_font_description_set_family(pangoFontDescription, Str.toStringz(family));
222 	}
223 	
224 	/**
225 	 * Like pango_font_description_set_family(), except that no
226 	 * copy of family is made. The caller must make sure that the
227 	 * string passed in stays around until desc has been freed
228 	 * or the name is set again. This function can be used if
229 	 * family is a static string such as a C string literal, or
230 	 * if desc is only needed temporarily.
231 	 * Params:
232 	 * family = a string representing the family name.
233 	 */
234 	public void setFamilyStatic(string family)
235 	{
236 		// void pango_font_description_set_family_static  (PangoFontDescription *desc,  const char *family);
237 		pango_font_description_set_family_static(pangoFontDescription, Str.toStringz(family));
238 	}
239 	
240 	/**
241 	 * Gets the family name field of a font description. See
242 	 * pango_font_description_set_family().
243 	 * Returns: the family name field for the font description, or NULL if not previously set. This has the same life-time as the font description itself and should not be freed.
244 	 */
245 	public string getFamily()
246 	{
247 		// const char * pango_font_description_get_family (const PangoFontDescription *desc);
248 		return Str.toString(pango_font_description_get_family(pangoFontDescription));
249 	}
250 	
251 	/**
252 	 * Sets the style field of a PangoFontDescription. The
253 	 * PangoStyle enumeration describes whether the font is slanted and
254 	 * the manner in which it is slanted; it can be either
255 	 * PANGO_STYLE_NORMAL, PANGO_STYLE_ITALIC, or PANGO_STYLE_OBLIQUE.
256 	 * Most fonts will either have a italic style or an oblique
257 	 * style, but not both, and font matching in Pango will
258 	 * match italic specifications with oblique fonts and vice-versa
259 	 * if an exact match is not found.
260 	 * Params:
261 	 * style = the style for the font description
262 	 */
263 	public void setStyle(PangoStyle style)
264 	{
265 		// void pango_font_description_set_style (PangoFontDescription *desc,  PangoStyle style);
266 		pango_font_description_set_style(pangoFontDescription, style);
267 	}
268 	
269 	/**
270 	 * Gets the style field of a PangoFontDescription. See
271 	 * pango_font_description_set_style().
272 	 * Returns: the style field for the font description. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
273 	 */
274 	public PangoStyle getStyle()
275 	{
276 		// PangoStyle pango_font_description_get_style (const PangoFontDescription *desc);
277 		return pango_font_description_get_style(pangoFontDescription);
278 	}
279 	
280 	/**
281 	 * Sets the variant field of a font description. The PangoVariant
282 	 * can either be PANGO_VARIANT_NORMAL or PANGO_VARIANT_SMALL_CAPS.
283 	 * Params:
284 	 * variant = the variant type for the font description.
285 	 */
286 	public void setVariant(PangoVariant variant)
287 	{
288 		// void pango_font_description_set_variant (PangoFontDescription *desc,  PangoVariant variant);
289 		pango_font_description_set_variant(pangoFontDescription, variant);
290 	}
291 	
292 	/**
293 	 * Gets the variant field of a PangoFontDescription. See
294 	 * pango_font_description_set_variant().
295 	 * Returns: the variant field for the font description. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
296 	 */
297 	public PangoVariant getVariant()
298 	{
299 		// PangoVariant pango_font_description_get_variant (const PangoFontDescription *desc);
300 		return pango_font_description_get_variant(pangoFontDescription);
301 	}
302 	
303 	/**
304 	 * Sets the weight field of a font description. The weight field
305 	 * specifies how bold or light the font should be. In addition
306 	 * to the values of the PangoWeight enumeration, other intermediate
307 	 * numeric values are possible.
308 	 * Params:
309 	 * weight = the weight for the font description.
310 	 */
311 	public void setWeight(PangoWeight weight)
312 	{
313 		// void pango_font_description_set_weight (PangoFontDescription *desc,  PangoWeight weight);
314 		pango_font_description_set_weight(pangoFontDescription, weight);
315 	}
316 	
317 	/**
318 	 * Gets the weight field of a font description. See
319 	 * pango_font_description_set_weight().
320 	 * Returns: the weight field for the font description. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
321 	 */
322 	public PangoWeight getWeight()
323 	{
324 		// PangoWeight pango_font_description_get_weight (const PangoFontDescription *desc);
325 		return pango_font_description_get_weight(pangoFontDescription);
326 	}
327 	
328 	/**
329 	 * Sets the stretch field of a font description. The stretch field
330 	 * specifies how narrow or wide the font should be.
331 	 * Params:
332 	 * stretch = the stretch for the font description
333 	 */
334 	public void setStretch(PangoStretch stretch)
335 	{
336 		// void pango_font_description_set_stretch (PangoFontDescription *desc,  PangoStretch stretch);
337 		pango_font_description_set_stretch(pangoFontDescription, stretch);
338 	}
339 	
340 	/**
341 	 * Gets the stretch field of a font description.
342 	 * See pango_font_description_set_stretch().
343 	 * Returns: the stretch field for the font description. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
344 	 */
345 	public PangoStretch getStretch()
346 	{
347 		// PangoStretch pango_font_description_get_stretch (const PangoFontDescription *desc);
348 		return pango_font_description_get_stretch(pangoFontDescription);
349 	}
350 	
351 	/**
352 	 * Sets the size field of a font description in fractional points. This is mutually
353 	 * exclusive with pango_font_description_set_absolute_size().
354 	 * Params:
355 	 * size = the size of the font in points, scaled by PANGO_SCALE. (That is,
356 	 * a size value of 10 * PANGO_SCALE is a 10 point font. The conversion
357 	 * factor between points and device units depends on system configuration
358 	 * and the output device. For screen display, a logical DPI of 96 is
359 	 * common, in which case a 10 point font corresponds to a 10 * (96 / 72) = 13.3
360 	 * pixel font. Use pango_font_description_set_absolute_size() if you need
361 	 * a particular size in device units.
362 	 */
363 	public void setSize(int size)
364 	{
365 		// void pango_font_description_set_size (PangoFontDescription *desc,  gint size);
366 		pango_font_description_set_size(pangoFontDescription, size);
367 	}
368 	
369 	/**
370 	 * Gets the size field of a font description.
371 	 * See pango_font_description_set_size().
372 	 * Returns: the size field for the font description in points or device units. You must call pango_font_description_get_size_is_absolute() to find out which is the case. Returns 0 if the size field has not previously been set or it has been set to 0 explicitly. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
373 	 */
374 	public int getSize()
375 	{
376 		// gint pango_font_description_get_size (const PangoFontDescription *desc);
377 		return pango_font_description_get_size(pangoFontDescription);
378 	}
379 	
380 	/**
381 	 * Sets the size field of a font description, in device units. This is mutually
382 	 * exclusive with pango_font_description_set_size() which sets the font size
383 	 * in points.
384 	 * Since 1.8
385 	 * Params:
386 	 * size = the new size, in Pango units. There are PANGO_SCALE Pango units in one
387 	 * device unit. For an output backend where a device unit is a pixel, a size
388 	 * value of 10 * PANGO_SCALE gives a 10 pixel font.
389 	 */
390 	public void setAbsoluteSize(double size)
391 	{
392 		// void pango_font_description_set_absolute_size  (PangoFontDescription *desc,  double size);
393 		pango_font_description_set_absolute_size(pangoFontDescription, size);
394 	}
395 	
396 	/**
397 	 * Determines whether the size of the font is in points (not absolute) or device units (absolute).
398 	 * See pango_font_description_set_size() and pango_font_description_set_absolute_size().
399 	 * Since 1.8
400 	 * Returns: whether the size for the font description is in points or device units. Use pango_font_description_get_set_fields() to find out if the size field of the font description was explicitly set or not.
401 	 */
402 	public int getSizeIsAbsolute()
403 	{
404 		// gboolean pango_font_description_get_size_is_absolute  (const PangoFontDescription *desc);
405 		return pango_font_description_get_size_is_absolute(pangoFontDescription);
406 	}
407 	
408 	/**
409 	 * Sets the gravity field of a font description. The gravity field
410 	 * specifies how the glyphs should be rotated. If gravity is
411 	 * PANGO_GRAVITY_AUTO, this actually unsets the gravity mask on
412 	 * the font description.
413 	 * This function is seldom useful to the user. Gravity should normally
414 	 * be set on a PangoContext.
415 	 * Since 1.16
416 	 * Params:
417 	 * gravity = the gravity for the font description.
418 	 */
419 	public void setGravity(PangoGravity gravity)
420 	{
421 		// void pango_font_description_set_gravity (PangoFontDescription *desc,  PangoGravity gravity);
422 		pango_font_description_set_gravity(pangoFontDescription, gravity);
423 	}
424 	
425 	/**
426 	 * Gets the gravity field of a font description. See
427 	 * pango_font_description_set_gravity().
428 	 * Since 1.16
429 	 * Returns: the gravity field for the font description. Use pango_font_description_get_set_fields() to find out if the field was explicitly set or not.
430 	 */
431 	public PangoGravity getGravity()
432 	{
433 		// PangoGravity pango_font_description_get_gravity (const PangoFontDescription *desc);
434 		return pango_font_description_get_gravity(pangoFontDescription);
435 	}
436 	
437 	/**
438 	 * Determines which fields in a font description have been set.
439 	 * Returns: a bitmask with bits set corresponding to the fields in desc that have been set.
440 	 */
441 	public PangoFontMask getSetFields()
442 	{
443 		// PangoFontMask pango_font_description_get_set_fields  (const PangoFontDescription *desc);
444 		return pango_font_description_get_set_fields(pangoFontDescription);
445 	}
446 	
447 	/**
448 	 * Unsets some of the fields in a PangoFontDescription. The unset
449 	 * fields will get back to their default values.
450 	 * Params:
451 	 * toUnset = bitmask of fields in the desc to unset.
452 	 */
453 	public void unsetFields(PangoFontMask toUnset)
454 	{
455 		// void pango_font_description_unset_fields (PangoFontDescription *desc,  PangoFontMask to_unset);
456 		pango_font_description_unset_fields(pangoFontDescription, toUnset);
457 	}
458 	
459 	/**
460 	 * Merges the fields that are set in desc_to_merge into the fields in
461 	 * desc. If replace_existing is FALSE, only fields in desc that
462 	 * are not already set are affected. If TRUE, then fields that are
463 	 * already set will be replaced as well.
464 	 * If desc_to_merge is NULL, this function performs nothing.
465 	 * Params:
466 	 * desc = a PangoFontDescription
467 	 * descToMerge = the PangoFontDescription to merge from, or NULL. [allow-none]
468 	 * replaceExisting = if TRUE, replace fields in desc with the
469 	 * corresponding values from desc_to_merge, even if they
470 	 * are already exist.
471 	 */
472 	public void merge(PgFontDescription descToMerge, int replaceExisting)
473 	{
474 		// void pango_font_description_merge (PangoFontDescription *desc,  const PangoFontDescription *desc_to_merge,  gboolean replace_existing);
475 		pango_font_description_merge(pangoFontDescription, (descToMerge is null) ? null : descToMerge.getPgFontDescriptionStruct(), replaceExisting);
476 	}
477 	
478 	/**
479 	 * Like pango_font_description_merge(), but only a shallow copy is made
480 	 * of the family name and other allocated fields. desc can only be
481 	 * used until desc_to_merge is modified or freed. This is meant
482 	 * to be used when the merged font description is only needed temporarily.
483 	 * Params:
484 	 * desc = a PangoFontDescription
485 	 * descToMerge = the PangoFontDescription to merge from
486 	 * replaceExisting = if TRUE, replace fields in desc with the
487 	 * corresponding values from desc_to_merge, even if they
488 	 * are already exist.
489 	 */
490 	public void mergeStatic(PgFontDescription descToMerge, int replaceExisting)
491 	{
492 		// void pango_font_description_merge_static (PangoFontDescription *desc,  const PangoFontDescription *desc_to_merge,  gboolean replace_existing);
493 		pango_font_description_merge_static(pangoFontDescription, (descToMerge is null) ? null : descToMerge.getPgFontDescriptionStruct(), replaceExisting);
494 	}
495 	
496 	/**
497 	 * Determines if the style attributes of new_match are a closer match
498 	 * for desc than those of old_match are, or if old_match is NULL,
499 	 * determines if new_match is a match at all.
500 	 * Approximate matching is done for
501 	 * weight and style; other style attributes must match exactly.
502 	 * Style attributes are all attributes other than family and size-related
503 	 * attributes. Approximate matching for style considers PANGO_STYLE_OBLIQUE
504 	 * and PANGO_STYLE_ITALIC as matches, but not as good a match as when the
505 	 * styles are equal.
506 	 * Note that old_match must match desc.
507 	 * Params:
508 	 * oldMatch = a PangoFontDescription, or NULL. [allow-none]
509 	 * newMatch = a PangoFontDescription
510 	 * Returns: TRUE if new_match is a better match
511 	 */
512 	public int betterMatch(PgFontDescription oldMatch, PgFontDescription newMatch)
513 	{
514 		// gboolean pango_font_description_better_match (const PangoFontDescription *desc,  const PangoFontDescription *old_match,  const PangoFontDescription *new_match);
515 		return pango_font_description_better_match(pangoFontDescription, (oldMatch is null) ? null : oldMatch.getPgFontDescriptionStruct(), (newMatch is null) ? null : newMatch.getPgFontDescriptionStruct());
516 	}
517 	
518 	/**
519 	 * Creates a new font description from a string representation in the
520 	 * form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a
521 	 * comma separated list of families optionally terminated by a comma,
522 	 * STYLE_OPTIONS is a whitespace separated list of words where each WORD
523 	 * describes one of style, variant, weight, stretch, or gravity, and SIZE
524 	 * is a decimal number (size in points) or optionally followed by the
525 	 * unit modifier "px" for absolute size. Any one of the options may
526 	 * be absent. If FAMILY-LIST is absent, then the family_name field of
527 	 * the resulting font description will be initialized to NULL. If
528 	 * STYLE-OPTIONS is missing, then all style options will be set to the
529 	 * default values. If SIZE is missing, the size in the resulting font
530 	 * description will be set to 0.
531 	 * Params:
532 	 * str = string representation of a font description.
533 	 * Returns: a new PangoFontDescription.
534 	 */
535 	public static PgFontDescription fromString(string str)
536 	{
537 		// PangoFontDescription * pango_font_description_from_string  (const char *str);
538 		auto p = pango_font_description_from_string(Str.toStringz(str));
539 		
540 		if(p is null)
541 		{
542 			return null;
543 		}
544 		
545 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
546 	}
547 	
548 	/**
549 	 * Creates a string representation of a font description. See
550 	 * pango_font_description_from_string() for a description of the
551 	 * format of the string representation. The family list in the
552 	 * string description will only have a terminating comma if the
553 	 * last word of the list is a valid style option.
554 	 * Returns: a new string that must be freed with g_free().
555 	 */
556 	public override string toString()
557 	{
558 		// char * pango_font_description_to_string (const PangoFontDescription *desc);
559 		return Str.toString(pango_font_description_to_string(pangoFontDescription));
560 	}
561 	
562 	/**
563 	 * Creates a filename representation of a font description. The
564 	 * filename is identical to the result from calling
565 	 * pango_font_description_to_string(), but with underscores instead of
566 	 * characters that are untypical in filenames, and in lower case only.
567 	 * Returns: a new string that must be freed with g_free().
568 	 */
569 	public string toFilename()
570 	{
571 		// char * pango_font_description_to_filename (const PangoFontDescription *desc);
572 		return Str.toString(pango_font_description_to_filename(pangoFontDescription));
573 	}
574 }