pango-font.h 25.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/* Pango
 * pango-font.h: Font handling
 *
 * Copyright (C) 2000 Red Hat Software
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
15
16
17
18
19
20
21
22
23
24
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __PANGO_FONT_H__
#define __PANGO_FONT_H__

25
26
#include <pango/pango-coverage.h>
#include <pango/pango-types.h>
27

28
#include <glib-object.h>
Matthias Clasen's avatar
Matthias Clasen committed
29
#include <hb.h>
30

Owen Taylor's avatar
Owen Taylor committed
31
32
G_BEGIN_DECLS

33
34
35
/**
 * PangoFontDescription:
 *
Matthias Clasen's avatar
Matthias Clasen committed
36
37
38
39
40
41
 * A `PangoFontDescription` describes a font in an implementation-independent
 * manner.
 *
 * `PangoFontDescription` structures are used both to list what fonts are
 * available on the system and also for specifying the characteristics of
 * a font to load.
42
 */
43
typedef struct _PangoFontDescription PangoFontDescription;
Matthias Clasen's avatar
Matthias Clasen committed
44

45
46
47
/**
 * PangoFontMetrics:
 *
48
 * A `PangoFontMetrics` structure holds the overall metric information
Matthias Clasen's avatar
Matthias Clasen committed
49
50
51
52
53
54
 * for a font.
 *
 * The information in a `PangoFontMetrics` structure may be restricted
 * to a script. The fields of this structure are private to implementations
 * of a font backend. See the documentation of the corresponding getters
 * for documentation of their meaning.
55
56
57
58
59
60
61
62
 *
 * For an overview of the most important metrics, see:
 *
 * <picture>
 *   <source srcset="fontmetrics-dark.png" media="(prefers-color-scheme: dark)">
 *   <img alt="Font metrics" src="fontmetrics-light.png">
 * </picture>

63
 */
Owen Taylor's avatar
Owen Taylor committed
64
typedef struct _PangoFontMetrics PangoFontMetrics;
65

Owen Taylor's avatar
Owen Taylor committed
66
67
68
69
70
71
72
73
/**
 * PangoStyle:
 * @PANGO_STYLE_NORMAL: the font is upright.
 * @PANGO_STYLE_OBLIQUE: the font is slanted, but in a roman style.
 * @PANGO_STYLE_ITALIC: the font is slanted in an italic style.
 *
 * An enumeration specifying the various slant styles possible for a font.
 **/
74
75
76
77
78
79
typedef enum {
  PANGO_STYLE_NORMAL,
  PANGO_STYLE_OBLIQUE,
  PANGO_STYLE_ITALIC
} PangoStyle;

80
81
82
83
84
85
86
87
/**
 * PangoVariant:
 * @PANGO_VARIANT_NORMAL: A normal font.
 * @PANGO_VARIANT_SMALL_CAPS: A font with the lower case characters
 * replaced by smaller variants of the capital characters.
 *
 * An enumeration specifying capitalization variant of the font.
 */
88
89
90
91
92
typedef enum {
  PANGO_VARIANT_NORMAL,
  PANGO_VARIANT_SMALL_CAPS
} PangoVariant;

93
94
95
96
97
/**
 * PangoWeight:
 * @PANGO_WEIGHT_THIN: the thin weight (= 100; Since: 1.24)
 * @PANGO_WEIGHT_ULTRALIGHT: the ultralight weight (= 200)
 * @PANGO_WEIGHT_LIGHT: the light weight (= 300)
Behdad Esfahbod's avatar
Behdad Esfahbod committed
98
 * @PANGO_WEIGHT_SEMILIGHT: the semilight weight (= 350; Since: 1.36.7)
99
100
101
102
103
104
105
106
107
 * @PANGO_WEIGHT_BOOK: the book weight (= 380; Since: 1.24)
 * @PANGO_WEIGHT_NORMAL: the default weight (= 400)
 * @PANGO_WEIGHT_MEDIUM: the normal weight (= 500; Since: 1.24)
 * @PANGO_WEIGHT_SEMIBOLD: the semibold weight (= 600)
 * @PANGO_WEIGHT_BOLD: the bold weight (= 700)
 * @PANGO_WEIGHT_ULTRABOLD: the ultrabold weight (= 800)
 * @PANGO_WEIGHT_HEAVY: the heavy weight (= 900)
 * @PANGO_WEIGHT_ULTRAHEAVY: the ultraheavy weight (= 1000; Since: 1.24)
 *
Matthias Clasen's avatar
Matthias Clasen committed
108
109
110
111
 * An enumeration specifying the weight (boldness) of a font.
 *
 * This is a numerical value ranging from 100 to 1000, but there
 * are some predefined values.
112
 */
