1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module pango.c.font;
7 
8 import pango.c.coverage;
9 import pango.c.types;
10 import pango.c.engine;
11 import pango.c.fontmap;
12 
13 import glib;
14 import gobject;
15 
16 
17 extern (C):
18 
19 /**
20  * PangoFontDescription:
21  *
22  * The #PangoFontDescription structure represents the description
23  * of an ideal font. These structures are used both to list
24  * what fonts are available on the system and also for specifying
25  * the characteristics of a font to load.
26  */
27 struct PangoFontDescription;
28 
29 /**
30  * PangoStyle:
31  * @PANGO_STYLE_NORMAL: the font is upright.
32  * @PANGO_STYLE_OBLIQUE: the font is slanted, but in a roman style.
33  * @PANGO_STYLE_ITALIC: the font is slanted in an italic style.
34  *
35  * An enumeration specifying the various slant styles possible for a font.
36  **/
37 enum PangoStyle {
38   PANGO_STYLE_NORMAL,
39   PANGO_STYLE_OBLIQUE,
40   PANGO_STYLE_ITALIC
41 }
42 
43 /**
44  * PangoVariant:
45  * @PANGO_VARIANT_NORMAL: A normal font.
46  * @PANGO_VARIANT_SMALL_CAPS: A font with the lower case characters
47  * replaced by smaller variants of the capital characters.
48  *
49  * An enumeration specifying capitalization variant of the font.
50  */
51 enum PangoVariant {
52   PANGO_VARIANT_NORMAL,
53   PANGO_VARIANT_SMALL_CAPS
54 }
55 
56 /**
57  * PangoWeight:
58  * @PANGO_WEIGHT_THIN: the thin weight (= 100; Since: 1.24)
59  * @PANGO_WEIGHT_ULTRALIGHT: the ultralight weight (= 200)
60  * @PANGO_WEIGHT_LIGHT: the light weight (= 300)
61  * @PANGO_WEIGHT_SEMILIGHT: the semilight weight (= 350; Since: 1.36.7)
62  * @PANGO_WEIGHT_BOOK: the book weight (= 380; Since: 1.24)
63  * @PANGO_WEIGHT_NORMAL: the default weight (= 400)
64  * @PANGO_WEIGHT_MEDIUM: the normal weight (= 500; Since: 1.24)
65  * @PANGO_WEIGHT_SEMIBOLD: the semibold weight (= 600)
66  * @PANGO_WEIGHT_BOLD: the bold weight (= 700)
67  * @PANGO_WEIGHT_ULTRABOLD: the ultrabold weight (= 800)
68  * @PANGO_WEIGHT_HEAVY: the heavy weight (= 900)
69  * @PANGO_WEIGHT_ULTRAHEAVY: the ultraheavy weight (= 1000; Since: 1.24)
70  *
71  * An enumeration specifying the weight (boldness) of a font. This is a numerical
72  * value ranging from 100 to 1000, but there are some predefined values:
73  */
74 enum PangoWeight {
75   PANGO_WEIGHT_THIN = 100,
76   PANGO_WEIGHT_ULTRALIGHT = 200,
77   PANGO_WEIGHT_LIGHT = 300,
78   PANGO_WEIGHT_SEMILIGHT = 350,
79   PANGO_WEIGHT_BOOK = 380,
80   PANGO_WEIGHT_NORMAL = 400,
81   PANGO_WEIGHT_MEDIUM = 500,
82   PANGO_WEIGHT_SEMIBOLD = 600,
83   PANGO_WEIGHT_BOLD = 700,
84   PANGO_WEIGHT_ULTRABOLD = 800,
85   PANGO_WEIGHT_HEAVY = 900,
86   PANGO_WEIGHT_ULTRAHEAVY = 1000
87 }
88 
89 /**
90  * PangoStretch:
91  * @PANGO_STRETCH_ULTRA_CONDENSED: ultra condensed width
92  * @PANGO_STRETCH_EXTRA_CONDENSED: extra condensed width
93  * @PANGO_STRETCH_CONDENSED: condensed width
94  * @PANGO_STRETCH_SEMI_CONDENSED: semi condensed width
95  * @PANGO_STRETCH_NORMAL: the normal width
96  * @PANGO_STRETCH_SEMI_EXPANDED: semi expanded width
97  * @PANGO_STRETCH_EXPANDED: expanded width
98  * @PANGO_STRETCH_EXTRA_EXPANDED: extra expanded width
99  * @PANGO_STRETCH_ULTRA_EXPANDED: ultra expanded width
100  *
101  * An enumeration specifying the width of the font relative to other designs
102  * within a family.
103  */
104 enum PangoStretch {
105   PANGO_STRETCH_ULTRA_CONDENSED,
106   PANGO_STRETCH_EXTRA_CONDENSED,
107   PANGO_STRETCH_CONDENSED,
108   PANGO_STRETCH_SEMI_CONDENSED,
109   PANGO_STRETCH_NORMAL,
110   PANGO_STRETCH_SEMI_EXPANDED,
111   PANGO_STRETCH_EXPANDED,
112   PANGO_STRETCH_EXTRA_EXPANDED,
113   PANGO_STRETCH_ULTRA_EXPANDED
114 }
115 
116 /**
117  * PangoFontMask:
118  * @PANGO_FONT_MASK_FAMILY: the font family is specified.
119  * @PANGO_FONT_MASK_STYLE: the font style is specified.
120  * @PANGO_FONT_MASK_VARIANT: the font variant is specified.
121  * @PANGO_FONT_MASK_WEIGHT: the font weight is specified.
122  * @PANGO_FONT_MASK_STRETCH: the font stretch is specified.
123  * @PANGO_FONT_MASK_SIZE: the font size is specified.
124  * @PANGO_FONT_MASK_GRAVITY: the font gravity is specified (Since: 1.16.)
125  *
126  * The bits in a #PangoFontMask correspond to fields in a
127  * #PangoFontDescription that have been set.
128  */
129 enum PangoFontMask {
130   PANGO_FONT_MASK_FAMILY  = 1 << 0,
131   PANGO_FONT_MASK_STYLE   = 1 << 1,
132   PANGO_FONT_MASK_VARIANT = 1 << 2,
133   PANGO_FONT_MASK_WEIGHT  = 1 << 3,
134   PANGO_FONT_MASK_STRETCH = 1 << 4,
135   PANGO_FONT_MASK_SIZE    = 1 << 5,
136   PANGO_FONT_MASK_GRAVITY = 1 << 6
137 }
138 
139 /* CSS scale factors (1.2 factor between each size) */
140 /**
141  * PANGO_SCALE_XX_SMALL:
142  *
143  * The scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).
144  */
145 /**
146  * PANGO_SCALE_X_SMALL:
147  *
148  * The scale factor for two shrinking steps (1 / (1.2 * 1.2)).
149  */
150 /**
151  * PANGO_SCALE_SMALL:
152  *
153  * The scale factor for one shrinking step (1 / 1.2).
154  */
155 /**
156  * PANGO_SCALE_MEDIUM:
157  *
158  * The scale factor for normal size (1.0).
159  */
160 /**
161  * PANGO_SCALE_LARGE:
162  *
163  * The scale factor for one magnification step (1.2).
164  */
165 /**
166  * PANGO_SCALE_X_LARGE:
167  *
168  * The scale factor for two magnification steps (1.2 * 1.2).
169  */
170 /**
171  * PANGO_SCALE_XX_LARGE:
172  *
173  * The scale factor for three magnification steps (1.2 * 1.2 * 1.2).
174  */
175 enum double PANGO_SCALE_XX_SMALL = 0.5787037037037;
176 enum double PANGO_SCALE_X_SMALL = 0.6444444444444;
177 enum double PANGO_SCALE_SMALL = 0.8333333333333;
178 enum double PANGO_SCALE_MEDIUM = 1.0;
179 enum double PANGO_SCALE_LARGE = 1.2;
180 enum double PANGO_SCALE_X_LARGE = 1.4399999999999;
181 enum double PANGO_SCALE_XX_LARGE = 1.728;
182 
183 /*
184  * PangoFontDescription
185  */
186 
187 pure GType pango_font_description_get_type();
188 PangoFontDescription *pango_font_description_new ();
189 PangoFontDescription *pango_font_description_copy (const(PangoFontDescription) *desc);
190 
191 pure PangoFontDescription * pango_font_description_copy_static (const(PangoFontDescription)  *desc);
192 
193 pure guint                  pango_font_description_hash (const(PangoFontDescription)  *desc);
194 
195 pure gboolean               pango_font_description_equal (
196                                     const(PangoFontDescription)  *desc1,
197                                     const(PangoFontDescription)  *desc2);
198 
199 void                        pango_font_description_free (PangoFontDescription *desc);
200 
201 void                        pango_font_descriptions_free (PangoFontDescription  **descs, int n_descs);
202 
203 void                        pango_font_description_set_family        (PangoFontDescription *desc,
204 							       const(char)           *family);
205 
206 void                        pango_font_description_set_family_static (PangoFontDescription *desc,
207 							       const(char)           *family);
208 
209 pure const(char)          * pango_font_description_get_family        (const(PangoFontDescription) *desc);
210 
211 void                        pango_font_description_set_style         (PangoFontDescription *desc,
212 							       PangoStyle            style);
213 
214 pure PangoStyle             pango_font_description_get_style         (const(PangoFontDescription) *desc);
215 
216 void                        pango_font_description_set_variant       (PangoFontDescription *desc,
217 							       PangoVariant          variant);
218 
219 pure PangoVariant           pango_font_description_get_variant       (const(PangoFontDescription) *desc);
220 
221 void                        pango_font_description_set_weight        (PangoFontDescription *desc,
222 							       PangoWeight           weight);
223 
224 pure PangoWeight            pango_font_description_get_weight        (const(PangoFontDescription) *desc);
225 
226 void                        pango_font_description_set_stretch       (PangoFontDescription *desc,
227 							       PangoStretch          stretch);
228 
229 pure PangoStretch           pango_font_description_get_stretch       (const(PangoFontDescription) *desc);
230 
231 void                        pango_font_description_set_size          (PangoFontDescription *desc,
232 							       gint                  size);
233 
234 pure gint                   pango_font_description_get_size          (const(PangoFontDescription) *desc);
235 
236 void                        pango_font_description_set_absolute_size (PangoFontDescription *desc,
237 							       double                size);
238 
239 pure gboolean               pango_font_description_get_size_is_absolute (const(PangoFontDescription) *desc);
240 
241 void                        pango_font_description_set_gravity       (PangoFontDescription *desc,
242 							       PangoGravity          gravity);
243 
244 pure PangoGravity           pango_font_description_get_gravity       (const(PangoFontDescription) *desc);
245 
246 pure PangoFontMask          pango_font_description_get_set_fields (const(PangoFontDescription) *desc);
247 
248 void                        pango_font_description_unset_fields   (PangoFontDescription       *desc,
249 						     PangoFontMask               to_unset);
250 
251 void                        pango_font_description_merge        (PangoFontDescription       *desc,
252 					  const(PangoFontDescription) *desc_to_merge,
253 					  gboolean                    replace_existing);
254 
255 void                        pango_font_description_merge_static (PangoFontDescription       *desc,
256 					  const(PangoFontDescription) *desc_to_merge,
257 					  gboolean                    replace_existing);
258 
259 pure gboolean               pango_font_description_better_match (const(PangoFontDescription) *desc,
260 					      const(PangoFontDescription) *old_match,
261 					      const(PangoFontDescription) *new_match);
262 
263 PangoFontDescription *pango_font_description_from_string (const(char)                  *str);
264 
265 char *                pango_font_description_to_string   (const(PangoFontDescription)  *desc);
266 
267 char *                pango_font_description_to_filename (const(PangoFontDescription)  *desc);
268 
269 /*
270  * PangoFontMetrics
271  */
272 version (Backend) {}
273 else {
274     struct PangoFontMetrics;
275 }
276 
277 pure GType             pango_font_metrics_get_type                    ();
278 PangoFontMetrics *     pango_font_metrics_ref                         (PangoFontMetrics *metrics);
279 void                   pango_font_metrics_unref                       (PangoFontMetrics *metrics);
280 pure int               pango_font_metrics_get_ascent                  (PangoFontMetrics *metrics);
281 pure int               pango_font_metrics_get_descent                 (PangoFontMetrics *metrics);
282 pure int               pango_font_metrics_get_approximate_char_width  (PangoFontMetrics *metrics);
283 pure int               pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics);
284 pure int               pango_font_metrics_get_underline_position      (PangoFontMetrics *metrics);
285 pure int               pango_font_metrics_get_underline_thickness     (PangoFontMetrics *metrics);
286 pure int               pango_font_metrics_get_strikethrough_position  (PangoFontMetrics *metrics);
287 pure int               pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics);
288 
289 
290 version (Backend) {
291 
292     PangoFontMetrics *pango_font_metrics_new ();
293 
294     /**
295     * PangoFontMetrics:
296     *
297     * A #PangoFontMetrics structure holds the overall metric information
298     * for a font (possibly restricted to a script). The fields of this
299     * structure are private to implementations of a font backend. See
300     * the documentation of the corresponding getters for documentation
301     * of their meaning.
302     */
303     struct PangoFontMetrics
304     {
305       guint ref_count;
306 
307       int ascent;
308       int descent;
309       int approximate_char_width;
310       int approximate_digit_width;
311       int underline_position;
312       int underline_thickness;
313       int strikethrough_position;
314       int strikethrough_thickness;
315     }
316 
317 }
318 
319 /*
320  * PangoFontFamily
321  */
322 
323 version(Backend) {}
324 else {
325     struct PangoFontFamily;
326 }
327 
328 pure GType      pango_font_family_get_type       ();
329 
330 void                 pango_font_family_list_faces (PangoFontFamily  *family,
331 						   PangoFontFace  ***faces,
332 						   int              *n_faces);
333 pure const(char) *pango_font_family_get_name   (PangoFontFamily  *family);
334 pure gboolean   pango_font_family_is_monospace         (PangoFontFamily  *family);
335 
336 
337 version (Backend) {
338 
339     /**
340      * PangoFontFamily:
341      *
342      * The #PangoFontFamily structure is used to represent a family of related
343      * font faces. The faces in a family share a common design, but differ in
344      * slant, weight, width and other aspects.
345      */
346     struct PangoFontFamily
347     {
348       GObject parent_instance;
349     }
350 
351     struct PangoFontFamilyClass
352     {
353       GObjectClass parent_class;
354 
355       /*< public >*/
356 
357       void  function      (PangoFontFamily  *family,
358 			        PangoFontFace  ***faces,
359 			        int              *n_faces) list_faces;
360       const(char) * function (PangoFontFamily  *family) get_name;
361       gboolean function (PangoFontFamily *family) is_monospace;
362 
363       /*< private >*/
364 
365       /* Padding for future expansion */
366       void function () _pango_reserved2;
367       void function () _pango_reserved3;
368       void function () _pango_reserved4;
369     }
370 
371 }
372 
373 /*
374  * PangoFontFace
375  */
376 
377 version(Backend) {}
378 else {
379     struct PangoFontFace;
380 }
381 
382 pure GType      pango_font_face_get_type       ();
383 
384 PangoFontDescription *pango_font_face_describe       (PangoFontFace  *face);
385 const(char)           *pango_font_face_get_face_name  (PangoFontFace  *face);
386 void                  pango_font_face_list_sizes     (PangoFontFace  *face,
387 						      int           **sizes,
388 						      int            *n_sizes);
389 gboolean              pango_font_face_is_synthesized (PangoFontFace  *face);
390 
391 
392 version (Backend) {
393     /**
394      * PangoFontFace:
395      *
396      * The #PangoFontFace structure is used to represent a group of fonts with
397      * the same family, slant, weight, width, but varying sizes.
398      */
399     struct PangoFontFace
400     {
401       GObject parent_instance;
402     }
403 
404     struct PangoFontFaceClass
405     {
406       GObjectClass parent_class;
407 
408       /*< public >*/
409 
410       const(char)           * function  (PangoFontFace *face) get_face_name;
411       PangoFontDescription * function       (PangoFontFace *face) describe;
412       void                   function     (PangoFontFace  *face,
413 					        int           **sizes,
414 					        int            *n_sizes) list_sizes;
415       gboolean               function (PangoFontFace *face) is_synthesized;
416 
417       /*< private >*/
418 
419       /* Padding for future expansion */
420       void function () _pango_reserved3;
421       void function () _pango_reserved4;
422     }
423 }
424 
425 /*
426  * PangoFont
427  */
428 version (Backend) {}
429 else {
430     struct PangoFont;
431 }
432 
433 pure GType                 pango_font_get_type          ();
434 
435 PangoFontDescription *pango_font_describe          (PangoFont        *font);
436 PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont        *font);
437 PangoCoverage *       pango_font_get_coverage      (PangoFont        *font,
438 						    PangoLanguage    *language);
439 PangoEngineShape *    pango_font_find_shaper       (PangoFont        *font,
440 						    PangoLanguage    *language,
441 						    guint32           ch);
442 PangoFontMetrics *    pango_font_get_metrics       (PangoFont        *font,
443 						    PangoLanguage    *language);
444 void                  pango_font_get_glyph_extents (PangoFont        *font,
445 						    PangoGlyph        glyph,
446 						    PangoRectangle   *ink_rect,
447 						    PangoRectangle   *logical_rect);
448 PangoFontMap         *pango_font_get_font_map      (PangoFont        *font);
449 
450 
451 version (Backend) {
452     /**
453      * PangoFont:
454      *
455      * The #PangoFont structure is used to represent
456      * a font in a rendering-system-independent matter.
457      * To create an implementation of a #PangoFont,
458      * the rendering-system specific code should allocate
459      * a larger structure that contains a nested
460      * #PangoFont, fill in the <structfield>klass</structfield> member of
461      * the nested #PangoFont with a pointer to
462      * a appropriate #PangoFontClass, then call
463      * pango_font_init() on the structure.
464      *
465      * The #PangoFont structure contains one member
466      * which the implementation fills in.
467      */
468     struct PangoFont
469     {
470       GObject parent_instance;
471     }
472 
473     struct PangoFontClass
474     {
475       GObjectClass parent_class;
476 
477       /*< public >*/
478 
479       PangoFontDescription *function           (PangoFont      *font) describe;
480       PangoCoverage *       function       (PangoFont      *font,
481 					           PangoLanguage  *lang) get_coverage;
482       PangoEngineShape *    function        (PangoFont      *font,
483 					           PangoLanguage  *lang,
484 					           guint32         ch) find_shaper;
485       void                  function  (PangoFont      *font,
486 					           PangoGlyph      glyph,
487 					           PangoRectangle *ink_rect,
488 					           PangoRectangle *logical_rect) get_glyph_extents;
489       PangoFontMetrics *    function        (PangoFont      *font,
490 					           PangoLanguage  *language) get_metrics;
491       PangoFontMap *        function       (PangoFont      *font) get_font_map;
492       PangoFontDescription *function  (PangoFont      *font) describe_absolute;
493       /*< private >*/
494 
495       /* Padding for future expansion */
496       void function () _pango_reserved1;
497       void function () _pango_reserved2;
498     }
499 
500     /* used for very rare and miserable situtations that we cannot even
501      * draw a hexbox
502      */
503     enum PANGO_UNKNOWN_GLYPH_WIDTH = 10;
504     enum PANGO_UNKNOWN_GLYPH_HEIGHT = 14;
505 
506 }
507 
508 /**
509  * PANGO_GLYPH_EMPTY:
510  *
511  * The %PANGO_GLYPH_EMPTY macro represents a #PangoGlyph value that has a
512  *  special meaning, which is a zero-width empty glyph.  This is useful for
513  * example in shaper modules, to use as the glyph for various zero-width
514  * Unicode characters (those passing pango_is_zero_width()).
515  */
516 /**
517  * PANGO_GLYPH_INVALID_INPUT:
518  *
519  * The %PANGO_GLYPH_INVALID_INPUT macro represents a #PangoGlyph value that has a
520  * special meaning of invalid input.  #PangoLayout produces one such glyph
521  * per invalid input UTF-8 byte and such a glyph is rendered as a crossed
522  * box.
523  *
524  * Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG
525  * on.
526  *
527  * Since: 1.20
528  */
529 /**
530  * PANGO_GLYPH_UNKNOWN_FLAG:
531  *
532  * The %PANGO_GLYPH_UNKNOWN_FLAG macro is a flag value that can be added to
533  * a #gunichar value of a valid Unicode character, to produce a #PangoGlyph
534  * value, representing an unknown-character glyph for the respective #gunichar.
535  */
536 /**
537  * PANGO_GET_UNKNOWN_GLYPH:
538  * @wc: a Unicode character
539  *
540  * The way this unknown glyphs are rendered is backend specific.  For example,
541  * a box with the hexadecimal Unicode code-point of the character written in it
542  * is what is done in the most common backends.
543  *
544  * Returns: a #PangoGlyph value that means no glyph was found for @wc.
545  */
546 enum PangoGlyph PANGO_GLYPH_EMPTY = 0x0FFFFFFF;
547 enum PangoGlyph PANGO_GLYPH_INVALID_INPUT = 0xFFFFFFFF;
548 enum PangoGlyph PANGO_GLYPH_UNKNOWN_FLAG = 0x10000000;
549 PangoGlyph PANGO_GET_UNKNOWN_GLYPH(WC)(WC wc) { return cast(PangoGlyph)(wc) | PANGO_GLYPH_UNKNOWN_FLAG; }
550