Upload tizen 2.0 beta source
[external/pango1.0.git] / pango / pango-font.h
1 /* Pango
2  * pango-font.h: Font handling
3  *
4  * Copyright (C) 2000 Red Hat Software
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __PANGO_FONT_H__
23 #define __PANGO_FONT_H__
24
25 #include <pango/pango-coverage.h>
26 #include <pango/pango-types.h>
27
28 #include <glib-object.h>
29
30 G_BEGIN_DECLS
31
32 typedef struct _PangoFontDescription PangoFontDescription;
33 typedef struct _PangoFontMetrics PangoFontMetrics;
34
35 /**
36  * PangoStyle:
37  * @PANGO_STYLE_NORMAL: the font is upright.
38  * @PANGO_STYLE_OBLIQUE: the font is slanted, but in a roman style.
39  * @PANGO_STYLE_ITALIC: the font is slanted in an italic style.
40  *
41  * An enumeration specifying the various slant styles possible for a font.
42  **/
43 typedef enum {
44   PANGO_STYLE_NORMAL,
45   PANGO_STYLE_OBLIQUE,
46   PANGO_STYLE_ITALIC
47 } PangoStyle;
48
49 typedef enum {
50   PANGO_VARIANT_NORMAL,
51   PANGO_VARIANT_SMALL_CAPS
52 } PangoVariant;
53
54 typedef enum {
55   PANGO_WEIGHT_THIN = 100,
56   PANGO_WEIGHT_ULTRALIGHT = 200,
57   PANGO_WEIGHT_LIGHT = 300,
58   PANGO_WEIGHT_BOOK = 380,
59   PANGO_WEIGHT_NORMAL = 400,
60   PANGO_WEIGHT_MEDIUM = 500,
61   PANGO_WEIGHT_SEMIBOLD = 600,
62   PANGO_WEIGHT_BOLD = 700,
63   PANGO_WEIGHT_ULTRABOLD = 800,
64   PANGO_WEIGHT_HEAVY = 900,
65   PANGO_WEIGHT_ULTRAHEAVY = 1000
66 } PangoWeight;
67
68 typedef enum {
69   PANGO_STRETCH_ULTRA_CONDENSED,
70   PANGO_STRETCH_EXTRA_CONDENSED,
71   PANGO_STRETCH_CONDENSED,
72   PANGO_STRETCH_SEMI_CONDENSED,
73   PANGO_STRETCH_NORMAL,
74   PANGO_STRETCH_SEMI_EXPANDED,
75   PANGO_STRETCH_EXPANDED,
76   PANGO_STRETCH_EXTRA_EXPANDED,
77   PANGO_STRETCH_ULTRA_EXPANDED
78 } PangoStretch;
79
80 typedef enum {
81   PANGO_FONT_MASK_FAMILY  = 1 << 0,
82   PANGO_FONT_MASK_STYLE   = 1 << 1,
83   PANGO_FONT_MASK_VARIANT = 1 << 2,
84   PANGO_FONT_MASK_WEIGHT  = 1 << 3,
85   PANGO_FONT_MASK_STRETCH = 1 << 4,
86   PANGO_FONT_MASK_SIZE    = 1 << 5,
87   PANGO_FONT_MASK_GRAVITY = 1 << 6
88 } PangoFontMask;
89
90 /* CSS scale factors (1.2 factor between each size) */
91 #define PANGO_SCALE_XX_SMALL ((double)0.5787037037037)
92 #define PANGO_SCALE_X_SMALL  ((double)0.6444444444444)
93 #define PANGO_SCALE_SMALL    ((double)0.8333333333333)
94 #define PANGO_SCALE_MEDIUM   ((double)1.0)
95 #define PANGO_SCALE_LARGE    ((double)1.2)
96 #define PANGO_SCALE_X_LARGE  ((double)1.4399999999999)
97 #define PANGO_SCALE_XX_LARGE ((double)1.728)
98
99 /*
100  * PangoFontDescription
101  */
102
103 #define PANGO_TYPE_FONT_DESCRIPTION (pango_font_description_get_type ())
104
105 GType                 pango_font_description_get_type    (void) G_GNUC_CONST;
106 PangoFontDescription *pango_font_description_new         (void);
107 PangoFontDescription *pango_font_description_copy        (const PangoFontDescription  *desc);
108 PangoFontDescription *pango_font_description_copy_static (const PangoFontDescription  *desc);
109 guint                 pango_font_description_hash        (const PangoFontDescription  *desc) G_GNUC_PURE;
110 gboolean              pango_font_description_equal       (const PangoFontDescription  *desc1,
111                                                           const PangoFontDescription  *desc2) G_GNUC_PURE;
112 void                  pango_font_description_free        (PangoFontDescription        *desc);
113 void                  pango_font_descriptions_free       (PangoFontDescription       **descs,
114                                                           int                          n_descs);
115
116 void                 pango_font_description_set_family        (PangoFontDescription *desc,
117                                                                const char           *family);
118 void                 pango_font_description_set_family_static (PangoFontDescription *desc,
119                                                                const char           *family);
120 G_CONST_RETURN char *pango_font_description_get_family        (const PangoFontDescription *desc) G_GNUC_PURE;
121 void                 pango_font_description_set_style         (PangoFontDescription *desc,
122                                                                PangoStyle            style);
123 PangoStyle           pango_font_description_get_style         (const PangoFontDescription *desc) G_GNUC_PURE;
124 void                 pango_font_description_set_variant       (PangoFontDescription *desc,
125                                                                PangoVariant          variant);
126 PangoVariant         pango_font_description_get_variant       (const PangoFontDescription *desc) G_GNUC_PURE;
127 void                 pango_font_description_set_weight        (PangoFontDescription *desc,
128                                                                PangoWeight           weight);
129 PangoWeight          pango_font_description_get_weight        (const PangoFontDescription *desc) G_GNUC_PURE;
130 void                 pango_font_description_set_stretch       (PangoFontDescription *desc,
131                                                                PangoStretch          stretch);
132 PangoStretch         pango_font_description_get_stretch       (const PangoFontDescription *desc) G_GNUC_PURE;
133 void                 pango_font_description_set_size          (PangoFontDescription *desc,
134                                                                gint                  size);
135 gint                 pango_font_description_get_size          (const PangoFontDescription *desc) G_GNUC_PURE;
136 void                 pango_font_description_set_absolute_size (PangoFontDescription *desc,
137                                                                double                size);
138 gboolean             pango_font_description_get_size_is_absolute (const PangoFontDescription *desc) G_GNUC_PURE;
139 void                 pango_font_description_set_gravity       (PangoFontDescription *desc,
140                                                                PangoGravity          gravity);
141 PangoGravity         pango_font_description_get_gravity       (const PangoFontDescription *desc) G_GNUC_PURE;
142
143 PangoFontMask pango_font_description_get_set_fields (const PangoFontDescription *desc) G_GNUC_PURE;
144 void          pango_font_description_unset_fields   (PangoFontDescription       *desc,
145                                                      PangoFontMask               to_unset);
146
147 void pango_font_description_merge        (PangoFontDescription       *desc,
148                                           const PangoFontDescription *desc_to_merge,
149                                           gboolean                    replace_existing);
150 void pango_font_description_merge_static (PangoFontDescription       *desc,
151                                           const PangoFontDescription *desc_to_merge,
152                                           gboolean                    replace_existing);
153
154 gboolean pango_font_description_better_match (const PangoFontDescription *desc,
155                                               const PangoFontDescription *old_match,
156                                               const PangoFontDescription *new_match) G_GNUC_PURE;
157
158 PangoFontDescription *pango_font_description_from_string (const char                  *str);
159 char *                pango_font_description_to_string   (const PangoFontDescription  *desc);
160 char *                pango_font_description_to_filename (const PangoFontDescription  *desc);
161
162 /*
163  * PangoFontMetrics
164  */
165
166 #define PANGO_TYPE_FONT_METRICS  (pango_font_metrics_get_type ())
167 GType             pango_font_metrics_get_type                    (void) G_GNUC_CONST;
168 PangoFontMetrics *pango_font_metrics_ref                         (PangoFontMetrics *metrics);
169 void              pango_font_metrics_unref                       (PangoFontMetrics *metrics);
170 int               pango_font_metrics_get_ascent                  (PangoFontMetrics *metrics) G_GNUC_PURE;
171 int               pango_font_metrics_get_descent                 (PangoFontMetrics *metrics) G_GNUC_PURE;
172 int               pango_font_metrics_get_approximate_char_width  (PangoFontMetrics *metrics) G_GNUC_PURE;
173 int               pango_font_metrics_get_approximate_digit_width (PangoFontMetrics *metrics) G_GNUC_PURE;
174 int               pango_font_metrics_get_underline_position      (PangoFontMetrics *metrics) G_GNUC_PURE;
175 int               pango_font_metrics_get_underline_thickness     (PangoFontMetrics *metrics) G_GNUC_PURE;
176 int               pango_font_metrics_get_strikethrough_position  (PangoFontMetrics *metrics) G_GNUC_PURE;
177 int               pango_font_metrics_get_strikethrough_thickness (PangoFontMetrics *metrics) G_GNUC_PURE;
178
179 #ifdef PANGO_ENABLE_BACKEND
180
181 PangoFontMetrics *pango_font_metrics_new (void);
182
183 struct _PangoFontMetrics
184 {
185   guint ref_count;
186
187   int ascent;
188   int descent;
189   int approximate_char_width;
190   int approximate_digit_width;
191   int underline_position;
192   int underline_thickness;
193   int strikethrough_position;
194   int strikethrough_thickness;
195 };
196
197 #endif /* PANGO_ENABLE_BACKEND */
198
199 /*
200  * PangoFontFamily
201  */
202
203 #define PANGO_TYPE_FONT_FAMILY              (pango_font_family_get_type ())
204 #define PANGO_FONT_FAMILY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FAMILY, PangoFontFamily))
205 #define PANGO_IS_FONT_FAMILY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FAMILY))
206
207 typedef struct _PangoFontFamily      PangoFontFamily;
208 typedef struct _PangoFontFace        PangoFontFace;
209
210 GType      pango_font_family_get_type       (void) G_GNUC_CONST;
211
212 void                 pango_font_family_list_faces (PangoFontFamily  *family,
213                                                    PangoFontFace  ***faces,
214                                                    int              *n_faces);
215 G_CONST_RETURN char *pango_font_family_get_name   (PangoFontFamily  *family) G_GNUC_PURE;
216 gboolean   pango_font_family_is_monospace         (PangoFontFamily  *family) G_GNUC_PURE;
217
218 #ifdef PANGO_ENABLE_BACKEND
219
220 #define PANGO_FONT_FAMILY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
221 #define PANGO_IS_FONT_FAMILY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FAMILY))
222 #define PANGO_FONT_FAMILY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FAMILY, PangoFontFamilyClass))
223
224 typedef struct _PangoFontFamilyClass PangoFontFamilyClass;
225
226 struct _PangoFontFamily
227 {
228   GObject parent_instance;
229 };
230
231 struct _PangoFontFamilyClass
232 {
233   GObjectClass parent_class;
234
235   /*< public >*/
236
237   void  (*list_faces)      (PangoFontFamily  *family,
238                             PangoFontFace  ***faces,
239                             int              *n_faces);
240   const char * (*get_name) (PangoFontFamily  *family);
241   gboolean (*is_monospace) (PangoFontFamily *family);
242
243   /*< private >*/
244
245   /* Padding for future expansion */
246   void (*_pango_reserved2) (void);
247   void (*_pango_reserved3) (void);
248   void (*_pango_reserved4) (void);
249 };
250
251 #endif /* PANGO_ENABLE_BACKEND */
252
253 /*
254  * PangoFontFace
255  */
256
257 #define PANGO_TYPE_FONT_FACE              (pango_font_face_get_type ())
258 #define PANGO_FONT_FACE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT_FACE, PangoFontFace))
259 #define PANGO_IS_FONT_FACE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT_FACE))
260
261 GType      pango_font_face_get_type       (void) G_GNUC_CONST;
262
263 PangoFontDescription *pango_font_face_describe       (PangoFontFace  *face);
264 G_CONST_RETURN char  *pango_font_face_get_face_name  (PangoFontFace  *face) G_GNUC_PURE;
265 void                  pango_font_face_list_sizes     (PangoFontFace  *face,
266                                                       int           **sizes,
267                                                       int            *n_sizes);
268 gboolean              pango_font_face_is_synthesized (PangoFontFace  *face) G_GNUC_PURE;
269
270 #ifdef PANGO_ENABLE_BACKEND
271
272 #define PANGO_FONT_FACE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
273 #define PANGO_IS_FONT_FACE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT_FACE))
274 #define PANGO_FONT_FACE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT_FACE, PangoFontFaceClass))
275
276 typedef struct _PangoFontFaceClass   PangoFontFaceClass;
277
278 struct _PangoFontFace
279 {
280   GObject parent_instance;
281 };
282
283 struct _PangoFontFaceClass
284 {
285   GObjectClass parent_class;
286
287   /*< public >*/
288
289   const char           * (*get_face_name)  (PangoFontFace *face);
290   PangoFontDescription * (*describe)       (PangoFontFace *face);
291   void                   (*list_sizes)     (PangoFontFace  *face,
292                                             int           **sizes,
293                                             int            *n_sizes);
294   gboolean               (*is_synthesized) (PangoFontFace *face);
295
296   /*< private >*/
297
298   /* Padding for future expansion */
299   void (*_pango_reserved3) (void);
300   void (*_pango_reserved4) (void);
301 };
302
303 #endif /* PANGO_ENABLE_BACKEND */
304
305 /*
306  * PangoFont
307  */
308
309 #define PANGO_TYPE_FONT              (pango_font_get_type ())
310 #define PANGO_FONT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_FONT, PangoFont))
311 #define PANGO_IS_FONT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_FONT))
312
313 GType                 pango_font_get_type          (void) G_GNUC_CONST;
314
315 PangoFontDescription *pango_font_describe          (PangoFont        *font);
316 PangoFontDescription *pango_font_describe_with_absolute_size (PangoFont        *font);
317 PangoCoverage *       pango_font_get_coverage      (PangoFont        *font,
318                                                     PangoLanguage    *language);
319 PangoEngineShape *    pango_font_find_shaper       (PangoFont        *font,
320                                                     PangoLanguage    *language,
321                                                     guint32           ch);
322 PangoFontMetrics *    pango_font_get_metrics       (PangoFont        *font,
323                                                     PangoLanguage    *language);
324 void                  pango_font_get_glyph_extents (PangoFont        *font,
325                                                     PangoGlyph        glyph,
326                                                     PangoRectangle   *ink_rect,
327                                                     PangoRectangle   *logical_rect);
328 PangoFontMap         *pango_font_get_font_map      (PangoFont        *font);
329
330 #ifdef PANGO_ENABLE_BACKEND
331
332 #define PANGO_FONT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
333 #define PANGO_IS_FONT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONT))
334 #define PANGO_FONT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONT, PangoFontClass))
335
336 typedef struct _PangoFontClass       PangoFontClass;
337
338 struct _PangoFont
339 {
340   GObject parent_instance;
341 };
342
343 struct _PangoFontClass
344 {
345   GObjectClass parent_class;
346
347   /*< public >*/
348
349   PangoFontDescription *(*describe)           (PangoFont      *font);
350   PangoCoverage *       (*get_coverage)       (PangoFont      *font,
351                                                PangoLanguage  *lang);
352   PangoEngineShape *    (*find_shaper)        (PangoFont      *font,
353                                                PangoLanguage  *lang,
354                                                guint32         ch);
355   void                  (*get_glyph_extents)  (PangoFont      *font,
356                                                PangoGlyph      glyph,
357                                                PangoRectangle *ink_rect,
358                                                PangoRectangle *logical_rect);
359   PangoFontMetrics *    (*get_metrics)        (PangoFont      *font,
360                                                PangoLanguage  *language);
361   PangoFontMap *        (*get_font_map)       (PangoFont      *font);
362   PangoFontDescription *(*describe_absolute)  (PangoFont      *font);
363   /*< private >*/
364
365   /* Padding for future expansion */
366   void (*_pango_reserved1) (void);
367   void (*_pango_reserved2) (void);
368 };
369
370 /* used for very rare and miserable situtations that we cannot even
371  * draw a hexbox
372  */
373 #define PANGO_UNKNOWN_GLYPH_WIDTH  10
374 #define PANGO_UNKNOWN_GLYPH_HEIGHT 14
375
376 #endif /* PANGO_ENABLE_BACKEND */
377
378 #define PANGO_GLYPH_EMPTY           ((PangoGlyph)0x0FFFFFFF)
379 #define PANGO_GLYPH_INVALID_INPUT   ((PangoGlyph)0xFFFFFFFF)
380 #define PANGO_GLYPH_UNKNOWN_FLAG    ((PangoGlyph)0x10000000)
381 #define PANGO_GET_UNKNOWN_GLYPH(wc) ((PangoGlyph)(wc)|PANGO_GLYPH_UNKNOWN_FLAG)
382
383
384 G_END_DECLS
385
386 #endif /* __PANGO_FONT_H__ */