113
typedef enum {
114
  PANGO_WEIGHT_THIN = 100,
115
116
  PANGO_WEIGHT_ULTRALIGHT = 200,
  PANGO_WEIGHT_LIGHT = 300,
Behdad Esfahbod's avatar
Behdad Esfahbod committed
117
  PANGO_WEIGHT_SEMILIGHT = 350,
118
  PANGO_WEIGHT_BOOK = 380,
119
  PANGO_WEIGHT_NORMAL = 400,
120
  PANGO_WEIGHT_MEDIUM = 500,
121
  PANGO_WEIGHT_SEMIBOLD = 600,
122
123
  PANGO_WEIGHT_BOLD = 700,
  PANGO_WEIGHT_ULTRABOLD = 800,
124
125
  PANGO_WEIGHT_HEAVY = 900,
  PANGO_WEIGHT_ULTRAHEAVY = 1000
126
127
} PangoWeight;

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
 * PangoStretch:
 * @PANGO_STRETCH_ULTRA_CONDENSED: ultra condensed width
 * @PANGO_STRETCH_EXTRA_CONDENSED: extra condensed width
 * @PANGO_STRETCH_CONDENSED: condensed width
 * @PANGO_STRETCH_SEMI_CONDENSED: semi condensed width
 * @PANGO_STRETCH_NORMAL: the normal width
 * @PANGO_STRETCH_SEMI_EXPANDED: semi expanded width
 * @PANGO_STRETCH_EXPANDED: expanded width
 * @PANGO_STRETCH_EXTRA_EXPANDED: extra expanded width
 * @PANGO_STRETCH_ULTRA_EXPANDED: ultra expanded width
 *
 * An enumeration specifying the width of the font relative to other designs
 * within a family.
 */
143
144
145
146
147
148
149
150
151
152
153
154
typedef enum {
  PANGO_STRETCH_ULTRA_CONDENSED,
  PANGO_STRETCH_EXTRA_CONDENSED,
  PANGO_STRETCH_CONDENSED,
  PANGO_STRETCH_SEMI_CONDENSED,
  PANGO_STRETCH_NORMAL,
  PANGO_STRETCH_SEMI_EXPANDED,
  PANGO_STRETCH_EXPANDED,
  PANGO_STRETCH_EXTRA_EXPANDED,
  PANGO_STRETCH_ULTRA_EXPANDED
} PangoStretch;

155
156
157
158
159
160
161
162
163
/**
 * PangoFontMask:
 * @PANGO_FONT_MASK_FAMILY: the font family is specified.
 * @PANGO_FONT_MASK_STYLE: the font style is specified.
 * @PANGO_FONT_MASK_VARIANT: the font variant is specified.
 * @PANGO_FONT_MASK_WEIGHT: the font weight is specified.
 * @PANGO_FONT_MASK_STRETCH: the font stretch is specified.
 * @PANGO_FONT_MASK_SIZE: the font size is specified.
 * @PANGO_FONT_MASK_GRAVITY: the font gravity is specified (Since: 1.16.)
164
 * @PANGO_FONT_MASK_VARIATIONS: OpenType font variations are specified (Since: 1.42)
165
 *
Matthias Clasen's avatar
Matthias Clasen committed
166
167
 * The bits in a `PangoFontMask` correspond to the set fields in a
 * `PangoFontDescription`.
168
 */
