Imported Upstream version 1.7.6
[platform/upstream/harfbuzz.git] / src / hb-buffer.h
index bf289c1..8a2d3e8 100644 (file)
@@ -63,7 +63,7 @@ HB_BEGIN_DECLS
  */
 typedef struct hb_glyph_info_t {
   hb_codepoint_t codepoint;
-  hb_mask_t      mask;
+  hb_mask_t      mask; /* Holds hb_glyph_flags_t after hb_shape(), plus other things. */
   uint32_t       cluster;
 
   /*< private >*/
@@ -72,6 +72,37 @@ typedef struct hb_glyph_info_t {
 } hb_glyph_info_t;
 
 /**
+ * hb_glyph_flags_t:
+ * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the
+ *                                beginning of the cluster this glyph is part of,
+ *                                then both sides need to be re-shaped, as the
+ *                                result might be different.  On the flip side,
+ *                                it means that when this flag is not present,
+ *                                then it's safe to break the glyph-run at the
+ *                                beginning of this cluster, and the two sides
+ *                                represent the exact same result one would get
+ *                                if breaking input text at the beginning of
+ *                                this cluster and shaping the two sides
+ *                                separately.  This can be used to optimize
+ *                                paragraph layout, by avoiding re-shaping
+ *                                of each line after line-breaking, or limiting
+ *                                the reshaping to a small piece around the
+ *                                breaking point only.
+ */
+typedef enum { /*< flags >*/
+  HB_GLYPH_FLAG_UNSAFE_TO_BREAK                = 0x00000001,
+
+  HB_GLYPH_FLAG_DEFINED                        = 0x00000001 /* OR of all defined flags */
+} hb_glyph_flags_t;
+
+HB_EXTERN hb_glyph_flags_t
+hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);
+
+#define hb_glyph_info_get_glyph_flags(info) \
+       ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))
+
+
+/**
  * hb_glyph_position_t:
  * @x_advance: how much the line advances after drawing this glyph when setting
  *             text in horizontal direction.
@@ -119,8 +150,8 @@ typedef struct hb_segment_properties_t {
 #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
                                       HB_SCRIPT_INVALID, \
                                       HB_LANGUAGE_INVALID, \
-                                      NULL, \
-                                      NULL}
+                                      (void *) 0, \
+                                      (void *) 0}
 
 HB_EXTERN hb_bool_t
 hb_segment_properties_equal (const hb_segment_properties_t *a,
@@ -163,6 +194,7 @@ HB_EXTERN void *
 hb_buffer_get_user_data (hb_buffer_t        *buffer,
                         hb_user_data_key_t *key);
 
+
 /**
  * hb_buffer_content_type_t:
  * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
@@ -233,13 +265,21 @@ hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
  *                      of the text without the full context.
  * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text
  *                      paragraph can be applied to this buffer, similar to
- *                      @HB_BUFFER_FLAG_EOT.
+ *                      @HB_BUFFER_FLAG_BOT.
  * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:
  *                      flag indication that character with Default_Ignorable
  *                      Unicode property should use the corresponding glyph
- *                      from the font, instead of hiding them (currently done
- *                      by replacing them with the space glyph and zeroing the
- *                      advance width.)
+ *                      from the font, instead of hiding them (done by
+ *                      replacing them with the space glyph and zeroing the
+ *                      advance width.)  This flag takes precedence over
+ *                      @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
+ * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:
+ *                      flag indication that character with Default_Ignorable
+ *                      Unicode property should be removed from glyph string
+ *                      instead of hiding them (done by replacing them with the
+ *                      space glyph and zeroing the advance width.)
+ *                      @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes
+ *                      precedence over this flag. Since: 1.8.0
  *
  * Since: 0.9.20
  */
@@ -247,7 +287,8 @@ typedef enum { /*< flags >*/
   HB_BUFFER_FLAG_DEFAULT                       = 0x00000000u,
   HB_BUFFER_FLAG_BOT                           = 0x00000001u, /* Beginning-of-text */
   HB_BUFFER_FLAG_EOT                           = 0x00000002u, /* End-of-text */
-  HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES   = 0x00000004u
+  HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES   = 0x00000004u,
+  HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES     = 0x00000008u
 } hb_buffer_flags_t;
 
 HB_EXTERN void
@@ -359,6 +400,11 @@ hb_buffer_add_codepoints (hb_buffer_t          *buffer,
                          unsigned int          item_offset,
                          int                   item_length);
 
+HB_EXTERN void
+hb_buffer_append (hb_buffer_t *buffer,
+                 hb_buffer_t *source,
+                 unsigned int start,
+                 unsigned int end);
 
 HB_EXTERN hb_bool_t
 hb_buffer_set_length (hb_buffer_t  *buffer,
@@ -393,6 +439,9 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
  * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
  * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
  * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
+ * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0
+ * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,
+ *  glyph offsets will reflect absolute glyph positions. Since: 1.8.0
  *
  * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
  *
@@ -403,7 +452,9 @@ typedef enum { /*< flags >*/
   HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS         = 0x00000001u,
   HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS                = 0x00000002u,
   HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES      = 0x00000004u,
-  HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS       = 0x00000008u
+  HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS       = 0x00000008u,
+  HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS         = 0x00000010u,
+  HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES         = 0x00000020u
 } hb_buffer_serialize_flags_t;
 
 /**
@@ -453,6 +504,45 @@ hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
 
 
 /*
+ * Compare buffers
+ */
+
+typedef enum { /*< flags >*/
+  HB_BUFFER_DIFF_FLAG_EQUAL                    = 0x0000,
+
+  /* Buffers with different content_type cannot be meaningfully compared
+   * in any further detail. */
+  HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH    = 0x0001,
+
+  /* For buffers with differing length, the per-glyph comparison is not
+   * attempted, though we do still scan reference for dottedcircle / .notdef
+   * glyphs. */
+  HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH          = 0x0002,
+
+  /* We want to know if dottedcircle / .notdef glyphs are present in the
+   * reference, as we may not care so much about other differences in this
+   * case. */
+  HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT           = 0x0004,
+  HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT    = 0x0008,
+
+  /* If the buffers have the same length, we compare them glyph-by-glyph
+   * and report which aspect(s) of the glyph info/position are different. */
+  HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH       = 0x0010,
+  HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH         = 0x0020,
+  HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH     = 0x0040,
+  HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH                = 0x0080
+
+} hb_buffer_diff_flags_t;
+
+/* Compare the contents of two buffers, report types of differences. */
+HB_EXTERN hb_buffer_diff_flags_t
+hb_buffer_diff (hb_buffer_t *buffer,
+               hb_buffer_t *reference,
+               hb_codepoint_t dottedcircle_glyph,
+               unsigned int position_fuzz);
+
+
+/*
  * Debugging.
  */