hb-buffer.h revision 02a370697d25b986dbf1d5c38f46a89a4833b495
1/*
2 * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3 * Copyright (C) 2004,2007,2009  Red Hat, Inc.
4 *
5 * This is part of HarfBuzz, an OpenType Layout engine library.
6 *
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
26 */
27
28#ifndef HB_BUFFER_H
29#define HB_BUFFER_H
30
31#include "hb-common.h"
32
33HB_BEGIN_DECLS
34
35typedef enum _hb_direction_t {
36  HB_DIRECTION_LTR,
37  HB_DIRECTION_RTL,
38  HB_DIRECTION_TTB,
39  HB_DIRECTION_BTT
40} hb_direction_t;
41
42/* XXX  Hide structs? */
43
44typedef struct _hb_glyph_info_t {
45  hb_codepoint_t gindex;
46  unsigned int   properties;
47  unsigned int   cluster;
48  unsigned short component;
49  unsigned short ligID;
50  unsigned short gproperty;
51} hb_glyph_info_t;
52
53typedef struct _hb_glyph_position_t {
54  hb_position_t  x_pos;
55  hb_position_t  y_pos;
56  hb_position_t  x_advance;
57  hb_position_t  y_advance;
58  unsigned short back;		/* number of glyphs to go back
59				   for drawing current glyph */
60  hb_bool_t      new_advance;	/* if set, the advance width values are
61				   absolute, i.e., they won't be
62				   added to the original glyph's value
63				   but rather replace them */
64  short          cursive_chain; /* character to which this connects,
65				   may be positive or negative; used
66				   only internally */
67} hb_glyph_position_t;
68
69
70typedef struct _hb_buffer_t {
71  unsigned int allocated;
72
73  unsigned int in_length;
74  unsigned int out_length;
75  unsigned int in_pos;
76  unsigned int out_pos;
77
78  hb_glyph_info_t     *in_string;
79  hb_glyph_info_t     *out_string;
80  hb_glyph_info_t     *alt_string;
81  hb_glyph_position_t *positions;
82
83  hb_direction_t       direction;
84  unsigned int         max_lig_id;
85} hb_buffer_t;
86
87hb_buffer_t *
88hb_buffer_new (unsigned int allocation_size);
89
90void
91hb_buffer_free (hb_buffer_t *buffer);
92
93void
94hb_buffer_clear (hb_buffer_t *buffer);
95
96void
97hb_buffer_ensure (hb_buffer_t  *buffer,
98		  unsigned int  size);
99
100void
101hb_buffer_add_glyph (hb_buffer_t    *buffer,
102		     hb_codepoint_t  glyph_index,
103		     unsigned int    properties,
104		     unsigned int    cluster);
105
106void
107hb_buffer_set_direction (hb_buffer_t    *buffer,
108			 hb_direction_t  direction);
109
110
111HB_END_DECLS
112
113#endif /* HB_BUFFER_H */
114