Owen Taylor's avatar
Owen Taylor committed
169
170
171
172
173
174
typedef enum {
  PANGO_FONT_MASK_FAMILY  = 1 << 0,
  PANGO_FONT_MASK_STYLE   = 1 << 1,
  PANGO_FONT_MASK_VARIANT = 1 << 2,
  PANGO_FONT_MASK_WEIGHT  = 1 << 3,
  PANGO_FONT_MASK_STRETCH = 1 << 4,
175
  PANGO_FONT_MASK_SIZE    = 1 << 5,
176
177
  PANGO_FONT_MASK_GRAVITY = 1 << 6,
  PANGO_FONT_MASK_VARIATIONS = 1 << 7,
Owen Taylor's avatar
Owen Taylor committed
178
} PangoFontMask;
179
180

/* CSS scale factors (1.2 factor between each size) */
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**
 * PANGO_SCALE_XX_SMALL:
 *
 * The scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).
 */
/**
 * PANGO_SCALE_X_SMALL:
 *
 * The scale factor for two shrinking steps (1 / (1.2 * 1.2)).
 */
/**
 * PANGO_SCALE_SMALL:
 *
 * The scale factor for one shrinking step (1 / 1.2).
 */
/**
 * PANGO_SCALE_MEDIUM:
 *
 * The scale factor for normal size (1.0).
 */
/**
 * PANGO_SCALE_LARGE:
 *
 * The scale factor for one magnification step (1.2).
 */
/**
 * PANGO_SCALE_X_LARGE:
 *
 * The scale factor for two magnification steps (1.2 * 1.2).
 */
/**
 * PANGO_SCALE_XX_LARGE:
 *
 * The scale factor for three magnification steps (1.2 * 1.2 * 1.2).
 */
216
#define PANGO_SCALE_XX_SMALL ((double)0.5787037037037)
217
#define PANGO_SCALE_X_SMALL  ((double)0.6944444444444)
218
219
220
#define PANGO_SCALE_SMALL    ((double)0.8333333333333)
#define PANGO_SCALE_MEDIUM   ((double)1.0)
#define PANGO_SCALE_LARGE    ((double)1.2)
221
#define PANGO_SCALE_X_LARGE  ((double)1.44)
222
223
#define PANGO_SCALE_XX_LARGE ((double)1.728)

Owen Taylor's avatar
Owen Taylor committed
224
225
226
/*
 * PangoFontDescription
 */
Owen Taylor's avatar
Owen Taylor committed
227

228
229
#define PANGO_TYPE_FONT_DESCRIPTION (pango_font_description_get_type ())

230
PANGO_AVAILABLE_IN_ALL
231
GType                 pango_font_description_get_type    (void) G_GNUC_CONST;
232
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
233
PangoFontDescription *pango_font_description_new         (void);
234
PANGO_AVAILABLE_IN_ALL
235
PangoFontDescription *pango_font_description_copy        (const PangoFontDescription  *desc);
236
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
237
PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription  *desc);
238
PANGO_AVAILABLE_IN_ALL
239
guint                 pango_font_description_hash        (const PangoFontDescription  *desc) G_GNUC_PURE;
240
PANGO_AVAILABLE_IN_ALL
241
gboolean              pango_font_description_equal       (const PangoFontDescription  *desc1,
242
                                                          const PangoFontDescription  *desc2) G_GNUC_PURE;
243
PANGO_AVAILABLE_IN_ALL
244
void                  pango_font_description_free        (PangoFontDescription        *desc);
245
PANGO_AVAILABLE_IN_ALL
246
void                  pango_font_descriptions_free       (PangoFontDescription       **descs,
247
                                                          int                          n_descs);
248

249
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
250
void                 pango_font_description_set_family        (PangoFontDescription *desc,
251
                                                               const char           *family);
252
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
253
void                 pango_font_description_set_family_static (PangoFontDescription *desc,
254
                                                               const char           *family);
