summaryrefslogtreecommitdiff
path: root/pango/pango-font.h
blob: ebe1fc87cc1820974cf115f4bbc402a05f773696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/* 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * 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__

#include <pango/pango-coverage.h>
#include <pango/pango-types.h>

#include <glib-object.h>

G_BEGIN_DECLS

typedef struct _PangoFontDescription PangoFontDescription;
typedef struct _PangoFontMetrics PangoFontMetrics;

/**
 * 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.
 **/
typedef enum {
  PANGO_STYLE_NORMAL,
  PANGO_STYLE_OBLIQUE,
  PANGO_STYLE_ITALIC
} PangoStyle;

typedef enum {
  PANGO_VARIANT_NORMAL,
  PANGO_VARIANT_SMALL_CAPS
} PangoVariant;

typedef enum {
  PANGO_WEIGHT_ULTRALIGHT = 200,
  PANGO_WEIGHT_LIGHT = 300,
  PANGO_WEIGHT_NORMAL = 400,
  PANGO_WEIGHT_BOLD = 700,
  PANGO_WEIGHT_ULTRABOLD = 800,
  PANGO_WEIGHT_HEAVY = 900
} PangoWeight;

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;

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,
  PANGO_FONT_MASK_SIZE    = 1 << 5
} PangoFontMask;

/* CSS scale factors (1.2 factor between each size) */
#define PANGO_SCALE_XX_SMALL ((double)0.5787037037037)
#define PANGO_SCALE_X_SMALL  ((double)0.6444444444444)
#define PANGO_SCALE_SMALL    ((double)0.8333333333333)
#define PANGO_SCALE_MEDIUM   ((double)1.0)
#define PANGO_SCALE_LARGE    ((double)1.2)
#define PANGO_SCALE_X_LARGE  ((double)1.4399999999999)
#define PANGO_SCALE_XX_LARGE ((double)1.728)

/*
 * PangoFontDescription
 */

#define PANGO_TYPE_FONT_DESCRIPTION (pango_font_description_get_type ())

GType                 pango_font_description_get_type    (void);
PangoFontDescription *pango_font_description_new         (void);
PangoFontDescription *pango_font_description_copy        (const PangoFontDescription  *desc);
PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription  *desc);
guint                 pango_font_description_hash        (const PangoFontDescription  *desc);
gboolean              pango_font_description_equal       (const PangoFontDescription  *desc1,
							  const PangoFontDescription  *desc2);
void                  pango_font_description_free        (PangoFontDescription        *desc);
void                  pango_font_descriptions_free       (PangoFontDescription       **descs,
							  int                          n_descs);

void                 pango_font_description_set_family        (PangoFontDescription *desc,
							       const char           *family);
void                 pango_font_description_set_family_static (PangoFontDescription *desc,
							       const char           *family);
G_CONST_RETURN char *pango_font_description_get_family        (const PangoFontDescription *desc);
void                 pango_font_description_set_style         (PangoFontDescription *desc,
							       PangoStyle            style);
PangoStyle           pango_font_description_get_style         (const PangoFontDescription *desc);
void                 pango_font_description_set_variant       (PangoFontDescription *desc,
							       PangoVariant          variant);
PangoVariant         pango_font_description_get_variant       (const PangoFontDescription *desc);
void                 pango_font_description_set_weight        (PangoFontDescription *desc,
							       PangoWeight           weight);
PangoWeight          pango_font_description_get_weight        (const PangoFontDescription *desc);
void                 pango_font_description_set_stretch       (PangoFontDescription *desc,
							       PangoStretch          stretch);
PangoStretch         pango_font_description_get_stretch       (const PangoFontDescription *desc);
void                 pango_font_description_set_size          (PangoFontDescription *desc,
							       gint                  size);
gint                 pango_font_description_get_size          (const PangoFontDescription *desc);

PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc);
void          pango_font_description_unset_fields   (PangoFontDescription       *desc,
						     PangoFontMask               to_unset);

void pango_font_description_merge        (PangoFontDescription       *desc,
					  const PangoFontDescription *desc_to_merge,
					  gboolean                    replace_existing);
void pango_font_description_merge_static (PangoFontDescription       *desc,
					  const PangoFontDescription *desc_to_merge,
					  gboolean                    replace_existing);

gboolean pango_font_description_better_match (const PangoFontDescription *desc,
					      const PangoFontDescription *old_match,
					      const PangoFontDescription *new_match);

PangoFontDescription *pango_font_description_from_string (const char                  *str);
char *                pango_font_description_to_string   (const PangoFontDescription  *desc);
char *                pango_font_description_to_filename (const PangoFontDescription  *desc);

