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