255
PANGO_AVAILABLE_IN_ALL
256
const char          *pango_font_description_get_family        (const PangoFontDescription *desc) G_GNUC_PURE;
257
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
258
void                 pango_font_description_set_style         (PangoFontDescription *desc,
259
                                                               PangoStyle            style);
260
PANGO_AVAILABLE_IN_ALL
261
PangoStyle           pango_font_description_get_style         (const PangoFontDescription *desc) G_GNUC_PURE;
262
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
263
void                 pango_font_description_set_variant       (PangoFontDescription *desc,
264
                                                               PangoVariant          variant);
265
PANGO_AVAILABLE_IN_ALL
266
PangoVariant         pango_font_description_get_variant       (const PangoFontDescription *desc) G_GNUC_PURE;
267
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
268
void                 pango_font_description_set_weight        (PangoFontDescription *desc,
269
                                                               PangoWeight           weight);
270
PANGO_AVAILABLE_IN_ALL
271
PangoWeight          pango_font_description_get_weight        (const PangoFontDescription *desc) G_GNUC_PURE;
272
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
273
void                 pango_font_description_set_stretch       (PangoFontDescription *desc,
274
                                                               PangoStretch          stretch);
275
PANGO_AVAILABLE_IN_ALL
276
PangoStretch         pango_font_description_get_stretch       (const PangoFontDescription *desc) G_GNUC_PURE;
277
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
278
void                 pango_font_description_set_size          (PangoFontDescription *desc,
279
                                                               gint                  size);
280
PANGO_AVAILABLE_IN_ALL
281
gint                 pango_font_description_get_size          (const PangoFontDescription *desc) G_GNUC_PURE;
282
PANGO_AVAILABLE_IN_1_8
283
void                 pango_font_description_set_absolute_size (PangoFontDescription *desc,
284
                                                               double                size);
285
PANGO_AVAILABLE_IN_1_8
286
gboolean             pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE;
287
PANGO_AVAILABLE_IN_1_16
288
void                 pango_font_description_set_gravity       (PangoFontDescription *desc,
289
                                                               PangoGravity          gravity);
290
PANGO_AVAILABLE_IN_1_16
291
PangoGravity         pango_font_description_get_gravity       (const PangoFontDescription *desc) G_GNUC_PURE;
Owen Taylor's avatar
Owen Taylor committed
292

293
294
PANGO_AVAILABLE_IN_1_42
void                 pango_font_description_set_variations_static (PangoFontDescription       *desc,
295
                                                                   const char                 *variations);
296
297
PANGO_AVAILABLE_IN_1_42
void                 pango_font_description_set_variations    (PangoFontDescription       *desc,
298
                                                               const char                 *variations);
299
300
301
PANGO_AVAILABLE_IN_1_42
const char          *pango_font_description_get_variations    (const PangoFontDescription *desc) G_GNUC_PURE;

302
PANGO_AVAILABLE_IN_ALL
303
PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE;
304
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
305
void          pango_font_description_unset_fields   (PangoFontDescription       *desc,
306
                                                     PangoFontMask               to_unset);
Owen Taylor's avatar
Owen Taylor committed
307

308
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
309
void pango_font_description_merge        (PangoFontDescription       *desc,
310
311
                                          const PangoFontDescription *desc_to_merge,
                                          gboolean                    replace_existing);
312
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
313
void pango_font_description_merge_static (PangoFontDescription       *desc,
314
315
                                          const PangoFontDescription *desc_to_merge,
                                          gboolean                    replace_existing);
Owen Taylor's avatar
Owen Taylor committed
316

317
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
318
gboolean pango_font_description_better_match (const PangoFontDescription *desc,
319
320
                                              const PangoFontDescription *old_match,
                                              const PangoFontDescription *new_match) G_GNUC_PURE;
Owen Taylor's avatar
Owen Taylor committed
321

