blob: b48ef1d5774080db92434d6db33dd0d715c27aa0 [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
Behdad Esfahbod22da7fd2010-05-12 18:23:21 -04003 * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc.
Behdad Esfahbod6b347132007-10-11 08:30:50 +00004 *
Behdad Esfahbodc755cb32010-04-22 00:11:43 -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 Esfahbod3015c412009-05-20 06:01:16 -040031#include "hb-private.h"
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -040032#include "hb-buffer.h"
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050033#include "hb-unicode-private.h"
Behdad Esfahbod6b347132007-10-11 08:30:50 +000034
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040035HB_BEGIN_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +000036
Behdad Esfahbodacdba3f2010-07-23 15:11:18 -040037
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040038#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
Behdad Esfahbod6b347132007-10-11 08:30:50 +000039
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040040
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040041typedef struct _hb_internal_glyph_info_t {
42 hb_codepoint_t codepoint;
Behdad Esfahbod468769b2009-08-08 16:53:23 -040043 hb_mask_t mask;
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040044 uint32_t cluster;
45 uint16_t component;
46 uint16_t lig_id;
47 uint32_t gproperty;
48} hb_internal_glyph_info_t;
49
50typedef struct _hb_internal_glyph_position_t {
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040051 hb_position_t x_advance;
52 hb_position_t y_advance;
Behdad Esfahbod9bef3612009-11-05 12:20:11 -050053 hb_position_t x_offset;
54 hb_position_t y_offset;
Behdad Esfahbod9db8ad72009-11-06 16:47:31 -050055 uint32_t back : 16; /* number of glyphs to go back
Behdad Esfahbod864e2562009-08-18 16:38:48 -040056 for drawing current glyph */
57 int32_t cursive_chain : 16; /* character to which this connects,
Behdad Esfahbodc3df6492010-05-11 13:54:12 -040058 may be positive or negative */
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040059} hb_internal_glyph_position_t;
60
61ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
62ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
63ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
64
65
Behdad Esfahbod6b347132007-10-11 08:30:50 +000066HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040067_hb_buffer_swap (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000068
69HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040070_hb_buffer_clear_output (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000071
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040072HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040073_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
74 unsigned int num_in,
75 unsigned int num_out,
Behdad Esfahbod25e7ef72009-11-06 17:21:01 -050076 const hb_codepoint_t *glyph_data,
Behdad Esfahbod3015c412009-05-20 06:01:16 -040077 unsigned short component,
78 unsigned short ligID);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000079
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040080HB_INTERNAL void
Behdad Esfahbod25e7ef72009-11-06 17:21:01 -050081_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
82 unsigned int num_in,
83 unsigned int num_out,
84 const uint16_t *glyph_data_be,
85 unsigned short component,
86 unsigned short ligID);
87
88HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040089_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
90 hb_codepoint_t glyph_index,
91 unsigned short component,
92 unsigned short ligID);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000093
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040094HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040095_hb_buffer_next_glyph (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000096
Behdad Esfahbod78ef65b2007-11-07 08:06:01 +000097
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +010098HB_INTERNAL void
99_hb_buffer_clear_masks (hb_buffer_t *buffer);
100
101HB_INTERNAL void
Behdad Esfahbod81c5e872010-05-28 18:31:16 -0400102_hb_buffer_set_masks (hb_buffer_t *buffer,
103 hb_mask_t value,
104 hb_mask_t mask,
105 unsigned int cluster_start,
106 unsigned int cluster_end);
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +0100107
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400108
109struct _hb_buffer_t {
110 hb_reference_count_t ref_count;
111
112 /* Information about how the text in the buffer should be treated */
113 hb_unicode_funcs_t *unicode;
114 hb_direction_t direction;
115 hb_script_t script;
116 hb_language_t language;
117
118 /* Buffer contents */
119
Behdad Esfahbod910a33f2010-05-14 22:13:38 -0400120 unsigned int allocated; /* Length of allocated arrays */
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400121
Behdad Esfahboda6a79df2010-05-14 23:20:16 -0400122 hb_bool_t have_output; /* Whether we have an output buffer going on */
123 hb_bool_t have_positions; /* Whether we have positions */
124 hb_bool_t in_error; /* Allocation failed */
Behdad Esfahbod910a33f2010-05-14 22:13:38 -0400125
126 unsigned int i; /* Cursor into ->info and ->pos arrays */
127 unsigned int len; /* Length of ->info and ->pos arrays */
128 unsigned int out_len; /* Length of ->out array */
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400129
Behdad Esfahbod7e7007a2010-05-14 22:02:37 -0400130 hb_internal_glyph_info_t *info;
Behdad Esfahbod9d5e26d2010-05-14 22:03:11 -0400131 hb_internal_glyph_info_t *out_info;
Behdad Esfahbod1b621822010-05-14 22:05:53 -0400132 hb_internal_glyph_position_t *pos;
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400133
134 /* Other stuff */
135
Behdad Esfahbod1b621822010-05-14 22:05:53 -0400136 unsigned int max_lig_id;
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400137
138
139 /* Methods */
140 inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
141 inline void swap (void) { _hb_buffer_swap (this); }
Behdad Esfahbod1d5e7802010-05-12 23:43:00 -0400142 inline void clear_output (void) { _hb_buffer_clear_output (this); }
143 inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
Behdad Esfahbod72071a82010-05-13 13:22:24 -0400144 inline void add_output_glyphs (unsigned int num_in,
145 unsigned int num_out,
146 const hb_codepoint_t *glyph_data,
147 unsigned short component,
148 unsigned short ligID)
149 { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
150 inline void add_output_glyphs_be16 (unsigned int num_in,
151 unsigned int num_out,
152 const uint16_t *glyph_data_be,
153 unsigned short component,
154 unsigned short ligID)
155 { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
Behdad Esfahbod1d5e7802010-05-12 23:43:00 -0400156 inline void add_output_glyph (hb_codepoint_t glyph_index,
157 unsigned short component = 0xFFFF,
158 unsigned short ligID = 0xFFFF)
159 { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
160 inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +0100161
162 inline void clear_masks (void) { _hb_buffer_clear_masks (this); }
Behdad Esfahbod81c5e872010-05-28 18:31:16 -0400163 inline void set_masks (hb_mask_t value,
164 hb_mask_t mask,
165 unsigned int cluster_start,
166 unsigned int cluster_end)
167 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
Behdad Esfahbod1ce7b872010-05-21 17:31:45 +0100168
Behdad Esfahbodd0316a82010-05-12 23:34:52 -0400169};
170
171
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400172HB_END_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000173
Behdad Esfahbodda8edbb2010-06-09 07:15:39 -0400174#endif /* HB_BUFFER_PRIVATE_HH */