blob: 6954f96f52be873ea23427d28167501f63a250ac [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
Behdad Esfahbod2409d5f2011-04-21 17:14:28 -04002 * Copyright © 1998-2004 David Turner and Werner Lemberg
3 * Copyright © 2004,2007,2009,2010 Red Hat, Inc.
Behdad Esfahbod6b347132007-10-11 08:30:50 +00004 *
Behdad Esfahbod8f0d7e02011-04-15 18:59:56 -04005 * This is part of HarfBuzz, a text shaping library.
Behdad Esfahbod6b347132007-10-11 08:30:50 +00006 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00007 * 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.
Behdad Esfahbod6b347132007-10-11 08:30:50 +000012 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000013 * 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
Behdad Esfahbod6b347132007-10-11 08:30:50 +000026 */
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000027
Behdad Esfahbodda8edbb2010-06-09 07:15:39 -040028#ifndef HB_BUFFER_PRIVATE_HH
29#define HB_BUFFER_PRIVATE_HH
Behdad Esfahbod6b347132007-10-11 08:30:50 +000030
Behdad Esfahbodc57d4542011-04-20 18:50:27 -040031#include "hb-private.hh"
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -040032#include "hb-buffer.h"
Behdad Esfahbodfca368c2011-04-21 18:24:02 -040033#include "hb-object-private.hh"
Behdad Esfahbodfb194b82011-04-20 02:00:47 -040034#include "hb-unicode-private.hh"
Behdad Esfahbod6b347132007-10-11 08:30:50 +000035
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040036HB_BEGIN_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +000037
Behdad Esfahbodacdba3f2010-07-23 15:11:18 -040038
Behdad Esfahbod88474c62010-10-27 14:42:15 -040039ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040040ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
41
Behdad Esfahboda7c50462010-10-08 18:47:47 -040042typedef struct _hb_segment_properties_t {
43 hb_direction_t direction;
44 hb_script_t script;
45 hb_language_t language;
46} hb_segment_properties_t;
47
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040048
Behdad Esfahbod6b347132007-10-11 08:30:50 +000049HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040050_hb_buffer_swap (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000051
52HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040053_hb_buffer_clear_output (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000054
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040055HB_INTERNAL void
Behdad Esfahbod8f0d7e02011-04-15 18:59:56 -040056_hb_buffer_clear_positions (hb_buffer_t *buffer);
57
58HB_INTERNAL void
Behdad Esfahboddd2ffd22010-10-27 16:57:01 -040059_hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer,
60 unsigned int num_in,
61 unsigned int num_out,
62 const uint16_t *glyph_data_be);
Behdad Esfahbod25e7ef72009-11-06 17:21:01 -050063
64HB_INTERNAL void
Behdad Esfahboddd2ffd22010-10-27 16:57:01 -040065_hb_buffer_replace_glyph (hb_buffer_t *buffer,
66 hb_codepoint_t glyph_index);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000067
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040068HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040069_hb_buffer_next_glyph (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000070
Behdad Esfahbod78ef65b2007-11-07 08:06:01 +000071
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +010072HB_INTERNAL void
Behdad Esfahbod57ac0ec2010-10-12 17:07:02 -040073_hb_buffer_reset_masks (hb_buffer_t *buffer,
74 hb_mask_t mask);
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +010075
76HB_INTERNAL void
Behdad Esfahbod57ac0ec2010-10-12 17:07:02 -040077_hb_buffer_add_masks (hb_buffer_t *buffer,
Behdad Esfahbodbd7378b2010-10-13 18:33:16 -040078 hb_mask_t mask);
79
80HB_INTERNAL void
81_hb_buffer_set_masks (hb_buffer_t *buffer,
Behdad Esfahbod81c5e872010-05-28 18:31:16 -040082 hb_mask_t value,
83 hb_mask_t mask,
84 unsigned int cluster_start,
85 unsigned int cluster_end);
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +010086
Behdad Esfahbodd0316a82010-05-12 23:34:52 -040087
88struct _hb_buffer_t {
Behdad Esfahbodfca368c2011-04-21 18:24:02 -040089 hb_object_header_t header;
Behdad Esfahbodd0316a82010-05-12 23:34:52 -040090
91 /* Information about how the text in the buffer should be treated */
Behdad Esfahbod4e4ef242010-07-23 17:22:11 -040092
Behdad Esfahboda7c50462010-10-08 18:47:47 -040093 hb_unicode_funcs_t *unicode; /* Unicode functions */
94 hb_segment_properties_t props; /* Script, language, direction */
Behdad Esfahbodd0316a82010-05-12 23:34:52 -040095
96 /* Buffer contents */
97
Behdad Esfahbodfca368c2011-04-21 18:24:02 -040098 bool have_output; /* Whether we have an output buffer going on */
99 bool have_positions; /* Whether we have positions */
100 bool in_error; /* Allocation failed */
Behdad Esfahbod910a33f2010-05-14 22:13:38 -0400101
102 unsigned int i; /* Cursor into ->info and ->pos arrays */
103 unsigned int len; /* Length of ->info and ->pos arrays */
Behdad Esfahbodcc1a8a92011-01-06 14:58:52 -0500104 unsigned int out_len; /* Length of ->out array if have_output */
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400105
Behdad Esfahbodc0af1932011-04-15 19:26:24 -0400106 unsigned int serial;
107
108 unsigned int allocated; /* Length of allocated arrays */
Behdad Esfahbod88474c62010-10-27 14:42:15 -0400109 hb_glyph_info_t *info;
110 hb_glyph_info_t *out_info;
111 hb_glyph_position_t *pos;
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400112
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400113
114 /* Methods */
Behdad Esfahbodcc1a8a92011-01-06 14:58:52 -0500115 inline unsigned int backtrack_len (void) const
116 { return this->have_output? this->out_len : this->i; }
Behdad Esfahboddbf56b12010-10-27 17:06:12 -0400117 inline unsigned int next_serial (void) { return serial++; }
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400118 inline void swap (void) { _hb_buffer_swap (this); }
Behdad Esfahbod1d5e7802010-05-12 23:43:00 -0400119 inline void clear_output (void) { _hb_buffer_clear_output (this); }
Behdad Esfahbod8f0d7e02011-04-15 18:59:56 -0400120 inline void clear_positions (void) { _hb_buffer_clear_positions (this); }
Behdad Esfahbod1d5e7802010-05-12 23:43:00 -0400121 inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
Behdad Esfahboddd2ffd22010-10-27 16:57:01 -0400122 inline void replace_glyphs_be16 (unsigned int num_in,
123 unsigned int num_out,
124 const uint16_t *glyph_data_be)
125 { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
126 inline void replace_glyph (hb_codepoint_t glyph_index)
127 { _hb_buffer_replace_glyph (this, glyph_index); }
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +0100128
Behdad Esfahbodbd7378b2010-10-13 18:33:16 -0400129 inline void reset_masks (hb_mask_t mask)
130 {
131 for (unsigned int i = 0; i < len; i++)
132 info[i].mask = mask;
133 }
134 inline void add_masks (hb_mask_t mask)
135 {
136 for (unsigned int i = 0; i < len; i++)
137 info[i].mask |= mask;
138 }
139 inline void set_masks (hb_mask_t value,
Behdad Esfahbod81c5e872010-05-28 18:31:16 -0400140 hb_mask_t mask,
141 unsigned int cluster_start,
142 unsigned int cluster_end)
Behdad Esfahbodbd7378b2010-10-13 18:33:16 -0400143 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400144};
145
146
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400147HB_END_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000148
Behdad Esfahbodda8edbb2010-06-09 07:15:39 -0400149#endif /* HB_BUFFER_PRIVATE_HH */