322
PANGO_AVAILABLE_IN_ALL
323
PangoFontDescription *pango_font_description_from_string (const char                  *str);
324
PANGO_AVAILABLE_IN_ALL
325
char *                pango_font_description_to_string   (const PangoFontDescription  *desc);
326
PANGO_AVAILABLE_IN_ALL
Tor Lillqvist's avatar
Tor Lillqvist committed
327
char *                pango_font_description_to_filename (const PangoFontDescription  *desc);
328

Owen Taylor's avatar
Owen Taylor committed
329
330
331
/*
 * PangoFontMetrics
 */
332
333

#define PANGO_TYPE_FONT_METRICS  (pango_font_metrics_get_type ())
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350

struct _PangoFontMetrics
{
  /* <private> */
  guint ref_count;

  int ascent;
  int descent;
  int height;
  int approximate_char_width;
  int approximate_digit_width;
  int underline_position;
  int underline_thickness;
  int strikethrough_position;
  int strikethrough_thickness;
};

351
PANGO_AVAILABLE_IN_ALL
352
GType             pango_font_metrics_get_type                    (void) G_GNUC_CONST;
353
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
354
PangoFontMetrics *pango_font_metrics_ref                         (PangoFontMetrics *metrics);
355
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
356
void              pango_font_metrics_unref                       (PangoFontMetrics *metrics);
357
PANGO_AVAILABLE_IN_ALL
358
int               pango_font_metrics_get_ascent                  (PangoFontMetrics *metrics) G_GNUC_PURE;
359
PANGO_AVAILABLE_IN_ALL
360
int               pango_font_metrics_get_descent                 (PangoFontMetrics *metrics) G_GNUC_PURE;
361
362
PANGO_AVAILABLE_IN_1_44
int               pango_font_metrics_get_height                  (PangoFontMetrics *metrics) G_GNUC_PURE;
363
PANGO_AVAILABLE_IN_ALL
364
int               pango_font_metrics_get_approximate_char_width  (PangoFontMetrics *metrics) G_GNUC_PURE;
365
PANGO_AVAILABLE_IN_ALL
366
int               pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE;
367
PANGO_AVAILABLE_IN_1_6
368
int               pango_font_metrics_get_underline_position      (PangoFontMetrics *metrics) G_GNUC_PURE;
369
PANGO_AVAILABLE_IN_1_6
370
int               pango_font_metrics_get_underline_thickness     (PangoFontMetrics *metrics) G_GNUC_PURE;
371
PANGO_AVAILABLE_IN_1_6
372
int               pango_font_metrics_get_strikethrough_position  (PangoFontMetrics *metrics) G_GNUC_PURE;
373
PANGO_AVAILABLE_IN_1_6
374
int               pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
Owen Taylor's avatar
Owen Taylor committed
375
376
377
378
379
380
381
382
383


/*
 * PangoFontFamily
 */

#define PANGO_TYPE_FONT_FAMILY              (pango_font_family_get_type ())
#define PANGO_FONT_FAMILY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily))
#define PANGO_IS_FONT_FAMILY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY))
384
385
386
#define PANGO_FONT_FAMILY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
#define PANGO_IS_FONT_FAMILY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY))
#define PANGO_FONT_FAMILY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
Owen Taylor's avatar
Owen Taylor committed
387
388

typedef struct _PangoFontFace        PangoFontFace;
389
390
391
392
393
394
395
396
typedef struct _PangoFontFamily      PangoFontFamily;
typedef struct _PangoFontFamilyClass PangoFontFamilyClass;

#ifndef PANGO_DISABLE_DEPRECATED

/**
 * PangoFontFamily:
 *
Matthias Clasen's avatar
Matthias Clasen committed
397
398
399
400
401
 * A `PangoFontFamily` is used to represent a family of related
 * font faces.
 *
 * The font faces in a family share a common design, but differ in
 * slant, weight, width or other aspects.
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
 */
struct _PangoFontFamily
{
  GObject parent_instance;
};

struct _PangoFontFamilyClass
{
  GObjectClass parent_class;

  /*< public >*/

