hb-buffer-private.hh revision 88474c6fdaf35c56368694a5b164f4988a004d49
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.h" 34 35HB_BEGIN_DECLS 36 37 38#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF 39#define component() var1.u16[0] 40#define lig_id() var1.u16[1] 41#define gproperty() var2.u32 42#define back() var.u16[0] /* number of glyphs to go back for drawing current glyph */ 43#define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */ 44 45ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); 46ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); 47 48typedef struct _hb_segment_properties_t { 49 hb_direction_t direction; 50 hb_script_t script; 51 hb_language_t language; 52} hb_segment_properties_t; 53 54 55HB_INTERNAL void 56_hb_buffer_swap (hb_buffer_t *buffer); 57 58HB_INTERNAL void 59_hb_buffer_clear_output (hb_buffer_t *buffer); 60 61HB_INTERNAL void 62_hb_buffer_add_output_glyphs (hb_buffer_t *buffer, 63 unsigned int num_in, 64 unsigned int num_out, 65 const hb_codepoint_t *glyph_data, 66 unsigned short component, 67 unsigned short ligID); 68 69HB_INTERNAL void 70_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, 71 unsigned int num_in, 72 unsigned int num_out, 73 const uint16_t *glyph_data_be, 74 unsigned short component, 75 unsigned short ligID); 76 77HB_INTERNAL void 78_hb_buffer_add_output_glyph (hb_buffer_t *buffer, 79 hb_codepoint_t glyph_index, 80 unsigned short component, 81 unsigned short ligID); 82 83HB_INTERNAL void 84_hb_buffer_next_glyph (hb_buffer_t *buffer); 85 86 87HB_INTERNAL void 88_hb_buffer_reset_masks (hb_buffer_t *buffer, 89 hb_mask_t mask); 90 91HB_INTERNAL void 92_hb_buffer_add_masks (hb_buffer_t *buffer, 93 hb_mask_t mask); 94 95HB_INTERNAL void 96_hb_buffer_set_masks (hb_buffer_t *buffer, 97 hb_mask_t value, 98 hb_mask_t mask, 99 unsigned int cluster_start, 100 unsigned int cluster_end); 101 102 103struct _hb_buffer_t { 104 hb_reference_count_t ref_count; 105 106 /* Information about how the text in the buffer should be treated */ 107 108 hb_unicode_funcs_t *unicode; /* Unicode functions */ 109 hb_segment_properties_t props; /* Script, language, direction */ 110 111 /* Buffer contents */ 112 113 unsigned int allocated; /* Length of allocated arrays */ 114 115 hb_bool_t have_output; /* Whether we have an output buffer going on */ 116 hb_bool_t have_positions; /* Whether we have positions */ 117 hb_bool_t in_error; /* Allocation failed */ 118 119 unsigned int i; /* Cursor into ->info and ->pos arrays */ 120 unsigned int len; /* Length of ->info and ->pos arrays */ 121 unsigned int out_len; /* Length of ->out array */ 122 123 hb_glyph_info_t *info; 124 hb_glyph_info_t *out_info; 125 hb_glyph_position_t *pos; 126 127 /* Other stuff */ 128 129 unsigned int max_lig_id; 130 131 132 /* Methods */ 133 inline unsigned int allocate_lig_id (void) { return max_lig_id++; } 134 inline void swap (void) { _hb_buffer_swap (this); } 135 inline void clear_output (void) { _hb_buffer_clear_output (this); } 136 inline void next_glyph (void) { _hb_buffer_next_glyph (this); } 137 inline void add_output_glyphs (unsigned int num_in, 138 unsigned int num_out, 139 const hb_codepoint_t *glyph_data, 140 unsigned short component, 141 unsigned short ligID) 142 { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); } 143 inline void add_output_glyphs_be16 (unsigned int num_in, 144 unsigned int num_out, 145 const uint16_t *glyph_data_be, 146 unsigned short component, 147 unsigned short ligID) 148 { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); } 149 inline void add_output_glyph (hb_codepoint_t glyph_index, 150 unsigned short component = 0xFFFF, 151 unsigned short ligID = 0xFFFF) 152 { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); } 153 inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); } 154 155 inline void reset_masks (hb_mask_t mask) 156 { 157 for (unsigned int i = 0; i < len; i++) 158 info[i].mask = mask; 159 } 160 inline void add_masks (hb_mask_t mask) 161 { 162 for (unsigned int i = 0; i < len; i++) 163 info[i].mask |= mask; 164 } 165 inline void set_masks (hb_mask_t value, 166 hb_mask_t mask, 167 unsigned int cluster_start, 168 unsigned int cluster_end) 169 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } 170 171}; 172 173 174HB_END_DECLS 175 176#endif /* HB_BUFFER_PRIVATE_HH */ 177