hb-buffer-private.hh revision fb194b8794898f51eb596fa4092c26606889d376
1/* 2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg 3 * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. 4 * 5 * This is part of HarfBuzz, a text shaping 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_PRIVATE_HH 29#define HB_BUFFER_PRIVATE_HH 30 31#include "hb-private.h" 32#include "hb-buffer.h" 33#include "hb-unicode-private.hh" 34 35HB_BEGIN_DECLS 36 37 38ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); 39ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); 40 41typedef struct _hb_segment_properties_t { 42 hb_direction_t direction; 43 hb_script_t script; 44 hb_language_t language; 45} hb_segment_properties_t; 46 47 48HB_INTERNAL void 49_hb_buffer_swap (hb_buffer_t *buffer); 50 51HB_INTERNAL void 52_hb_buffer_clear_output (hb_buffer_t *buffer); 53 54HB_INTERNAL void 55_hb_buffer_clear_positions (hb_buffer_t *buffer); 56 57HB_INTERNAL void 58_hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer, 59 unsigned int num_in, 60 unsigned int num_out, 61 const uint16_t *glyph_data_be); 62 63HB_INTERNAL void 64_hb_buffer_replace_glyph (hb_buffer_t *buffer, 65 hb_codepoint_t glyph_index); 66 67HB_INTERNAL void 68_hb_buffer_next_glyph (hb_buffer_t *buffer); 69 70 71HB_INTERNAL void 72_hb_buffer_reset_masks (hb_buffer_t *buffer, 73 hb_mask_t mask); 74 75HB_INTERNAL void 76_hb_buffer_add_masks (hb_buffer_t *buffer, 77 hb_mask_t mask); 78 79HB_INTERNAL void 80_hb_buffer_set_masks (hb_buffer_t *buffer, 81 hb_mask_t value, 82 hb_mask_t mask, 83 unsigned int cluster_start, 84 unsigned int cluster_end); 85 86 87struct _hb_buffer_t { 88 hb_reference_count_t ref_count; 89 90 /* Information about how the text in the buffer should be treated */ 91 92 hb_unicode_funcs_t *unicode; /* Unicode functions */ 93 hb_segment_properties_t props; /* Script, language, direction */ 94 95 /* Buffer contents */ 96 97 hb_bool_t have_output; /* Whether we have an output buffer going on */ 98 hb_bool_t have_positions; /* Whether we have positions */ 99 hb_bool_t in_error; /* Allocation failed */ 100 101 unsigned int i; /* Cursor into ->info and ->pos arrays */ 102 unsigned int len; /* Length of ->info and ->pos arrays */ 103 unsigned int out_len; /* Length of ->out array if have_output */ 104 105 unsigned int serial; 106 107 unsigned int allocated; /* Length of allocated arrays */ 108 hb_glyph_info_t *info; 109 hb_glyph_info_t *out_info; 110 hb_glyph_position_t *pos; 111 112 113 /* Methods */ 114 inline unsigned int backtrack_len (void) const 115 { return this->have_output? this->out_len : this->i; } 116 inline unsigned int next_serial (void) { return serial++; } 117 inline void swap (void) { _hb_buffer_swap (this); } 118 inline void clear_output (void) { _hb_buffer_clear_output (this); } 119 inline void clear_positions (void) { _hb_buffer_clear_positions (this); } 120 inline void next_glyph (void) { _hb_buffer_next_glyph (this); } 121 inline void replace_glyphs_be16 (unsigned int num_in, 122 unsigned int num_out, 123 const uint16_t *glyph_data_be) 124 { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); } 125 inline void replace_glyph (hb_codepoint_t glyph_index) 126 { _hb_buffer_replace_glyph (this, glyph_index); } 127 128 inline void reset_masks (hb_mask_t mask) 129 { 130 for (unsigned int i = 0; i < len; i++) 131 info[i].mask = mask; 132 } 133 inline void add_masks (hb_mask_t mask) 134 { 135 for (unsigned int i = 0; i < len; i++) 136 info[i].mask |= mask; 137 } 138 inline void set_masks (hb_mask_t value, 139 hb_mask_t mask, 140 unsigned int cluster_start, 141 unsigned int cluster_end) 142 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } 143}; 144 145 146HB_END_DECLS 147 148#endif /* HB_BUFFER_PRIVATE_HH */ 149