  void  (*list_faces)      (PangoFontFamily  *family,
                            PangoFontFace  ***faces,
                            int              *n_faces);
  const char * (*get_name) (PangoFontFamily  *family);
  gboolean (*is_monospace) (PangoFontFamily *family);
  gboolean (*is_variable)  (PangoFontFamily *family);

421
422
423
424
  PangoFontFace * (*get_face) (PangoFontFamily *family,
                               const char      *name);


425
426
427
428
429
430
431
  /*< private >*/

  /* Padding for future expansion */
  void (*_pango_reserved2) (void);
};

#endif /* PANGO_DISABLE_DEPRECATED */
Owen Taylor's avatar
Owen Taylor committed
432

433
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
434
435
GType      pango_font_family_get_type       (void) G_GNUC_CONST;

436
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
437
void                 pango_font_family_list_faces (PangoFontFamily  *family,
438
439
                                                   PangoFontFace  ***faces,
                                                   int              *n_faces);
440
PANGO_AVAILABLE_IN_ALL
441
const char *pango_font_family_get_name   (PangoFontFamily  *family) G_GNUC_PURE;
442
PANGO_AVAILABLE_IN_1_4
443
gboolean   pango_font_family_is_monospace         (PangoFontFamily  *family) G_GNUC_PURE;
Matthias Clasen's avatar
Matthias Clasen committed
444
445
PANGO_AVAILABLE_IN_1_44
gboolean   pango_font_family_is_variable          (PangoFontFamily  *family) G_GNUC_PURE;
Owen Taylor's avatar
Owen Taylor committed
446

447
448
449
450
PANGO_AVAILABLE_IN_1_46
PangoFontFace *pango_font_family_get_face (PangoFontFamily *family,
                                           const char      *name);

Owen Taylor's avatar
Owen Taylor committed
451
452
453
454
455
456
457
458

/*
 * PangoFontFace
 */

#define PANGO_TYPE_FONT_FACE              (pango_font_face_get_type ())
#define PANGO_FONT_FACE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace))
#define PANGO_IS_FONT_FACE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE))
459
460
461
462
463
464
465
466
467
468
469
#define PANGO_FONT_FACE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
#define PANGO_IS_FONT_FACE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE))
#define PANGO_FONT_FACE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))

typedef struct _PangoFontFaceClass   PangoFontFaceClass;

#ifndef PANGO_DISABLE_DEPRECATED

/**
 * PangoFontFace:
 *
Matthias Clasen's avatar
Matthias Clasen committed
470
471
 * A `PangoFontFace` is used to represent a group of fonts with
 * the same family, slant, weight, and width, but varying sizes.
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
 */
struct _PangoFontFace
{
  GObject parent_instance;
};

struct _PangoFontFaceClass
{
  GObjectClass parent_class;

  /*< public >*/

  const char           * (*get_face_name)  (PangoFontFace *face);
  PangoFontDescription * (*describe)       (PangoFontFace *face);
  void                   (*list_sizes)     (PangoFontFace  *face,
                                            int           **sizes,
                                            int            *n_sizes);
  gboolean               (*is_synthesized) (PangoFontFace *face);
490
  PangoFontFamily *      (*get_family)     (PangoFontFace *face);
491
492
493
494
495
496
497
498
499

  /*< private >*/

  /* Padding for future expansion */
  void (*_pango_reserved3) (void);
  void (*_pango_reserved4) (void);
};

#endif /* PANGO_DISABLE_DEPRECATED */
Owen Taylor's avatar
Owen Taylor committed
500

501
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
502
503
GType      pango_font_face_get_type       (void) G_GNUC_CONST;

504
PANGO_AVAILABLE_IN_ALL
505
PangoFontDescription *pango_font_face_describe       (PangoFontFace  *face);
506
PANGO_AVAILABLE_IN_ALL
507
const char           *pango_font_face_get_face_name  (PangoFontFace  *face) G_GNUC_PURE;
508
PANGO_AVAILABLE_IN_1_4
509
void                  pango_font_face_list_sizes     (PangoFontFace  *face,
510
511
                                                      int           **sizes,
                                                      int            *n_sizes);
