PageRenderTime 38ms CodeModel.GetById 12ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/pango/font.d

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