summaryrefslogtreecommitdiff
path: root/src/hb-buffer-private.hh
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2012-09-25 17:44:53 -0400
committerBehdad Esfahbod <behdad@behdad.org>2012-09-25 21:32:21 -0400
commit05207a79e0ae1769c5feaebe3fd99bdf9cfcf834 (patch)
treee0230b086473429f74e0fa1af3cac8e669a7b730 /src/hb-buffer-private.hh
parent89ac39dbbe028e6379f64392f2e590e3f1fdd847 (diff)
[buffer] Save pre/post textual context
To be used for a variety of purposes. We save up to five characters in each direction. No public API changes, everything is taken care of already. All clients need to do is to call hb_buffer_add_utf* with the full text + segment info (or at least some context) instead of just passing in the segment. Various operations (hb_buffer_reset, hb_buffer_set_length, hb_buffer_add*) automatically reset the relevant contexts.
Diffstat (limited to 'src/hb-buffer-private.hh')
-rw-r--r--src/hb-buffer-private.hh13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index f5d64f3f..67a2752c 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -1,7 +1,7 @@
/*
* Copyright © 1998-2004 David Turner and Werner Lemberg
* Copyright © 2004,2007,2009,2010 Red Hat, Inc.
- * Copyright © 2011 Google, Inc.
+ * Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -117,9 +117,18 @@ struct hb_buffer_t {
inline hb_glyph_info_t prev (void) const { return info[out_len - 1]; }
unsigned int serial;
+
+ /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */
uint8_t allocated_var_bytes[8];
const char *allocated_var_owner[8];
+ /* Text before / after the main buffer contents.
+ * Always in Unicode, and ordered outward.
+ * Index 0 is for "pre-context", 1 for "post-context". */
+ static const unsigned int CONTEXT_LENGTH = 5;
+ hb_codepoint_t context[2][CONTEXT_LENGTH];
+ unsigned int context_len[2];
+
/* Methods */
@@ -206,6 +215,8 @@ struct hb_buffer_t {
HB_INTERNAL bool make_room_for (unsigned int num_in, unsigned int num_out);
HB_INTERNAL void *get_scratch_buffer (unsigned int *size);
+
+ inline void clear_context (unsigned int side) { context_len[side] = 0; }
};