512
PANGO_AVAILABLE_IN_1_18
513
gboolean              pango_font_face_is_synthesized (PangoFontFace  *face) G_GNUC_PURE;
Owen Taylor's avatar
Owen Taylor committed
514

515
516
517
PANGO_AVAILABLE_IN_1_46
PangoFontFamily *     pango_font_face_get_family     (PangoFontFace  *face);

518

Owen Taylor's avatar
Owen Taylor committed
519
520
521
/*
 * PangoFont
 */
522
523
524
525

#define PANGO_TYPE_FONT              (pango_font_get_type ())
#define PANGO_FONT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont))
#define PANGO_IS_FONT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT))
526
527
528
529
#define PANGO_FONT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
#define PANGO_IS_FONT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT))
#define PANGO_FONT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass))

Owen Taylor's avatar
Owen Taylor committed
530

531
532
533
534
535
#ifndef PANGO_DISABLE_DEPRECATED

/**
 * PangoFont:
 *
Matthias Clasen's avatar
Matthias Clasen committed
536
537
 * A `PangoFont` is used to represent a font in a
 * rendering-system-independent manner.
538
539
540
541
542
543
 */
struct _PangoFont
{
  GObject parent_instance;
};

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
typedef struct _PangoFontClass       PangoFontClass;
struct _PangoFontClass
{
  GObjectClass parent_class;

  /*< public >*/

  PangoFontDescription *(*describe)           (PangoFont      *font);
  PangoCoverage *       (*get_coverage)       (PangoFont      *font,
                                               PangoLanguage  *language);
  void                  (*get_glyph_extents)  (PangoFont      *font,
                                               PangoGlyph      glyph,
                                               PangoRectangle *ink_rect,
                                               PangoRectangle *logical_rect);
  PangoFontMetrics *    (*get_metrics)        (PangoFont      *font,
                                               PangoLanguage  *language);
  PangoFontMap *        (*get_font_map)       (PangoFont      *font);
  PangoFontDescription *(*describe_absolute)  (PangoFont      *font);
  void                  (*get_features)       (PangoFont      *font,
                                               hb_feature_t   *features,
                                               guint           len,
                                               guint          *num_features);
  hb_font_t *           (*create_hb_font)     (PangoFont      *font);
};

569
570
#endif /* PANGO_DISABLE_DEPRECATED */

571
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
572
573
GType                 pango_font_get_type          (void) G_GNUC_CONST;

574
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
575
PangoFontDescription *pango_font_describe          (PangoFont        *font);
576
PANGO_AVAILABLE_IN_1_14
577
PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont        *font);
578
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
579
PangoCoverage *       pango_font_get_coverage      (PangoFont        *font,
580
                                                    PangoLanguage    *language);
581
#ifndef __GI_SCANNER__
582
PANGO_DEPRECATED_IN_1_44
Owen Taylor's avatar
Owen Taylor committed
583
PangoEngineShape *    pango_font_find_shaper       (PangoFont        *font,
584
585
                                                    PangoLanguage    *language,
                                                    guint32           ch);
586
#endif
587
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
588
PangoFontMetrics *    pango_font_get_metrics       (PangoFont        *font,
589
                                                    PangoLanguage    *language);
590
PANGO_AVAILABLE_IN_ALL
Owen Taylor's avatar
Owen Taylor committed
591
void                  pango_font_get_glyph_extents (PangoFont        *font,
592
593
594
                                                    PangoGlyph        glyph,
                                                    PangoRectangle   *ink_rect,
                                                    PangoRectangle   *logical_rect);
595
PANGO_AVAILABLE_IN_1_10
596
PangoFontMap         *pango_font_get_font_map      (PangoFont        *font);
Owen Taylor's avatar
Owen Taylor committed
597

Matthias Clasen's avatar
Matthias Clasen committed
598
599
600
PANGO_AVAILABLE_IN_1_46
PangoFontFace *       pango_font_get_face          (PangoFont        *font);

