blob: c8dd2607e5641090e7cd220eab222c1f0845916a [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
Behdad Esfahbod6c786832009-05-25 03:22:19 -04003 * Copyright (C) 2004,2007,2009 Red Hat, Inc.
Behdad Esfahbod6b347132007-10-11 08:30:50 +00004 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00005 * This is part of HarfBuzz, an OpenType Layout engine 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 Esfahbod5c0adce2009-05-20 05:42:12 -040028#ifndef HB_BUFFER_PRIVATE_H
29#define HB_BUFFER_PRIVATE_H
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 Esfahbod6b347132007-10-11 08:30:50 +000033
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040034HB_BEGIN_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +000035
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040036#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
Behdad Esfahbod6b347132007-10-11 08:30:50 +000037
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040038
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040039typedef struct _hb_internal_glyph_info_t {
40 hb_codepoint_t codepoint;
41 uint32_t properties;
42 uint32_t cluster;
43 uint16_t component;
44 uint16_t lig_id;
45 uint32_t gproperty;
46} hb_internal_glyph_info_t;
47
48typedef struct _hb_internal_glyph_position_t {
49 hb_position_t x_pos;
50 hb_position_t y_pos;
51 hb_position_t x_advance;
52 hb_position_t y_advance;
53 hb_bool_t new_advance :1; /* if set, the advance width values are
54 absolute, i.e., they won't be
55 added to the original glyph's value
56 but rather replace them */
57 unsigned short back : 15; /* number of glyphs to go back
58 for drawing current glyph */
59 short cursive_chain : 16; /* character to which this connects,
60 may be positive or negative; used
61 only internally */
62} hb_internal_glyph_position_t;
63
64ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
65ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
66ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
67
68
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040069struct _hb_buffer_t {
70 hb_reference_count_t ref_count;
71
72 unsigned int allocated;
73
74 unsigned int in_length;
75 unsigned int out_length;
76 unsigned int in_pos;
77 unsigned int out_pos;
78
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040079 hb_internal_glyph_info_t *in_string;
80 hb_internal_glyph_info_t *out_string;
81 hb_internal_glyph_info_t *alt_string;
82 hb_internal_glyph_position_t *positions;
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040083
84 hb_direction_t direction;
85 unsigned int max_lig_id;
86};
87
88
Behdad Esfahbod6b347132007-10-11 08:30:50 +000089HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040090_hb_buffer_swap (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000091
92HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040093_hb_buffer_clear_output (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +000094
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040095HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -040096_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
97 unsigned int num_in,
98 unsigned int num_out,
Behdad Esfahbod88a5f5a2009-05-25 03:39:11 -040099 const uint16_t *glyph_data_be,
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400100 unsigned short component,
101 unsigned short ligID);
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000102
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400103HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400104_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
105 hb_codepoint_t glyph_index,
106 unsigned short component,
107 unsigned short ligID);
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000108
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400109HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400110_hb_buffer_next_glyph (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000111
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400112HB_INTERNAL void
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400113_hb_buffer_replace_glyph (hb_buffer_t *buffer,
114 hb_codepoint_t glyph_index);
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000115
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400116HB_INTERNAL unsigned short
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400117_hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000118
Behdad Esfahbod78ef65b2007-11-07 08:06:01 +0000119
120/* convenience macros */
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400121#define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint)
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400122#define IN_INFO(pos) (&buffer->in_string[(pos)])
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400123#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].codepoint)
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400124#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400125#define IN_PROPERTIES(pos) (buffer->in_string[(pos)].properties)
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400126#define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id)
Behdad Esfahbod3015c412009-05-20 06:01:16 -0400127#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
128#define POSITION(pos) (&buffer->positions[(pos)])
129#define CURPOSITION() (&buffer->positions[buffer->in_pos])
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400130#define OUT_GLYPH(pos) (buffer->out_string[(pos)].codepoint)
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400131#define OUT_INFO(pos) (&buffer->out_string[(pos)])
Behdad Esfahbod78ef65b2007-11-07 08:06:01 +0000132
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400133HB_END_DECLS
Behdad Esfahbod6b347132007-10-11 08:30:50 +0000134
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -0400135#endif /* HB_BUFFER_PRIVATE_H */