[HarfBuzz] harfbuzz-ng: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun May 27 06:16:36 PDT 2012
src/hb-ot-shape-complex-indic-machine.rl | 2 +-
src/hb-ot-shape-complex-indic.cc | 2 +-
src/hb-set-private.hh | 31 ++++++++++++++++++++++++++++---
src/hb-set.cc | 14 ++++++++++++++
src/hb-set.h | 13 +++++++++++++
util/hb-ot-shape-closure.cc | 8 +++++---
util/helper-cairo.cc | 2 +-
util/options.cc | 6 +++++-
8 files changed, 68 insertions(+), 10 deletions(-)
New commits:
commit 8f8956a55fff95e5ad529d2f124c9528d1f4f81d
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri May 25 14:30:24 2012 -0400
[util] Add hidden --shaper that is equivalent of --shapers
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index de45fb3..77fd1a6 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -297,7 +297,7 @@ helper_cairo_create_context (double w, double h,
unsigned int fr, fg, fb, fa, br, bg, bb, ba;
- br = bg = bb = ba = 255;
+ br = bg = bb = 0; ba = 255;
sscanf (view_opts->back + (*view_opts->back=='#'), "%2x%2x%2x%2x", &br, &bg, &bb, &ba);
fr = fg = fb = 0; fa = 255;
sscanf (view_opts->fore + (*view_opts->fore=='#'), "%2x%2x%2x%2x", &fr, &fg, &fb, &fa);
diff --git a/util/options.cc b/util/options.cc
index 363a150..463daee 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Google, Inc.
+ * Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -178,6 +178,7 @@ parse_shapers (const char *name G_GNUC_UNUSED,
GError **error G_GNUC_UNUSED)
{
shape_options_t *shape_opts = (shape_options_t *) data;
+ g_free (shape_opts->shapers);
shape_opts->shapers = g_strsplit (arg, ",", 0);
return TRUE;
}
@@ -330,6 +331,7 @@ parse_features (const char *name G_GNUC_UNUSED,
char *p;
shape_opts->num_features = 0;
+ g_free (shape_opts->features);
shape_opts->features = NULL;
if (!*s)
@@ -387,6 +389,8 @@ shape_options_t::add_options (option_parser_t *parser)
{
{"list-shapers", 0, G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK, (gpointer) &list_shapers, "List available shapers and quit", NULL},
+ {"shaper", 0, G_OPTION_FLAG_HIDDEN,
+ G_OPTION_ARG_CALLBACK, (gpointer) &parse_shapers, "Hidden duplicate of --shapers", NULL},
{"shapers", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_shapers, "Comma-separated list of shapers to try","list"},
{"direction", 0, 0, G_OPTION_ARG_STRING, &this->direction, "Set text direction (default: auto)", "ltr/rtl/ttb/btt"},
{"language", 0, 0, G_OPTION_ARG_STRING, &this->language, "Set text language (default: $LANG)", "langstr"},
commit 29ce446d3161b7ea5874352e5f8eb33cd59338c3
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri May 25 14:17:54 2012 -0400
Add set iterator
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index df96b99..9d8ba4a 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -32,6 +32,7 @@
#include "hb-object-private.hh"
+/* TODO Make this faster and memmory efficient. */
struct _hb_set_t
{
@@ -51,6 +52,7 @@ struct _hb_set_t
}
inline void add (hb_codepoint_t g)
{
+ if (unlikely (g == SENTINEL)) return;
if (unlikely (g > MAX_G)) return;
elt (g) |= mask (g);
}
@@ -107,6 +109,23 @@ struct _hb_set_t
for (unsigned int i = 0; i < ELTS; i++)
elts[i] ^= other->elts[i];
}
+ inline bool next (hb_codepoint_t *codepoint)
+ {
+ if (unlikely (*codepoint == SENTINEL)) {
+ hb_codepoint_t i = get_min ();
+ if (i != SENTINEL) {
+ *codepoint = i;
+ return true;
+ } else
+ return false;
+ }
+ for (hb_codepoint_t i = *codepoint + 1; i < MAX_G + 1; i++)
+ if (has (i)) {
+ *codepoint = i;
+ return true;
+ }
+ return false;
+ }
inline hb_codepoint_t get_min (void) const
{
for (unsigned int i = 0; i < ELTS; i++)
@@ -114,7 +133,7 @@ struct _hb_set_t
for (unsigned int j = 0; i < BITS; j++)
if (elts[i] & (1 << j))
return i * BITS + j;
- return 0;
+ return SENTINEL;
}
inline hb_codepoint_t get_max (void) const
{
@@ -123,15 +142,16 @@ struct _hb_set_t
for (unsigned int j = BITS; j; j--)
if (elts[i - 1] & (1 << (j - 1)))
return (i - 1) * BITS + (j - 1);
- return 0;
+ return SENTINEL;
}
typedef uint32_t elt_t;
- static const unsigned int MAX_G = 65536 - 1;
+ static const unsigned int MAX_G = 65536 - 1; /* XXX Fix this... */
static const unsigned int SHIFT = 5;
static const unsigned int BITS = (1 << SHIFT);
static const unsigned int MASK = BITS - 1;
static const unsigned int ELTS = (MAX_G + 1 + (BITS - 1)) / BITS;
+ static const hb_codepoint_t SENTINEL = (hb_codepoint_t) -1;
elt_t &elt (hb_codepoint_t g) { return elts[g >> SHIFT]; }
elt_t elt (hb_codepoint_t g) const { return elts[g >> SHIFT]; }
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 7103bcd..5045386 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -182,3 +182,10 @@ hb_set_max (hb_set_t *set)
{
return set->get_max ();
}
+
+hb_bool_t
+hb_set_next (hb_set_t *set,
+ hb_codepoint_t *codepoint)
+{
+ return set->next (codepoint);
+}
diff --git a/src/hb-set.h b/src/hb-set.h
index 38bb84b..97e68e4 100644
--- a/src/hb-set.h
+++ b/src/hb-set.h
@@ -77,6 +77,8 @@ hb_bool_t
hb_set_has (hb_set_t *set,
hb_codepoint_t codepoint);
+/* Right now limited to 16-bit integers. Eventually will do full codepoint range, sans -1
+ * which we will use as a sentinel. */
void
hb_set_add (hb_set_t *set,
hb_codepoint_t codepoint);
@@ -109,14 +111,19 @@ void
hb_set_symmetric_difference (hb_set_t *set,
hb_set_t *other);
-/* Undefined if set empty */
+/* Returns -1 if set empty. */
hb_codepoint_t
hb_set_min (hb_set_t *set);
-/* Undefined if set empty */
+/* Returns -1 if set empty. */
hb_codepoint_t
hb_set_max (hb_set_t *set);
+/* Pass -1 in to get started. */
+hb_bool_t
+hb_set_next (hb_set_t *set,
+ hb_codepoint_t *codepoint);
+
/* TODO: Add faster iteration API? */
diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc
index afd88ae..55481c6 100644
--- a/util/hb-ot-shape-closure.cc
+++ b/util/hb-ot-shape-closure.cc
@@ -66,11 +66,13 @@ struct shape_closure_consumer_t : option_group_t
hb_set_clear (glyphs);
shaper.shape_closure (text, text_len, font, buffer, glyphs);
+
+ if (hb_set_empty (glyphs))
+ return;
+
/* Print it out! */
- hb_codepoint_t start = hb_set_min (glyphs);
- hb_codepoint_t end = 1 + hb_set_max (glyphs);
bool first = true;
- for (hb_codepoint_t i = start; i < end; i++)
+ for (hb_codepoint_t i = -1; hb_set_next (glyphs, &i);)
if (hb_set_has (glyphs, i)) {
if (first)
first = false;
commit 62c3e111fce0ad34960871134c2eb6da572df303
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri May 25 13:48:00 2012 -0400
Add set symmetric difference
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 717e530..df96b99 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -102,6 +102,11 @@ struct _hb_set_t
for (unsigned int i = 0; i < ELTS; i++)
elts[i] &= ~other->elts[i];
}
+ inline void symmetric_difference (const hb_set_t *other)
+ {
+ for (unsigned int i = 0; i < ELTS; i++)
+ elts[i] ^= other->elts[i];
+ }
inline hb_codepoint_t get_min (void) const
{
for (unsigned int i = 0; i < ELTS; i++)
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 0e8adde..7103bcd 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -164,6 +164,13 @@ hb_set_subtract (hb_set_t *set,
set->subtract (other);
}
+void
+hb_set_symmetric_difference (hb_set_t *set,
+ hb_set_t *other)
+{
+ set->symmetric_difference (other);
+}
+
hb_codepoint_t
hb_set_min (hb_set_t *set)
{
diff --git a/src/hb-set.h b/src/hb-set.h
index 35c77b8..38bb84b 100644
--- a/src/hb-set.h
+++ b/src/hb-set.h
@@ -105,9 +105,15 @@ void
hb_set_subtract (hb_set_t *set,
hb_set_t *other);
+void
+hb_set_symmetric_difference (hb_set_t *set,
+ hb_set_t *other);
+
+/* Undefined if set empty */
hb_codepoint_t
hb_set_min (hb_set_t *set);
+/* Undefined if set empty */
hb_codepoint_t
hb_set_max (hb_set_t *set);
commit 27aba594c90b4444c35273a38f5fedc8e09d9a88
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu May 24 15:00:01 2012 -0400
Minor
diff --git a/src/hb-ot-shape-complex-indic-machine.rl b/src/hb-ot-shape-complex-indic-machine.rl
index 207a88f..93ca29a 100644
--- a/src/hb-ot-shape-complex-indic-machine.rl
+++ b/src/hb-ot-shape-complex-indic-machine.rl
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Google, Inc.
+ * Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 3712d06..0c5479e 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Google, Inc.
+ * Copyright © 2011,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
More information about the HarfBuzz
mailing list