Matthias Clasen's avatar
Matthias Clasen committed
601
PANGO_AVAILABLE_IN_1_44
Matthias Clasen's avatar
Matthias Clasen committed
602
gboolean              pango_font_has_char          (PangoFont        *font,
603
                                                    gunichar          wc);
604
605
606
607
608
PANGO_AVAILABLE_IN_1_44
void                  pango_font_get_features      (PangoFont        *font,
                                                    hb_feature_t     *features,
                                                    guint             len,
                                                    guint            *num_features);
Matthias Clasen's avatar
Matthias Clasen committed
609
610
PANGO_AVAILABLE_IN_1_44
hb_font_t *           pango_font_get_hb_font       (PangoFont        *font);
611

Matthias Clasen's avatar
Matthias Clasen committed
612
613
614
PANGO_AVAILABLE_IN_1_50
PangoLanguage **      pango_font_get_languages     (PangoFont        *font);

615
616
617
/**
 * PANGO_GLYPH_EMPTY:
 *
Matthias Clasen's avatar
Matthias Clasen committed
618
619
620
621
 * A `PangoGlyph` value that indicates a zero-width empty glpyh.
 *
 * This is useful for example in shaper modules, to use as the glyph for
 * various zero-width Unicode characters (those passing [func@is_zero_width]).
622
 */
623

624
625
626
/**
 * PANGO_GLYPH_INVALID_INPUT:
 *
Matthias Clasen's avatar
Matthias Clasen committed
627
628
629
630
 * A `PangoGlyph` value for invalid input.
 *
 * `PangoLayout` produces one such glyph per invalid input UTF-8 byte and such
 * a glyph is rendered as a crossed box.
631
632
 *
 * Note that this value is defined such that it has the %PANGO_GLYPH_UNKNOWN_FLAG
Matthias Clasen's avatar
Matthias Clasen committed
633
 * set.
634
635
636
637
638
639
 *
 * Since: 1.20
 */
/**
 * PANGO_GLYPH_UNKNOWN_FLAG:
 *
Matthias Clasen's avatar
Matthias Clasen committed
640
641
642
643
 * Flag used in `PangoGlyph` to turn a `gunichar` value of a valid Unicode
 * character into an unknown-character glyph for that `gunichar`.
 *
 * Such unknown-character glyphs may be rendered as a 'hex box'.
644
645
646
647
648
 */
/**
 * PANGO_GET_UNKNOWN_GLYPH:
 * @wc: a Unicode character
 *
649
 * The way this unknown glyphs are rendered is backend specific. For example,
650
651
652
 * a box with the hexadecimal Unicode code-point of the character written in it
 * is what is done in the most common backends.
 *
653
 * Returns: a `PangoGlyph` value that means no glyph was found for @wc.
654
 */
655
656
657
#define PANGO_GLYPH_EMPTY           ((PangoGlyph)0x0FFFFFFF)
#define PANGO_GLYPH_INVALID_INPUT   ((PangoGlyph)0xFFFFFFFF)
#define PANGO_GLYPH_UNKNOWN_FLAG    ((PangoGlyph)0x10000000)
658
659
#define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG)

Matthias Clasen's avatar
Matthias Clasen committed
660
#ifndef __GI_SCANNER__
661
662
663
664
#ifndef PANGO_DISABLE_DEPRECATED
#define PANGO_UNKNOWN_GLYPH_WIDTH  10
#define PANGO_UNKNOWN_GLYPH_HEIGHT 14
#endif
Matthias Clasen's avatar
Matthias Clasen committed
665
#endif
666

667
668
G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFontFamily, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFontFace, g_object_unref)
Matthias Clasen's avatar
Matthias Clasen committed
669
670
G_DEFINE_AUTOPTR_CLEANUP_FUNC(PangoFont, g_object_unref)

Owen Taylor's avatar
Owen Taylor committed
671
G_END_DECLS
672

673
#endif /* __PANGO_FONT_H__ */