2 * pango-font.h: Font handling
4 * Copyright (C) 2000 Red Hat Software
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.
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.
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.
22 #ifndef __PANGO_FONT_H__
23 #define __PANGO_FONT_H__
25 #include <pango/pango-coverage.h>
26 #include <pango/pango-types.h>
28 #include <glib-object.h>
32 typedef struct _PangoFontDescription PangoFontDescription;
33 typedef struct _PangoFontMetrics PangoFontMetrics;
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.
41 * An enumeration specifying the various slant styles possible for a font.
51 PANGO_VARIANT_SMALL_CAPS
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
69 PANGO_STRETCH_ULTRA_CONDENSED,
70 PANGO_STRETCH_EXTRA_CONDENSED,
71 PANGO_STRETCH_CONDENSED,
72 PANGO_STRETCH_SEMI_CONDENSED,
74 PANGO_STRETCH_SEMI_EXPANDED,
75 PANGO_STRETCH_EXPANDED,
76 PANGO_STRETCH_EXTRA_EXPANDED,
77 PANGO_STRETCH_ULTRA_EXPANDED
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
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)
100 * PangoFontDescription
103 #define PANGO_TYPE_FONT_DESCRIPTION (pango_font_description_get_type ())
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,
116 void pango_font_description_set_family (PangoFontDescription *desc,
118 void pango_font_description_set_family_static (PangoFontDescription *desc,
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,
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,
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,
135 gint pango_font_description_get_size (const PangoFontDescription *desc) G_GNUC_PURE;
136 void pango_font_description_set_absolute_size (PangoFontDescription *desc,
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;
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);
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);
154 gboolean pango_font_description_better_match (const PangoFontDescription *desc,
155 const PangoFontDescription *old_match,
156 const PangoFontDescription *new_match) G_GNUC_PURE;
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);
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;
179 #ifdef PANGO_ENABLE_BACKEND
181 PangoFontMetrics *pango_font_metrics_new (void);
183 struct _PangoFontMetrics
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;
197 #endif /* PANGO_ENABLE_BACKEND */
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))
207 typedef struct _PangoFontFamily PangoFontFamily;
208 typedef struct _PangoFontFace PangoFontFace;
210 GType pango_font_family_get_type (void) G_GNUC_CONST;
212 void pango_font_family_list_faces (PangoFontFamily *family,
213 PangoFontFace ***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;
218 #ifdef PANGO_ENABLE_BACKEND
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))
224 typedef struct _PangoFontFamilyClass PangoFontFamilyClass;
226 struct _PangoFontFamily
228 GObject parent_instance;
231 struct _PangoFontFamilyClass
233 GObjectClass parent_class;
237 void (*list_faces) (PangoFontFamily *family,
238 PangoFontFace ***faces,
240 const char * (*get_name) (PangoFontFamily *family);
241 gboolean (*is_monospace) (PangoFontFamily *family);
245 /* Padding for future expansion */
246 void (*_pango_reserved2) (void);
247 void (*_pango_reserved3) (void);
248 void (*_pango_reserved4) (void);
251 #endif /* PANGO_ENABLE_BACKEND */
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))
261 GType pango_font_face_get_type (void) G_GNUC_CONST;
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,
268 gboolean pango_font_face_is_synthesized (PangoFontFace *face) G_GNUC_PURE;
270 #ifdef PANGO_ENABLE_BACKEND
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))
276 typedef struct _PangoFontFaceClass PangoFontFaceClass;
278 struct _PangoFontFace
280 GObject parent_instance;
283 struct _PangoFontFaceClass
285 GObjectClass parent_class;
289 const char * (*get_face_name) (PangoFontFace *face);
290 PangoFontDescription * (*describe) (PangoFontFace *face);
291 void (*list_sizes) (PangoFontFace *face,
294 gboolean (*is_synthesized) (PangoFontFace *face);
298 /* Padding for future expansion */
299 void (*_pango_reserved3) (void);
300 void (*_pango_reserved4) (void);
303 #endif /* PANGO_ENABLE_BACKEND */
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))
313 GType pango_font_get_type (void) G_GNUC_CONST;
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,
322 PangoFontMetrics * pango_font_get_metrics (PangoFont *font,
323 PangoLanguage *language);
324 void pango_font_get_glyph_extents (PangoFont *font,
326 PangoRectangle *ink_rect,
327 PangoRectangle *logical_rect);
328 PangoFontMap *pango_font_get_font_map (PangoFont *font);
330 #ifdef PANGO_ENABLE_BACKEND
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))
336 typedef struct _PangoFontClass PangoFontClass;
340 GObject parent_instance;
343 struct _PangoFontClass
345 GObjectClass parent_class;
349 PangoFontDescription *(*describe) (PangoFont *font);
350 PangoCoverage * (*get_coverage) (PangoFont *font,
351 PangoLanguage *lang);
352 PangoEngineShape * (*find_shaper) (PangoFont *font,
355 void (*get_glyph_extents) (PangoFont *font,
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);
365 /* Padding for future expansion */
366 void (*_pango_reserved1) (void);
367 void (*_pango_reserved2) (void);
370 /* used for very rare and miserable situtations that we cannot even
373 #define PANGO_UNKNOWN_GLYPH_WIDTH 10
374 #define PANGO_UNKNOWN_GLYPH_HEIGHT 14
376 #endif /* PANGO_ENABLE_BACKEND */
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)
386 #endif /* __PANGO_FONT_H__ */