/*
 * PangoFontMetrics
 */

#define PANGO_TYPE_FONT_METRICS  (pango_font_metrics_get_type ())
GType             pango_font_metrics_get_type                    (void);
PangoFontMetrics *pango_font_metrics_ref                         (PangoFontMetrics *metrics);
void              pango_font_metrics_unref                       (PangoFontMetrics *metrics);
int               pango_font_metrics_get_ascent                  (PangoFontMetrics *metrics);
int               pango_font_metrics_get_descent                 (PangoFontMetrics *metrics);
int               pango_font_metrics_get_approximate_char_width  (PangoFontMetrics *metrics);
int               pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics);
int               pango_font_metrics_get_underline_position      (PangoFontMetrics *metrics);
int               pango_font_metrics_get_underline_thickness     (PangoFontMetrics *metrics);
int               pango_font_metrics_get_strikethrough_position  (PangoFontMetrics *metrics);
int               pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics);

#ifdef PANGO_ENABLE_BACKEND

PangoFontMetrics *pango_font_metrics_new (void);

struct _PangoFontMetrics
{
  guint ref_count;
  
  int ascent;
  int descent;
  int approximate_char_width;
  int approximate_digit_width;
  int underline_position;
  int underline_thickness;
  int strikethrough_position;
  int strikethrough_thickness;
};

#endif /* PANGO_ENABLE_BACKEND */

/*
 * 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))

typedef struct _PangoFontFamily      PangoFontFamily;
typedef struct _PangoFontFace        PangoFontFace;

GType      pango_font_family_get_type       (void) G_GNUC_CONST;

void                 pango_font_family_list_faces (PangoFontFamily  *family,
						   PangoFontFace  ***faces,
						   int              *n_faces);
G_CONST_RETURN char *pango_font_family_get_name   (PangoFontFamily  *family);
gboolean   pango_font_family_is_monospace         (PangoFontFamily  *family);

#ifdef PANGO_ENABLE_BACKEND

#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))

typedef struct _PangoFontFamilyClass PangoFontFamilyClass;

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);

  /*< private >*/

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

#endif /* PANGO_ENABLE_BACKEND */

/*
 * 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))

GType      pango_font_face_get_type       (void) G_GNUC_CONST;

PangoFontDescription *pango_font_face_describe       (PangoFontFace *face);
G_CONST_RETURN char  *pango_font_face_get_face_name (PangoFontFace *face);
void                  pango_font_face_list_sizes     (PangoFontFace  *face, 
                                                      int           **sizes, 
                                                      int            *n_sizes);

#ifdef PANGO_ENABLE_BACKEND

#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;

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);

  /*< private >*/

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

#endif /* PANGO_ENABLE_BACKEND */

/*
 * PangoFont
 */

#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))

GType                 pango_font_get_type          (void) G_GNUC_CONST;

PangoFontDescription *pango_font_describe          (PangoFont        *font);
PangoCoverage *       pango_font_get_coverage      (PangoFont        *font,
						    PangoLanguage    *language);
PangoEngineShape *    pango_font_find_shaper       (PangoFont        *font,
						    PangoLanguage    *language,
						    guint32           ch);
PangoFontMetrics *    pango_font_get_metrics       (PangoFont        *font,
						    PangoLanguage    *language);
void                  pango_font_get_glyph_extents (PangoFont        *font,
						    PangoGlyph        glyph,
						    PangoRectangle   *ink_rect,
						    PangoRectangle   *logical_rect);

#ifdef PANGO_ENABLE_BACKEND

#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))

typedef struct _PangoFontClass       PangoFontClass;

struct _PangoFont
{
  GObject parent_instance;
};

struct _PangoFontClass
{
  GObjectClass parent_class;

  /*< public >*/
  
  PangoFontDescription *(*describe)           (PangoFont      *font);
  PangoCoverage *       (*get_coverage)       (PangoFont      *font,
					       PangoLanguage  *lang);
  PangoEngineShape *    (*find_shaper)        (PangoFont      *font,
					       PangoLanguage  *lang,
					       guint32         ch);
  void                  (*get_glyph_extents)  (PangoFont      *font,
					       PangoGlyph      glyph,
					       PangoRectangle *ink_rect,
					       PangoRectangle *logical_rect);
  PangoFontMetrics *    (*get_metrics)        (PangoFont      *font,
					       PangoLanguage  *language);
  /*< private >*/

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

#endif /* PANGO_ENABLE_BACKEND */

G_END_DECLS

#endif /* __PANGO_FONT_H__ */