[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Dec 20 08:45:33 PST 2009
src/Makefile.am | 9 ++++--
src/hb-buffer-private.h | 3 +-
src/hb-buffer.c | 30 +++++++++++---------
src/hb-common.h | 2 +
src/hb-font.cc | 3 ++
src/hb-shape.c | 71 ++++++++++++++++++++++++++++++++++++------------
src/hb-unicode.c | 37 +++++++++++++++++++++++++
src/hb-unicode.h | 21 ++++++++++++++
8 files changed, 142 insertions(+), 34 deletions(-)
New commits:
commit 001fc2d2aa22f14302739fe4ca45f7535855e0fb
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 17:24:05 2009 +0100
Add TrueType kern support
diff --git a/src/hb-shape.c b/src/hb-shape.c
index 2ad9457..e641df4 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -49,6 +49,37 @@ hb_form_clusters (hb_buffer_t *buffer)
IN_CLUSTER (buffer->in_pos) = IN_CLUSTER (buffer->in_pos - 1);
}
+static hb_direction_t
+hb_ensure_native_direction (hb_buffer_t *buffer)
+{
+ hb_direction_t original_direction = buffer->direction;
+
+ /* TODO vertical */
+ if (HB_DIRECTION_IS_HORIZONTAL (original_direction) &&
+ original_direction != _hb_script_get_horizontal_direction (buffer->script))
+ {
+ hb_buffer_reverse_clusters (buffer);
+ buffer->direction ^= 1;
+ }
+
+ return original_direction;
+}
+
+static void
+hb_mirror_chars (hb_buffer_t *buffer)
+{
+ unsigned int count;
+ hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->get_mirroring;
+
+ if (HB_DIRECTION_IS_FORWARD (buffer->direction))
+ return;
+
+ count = buffer->in_length;
+ for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
+ IN_CURGLYPH() = get_mirroring (IN_CURGLYPH());
+ }
+}
+
static void
hb_map_glyphs (hb_font_t *font,
hb_face_t *face,
@@ -86,39 +117,25 @@ hb_position_default (hb_font_t *font,
}
}
-
-static hb_direction_t
-hb_ensure_native_direction (hb_buffer_t *buffer)
-{
- hb_direction_t original_direction = buffer->direction;
-
- /* TODO vertical */
- if (HB_DIRECTION_IS_HORIZONTAL (original_direction) &&
- original_direction != _hb_script_get_horizontal_direction (buffer->script))
- {
- hb_buffer_reverse_clusters (buffer);
- buffer->direction ^= 1;
- }
-
- return original_direction;
-}
-
static void
-hb_mirror_chars (hb_buffer_t *buffer)
+hb_truetype_kern (hb_font_t *font,
+ hb_face_t *face,
+ hb_buffer_t *buffer)
{
unsigned int count;
- hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->get_mirroring;
-
- if (HB_DIRECTION_IS_FORWARD (buffer->direction))
- return;
count = buffer->in_length;
- for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
- IN_CURGLYPH() = get_mirroring (IN_CURGLYPH());
+ for (buffer->in_pos = 1; buffer->in_pos < count; buffer->in_pos++) {
+ hb_position_t kern, kern1, kern2;
+ kern = hb_font_get_kerning (font, face, IN_GLYPH(buffer->in_pos - 1), IN_CURGLYPH());
+ kern1 = kern >> 1;
+ kern2 = kern - kern1;
+ POSITION(buffer->in_pos - 1)->x_advance += kern1;
+ CURPOSITION()->x_advance += kern2;
+ CURPOSITION()->x_offset += kern2;
}
}
-
void
hb_shape (hb_font_t *font,
hb_face_t *face,
@@ -127,6 +144,7 @@ hb_shape (hb_font_t *font,
unsigned int num_features)
{
hb_direction_t original_direction;
+ hb_bool_t complex_positioning_applied;
hb_form_clusters (buffer);
original_direction = hb_ensure_native_direction (buffer);
@@ -144,10 +162,14 @@ hb_shape (hb_font_t *font,
hb_position_default (font, face, buffer);
- /* GPOS / kern */
+ /* GPOS */
+ complex_positioning_applied = FALSE;
if (HB_DIRECTION_IS_BACKWARD (buffer->direction))
hb_buffer_reverse (buffer);
+ if (!complex_positioning_applied)
+ hb_truetype_kern (font, face, buffer);
+
buffer->direction = original_direction;
}
commit 2c1b85cf66e5ecb7521b6018b76f0e161fb68967
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 16:29:17 2009 +0100
Direct unicode->get_mirroring directly
diff --git a/src/hb-shape.c b/src/hb-shape.c
index 74cab9e..2ad9457 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -107,14 +107,14 @@ static void
hb_mirror_chars (hb_buffer_t *buffer)
{
unsigned int count;
- hb_unicode_funcs_t *unicode = buffer->unicode;
+ hb_unicode_get_mirroring_func_t get_mirroring = buffer->unicode->get_mirroring;
if (HB_DIRECTION_IS_FORWARD (buffer->direction))
return;
count = buffer->in_length;
for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
- IN_CURGLYPH() = hb_unicode_get_mirroring (unicode, IN_CURGLYPH());
+ IN_CURGLYPH() = get_mirroring (IN_CURGLYPH());
}
}
commit 6a2ef5aa5459def232708af30ef8a484906b868b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 16:28:01 2009 +0100
Do mirroring
diff --git a/src/hb-shape.c b/src/hb-shape.c
index 2605af6..74cab9e 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -103,6 +103,21 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
return original_direction;
}
+static void
+hb_mirror_chars (hb_buffer_t *buffer)
+{
+ unsigned int count;
+ hb_unicode_funcs_t *unicode = buffer->unicode;
+
+ if (HB_DIRECTION_IS_FORWARD (buffer->direction))
+ return;
+
+ count = buffer->in_length;
+ for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
+ IN_CURGLYPH() = hb_unicode_get_mirroring (unicode, IN_CURGLYPH());
+ }
+}
+
void
hb_shape (hb_font_t *font,
@@ -116,7 +131,8 @@ hb_shape (hb_font_t *font,
hb_form_clusters (buffer);
original_direction = hb_ensure_native_direction (buffer);
- /* do_mirroring (buffer); */
+ hb_mirror_chars (buffer);
+
/* OT preprocess */
hb_map_glyphs (font, face, buffer);
commit 0465e69832393cc1ed36508ec5d597fbab64877a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 16:25:18 2009 +0100
Protect against NULL funcs
diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index 9d4d518..4dd18ed 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -121,6 +121,9 @@ void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode)
{
+ if (!unicode)
+ unicode = &_hb_unicode_funcs_nil;
+
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = unicode;
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 1cffc91..b284477 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -385,6 +385,9 @@ hb_font_set_funcs (hb_font_t *font,
if (font->destroy)
font->destroy (font->user_data);
+ if (!klass)
+ klass = &_hb_font_funcs_nil;
+
hb_font_funcs_reference (klass);
hb_font_funcs_destroy (font->klass);
font->klass = klass;
commit 5ceefa1d8dbd310570ea8d1c47107fe8d3dc96d9
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 15:29:16 2009 +0100
Add hb_unicode_get_*() functions
diff --git a/src/hb-unicode.c b/src/hb-unicode.c
index d8ea0ea..a897f23 100644
--- a/src/hb-unicode.c
+++ b/src/hb-unicode.c
@@ -160,6 +160,43 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
}
+hb_codepoint_t
+hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode)
+{
+ return ufuncs->get_mirroring (unicode);
+}
+
+hb_category_t
+hb_unicode_get_general_category (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode)
+{
+ return ufuncs->get_general_category (unicode);
+}
+
+hb_script_t
+hb_unicode_get_script (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode)
+{
+ return ufuncs->get_script (unicode);
+}
+
+unsigned int
+hb_unicode_get_combining_class (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode)
+{
+ return ufuncs->get_combining_class (unicode);
+}
+
+unsigned int
+hb_unicode_get_eastasian_width (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode)
+{
+ return ufuncs->get_eastasian_width (unicode);
+}
+
+
+
#define LTR HB_DIRECTION_LTR
#define RTL HB_DIRECTION_RTL
const hb_direction_t horiz_dir[] =
diff --git a/src/hb-unicode.h b/src/hb-unicode.h
index b7c3a75..6b63352 100644
--- a/src/hb-unicode.h
+++ b/src/hb-unicode.h
@@ -214,6 +214,27 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
hb_unicode_get_eastasian_width_func_t eastasian_width_func);
+hb_codepoint_t
+hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+hb_category_t
+hb_unicode_get_general_category (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+hb_script_t
+hb_unicode_get_script (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+unsigned int
+hb_unicode_get_combining_class (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+unsigned int
+hb_unicode_get_eastasian_width (hb_unicode_funcs_t *ufuncs,
+ hb_codepoint_t unicode);
+
+
HB_END_DECLS
#endif /* HB_UNICODE_H */
commit b8a53e44ce05911ce98b7cff34dee165e19d87ba
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 14:56:25 2009 +0100
We'll have to link to libstdc++ if linking to ICU, so disable test for now
We have to get rid of the ICU in main lib. Still thinking about best way
to do it.
diff --git a/src/Makefile.am b/src/Makefile.am
index 34af84f..ca6dc4d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -96,8 +96,11 @@ main_SOURCES = main.cc
main_CPPFLAGS = $(HBCFLAGS)
main_LDADD = libharfbuzz.la $(HBLIBS)
-TESTS = \
- check-libstdc++.sh \
- $(NULL)
+TESTS =
+
+if HAVE_ICU
+else
+TESTS += check-libstdc++.sh
+endif
-include $(top_srcdir)/git.mk
commit 314905d7548d5be58354546d660754b807b6efb2
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 14:50:42 2009 +0100
Explicitly track whether the buffer has positions
diff --git a/src/hb-buffer-private.h b/src/hb-buffer-private.h
index 6ba1a21..821a481 100644
--- a/src/hb-buffer-private.h
+++ b/src/hb-buffer-private.h
@@ -76,7 +76,8 @@ struct _hb_buffer_t {
unsigned int allocated;
- hb_bool_t have_output; /* weather we have an output buffer going on */
+ hb_bool_t have_output; /* whether we have an output buffer going on */
+ hb_bool_t have_positions; /* whether we have positions */
unsigned int in_length;
unsigned int out_length;
unsigned int in_pos;
diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index 723b8bd..9d4d518 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -177,6 +177,7 @@ void
hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
+ buffer->have_positions = FALSE;
buffer->in_length = 0;
buffer->out_length = 0;
buffer->in_pos = 0;
@@ -241,6 +242,7 @@ void
_hb_buffer_clear_output (hb_buffer_t *buffer)
{
buffer->have_output = TRUE;
+ buffer->have_positions = FALSE;
buffer->out_length = 0;
buffer->out_pos = 0;
buffer->out_string = buffer->in_string;
@@ -251,6 +253,7 @@ hb_buffer_clear_positions (hb_buffer_t *buffer)
{
_hb_buffer_clear_output (buffer);
buffer->have_output = FALSE;
+ buffer->have_positions = TRUE;
if (HB_UNLIKELY (!buffer->positions))
{
@@ -420,23 +423,21 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
void
_hb_buffer_next_glyph (hb_buffer_t *buffer)
{
- if (!buffer->have_output)
+ if (buffer->have_output)
{
- buffer->in_pos++;
- return;
- }
+ if (buffer->out_string != buffer->in_string)
+ {
+ hb_buffer_ensure (buffer, buffer->out_pos + 1);
+ buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
+ }
+ else if (buffer->out_pos != buffer->in_pos)
+ buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
- if (buffer->out_string != buffer->in_string)
- {
- hb_buffer_ensure (buffer, buffer->out_pos + 1);
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
+ buffer->out_pos++;
+ buffer->out_length = buffer->out_pos;
}
- else if (buffer->out_pos != buffer->in_pos)
- buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
buffer->in_pos++;
- buffer->out_pos++;
- buffer->out_length = buffer->out_pos;
}
void
@@ -470,7 +471,7 @@ hb_buffer_get_glyph_infos (hb_buffer_t *buffer)
hb_glyph_position_t *
hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
{
- if (buffer->have_output || (buffer->in_length && !buffer->positions))
+ if (!buffer->have_positions)
hb_buffer_clear_positions (buffer);
return (hb_glyph_position_t *) buffer->positions;
commit 314b460d8a02ed4b2789ff527cf6c9bc19769114
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 20 13:58:50 2009 +0100
Add HB_DIRECTION_IS_FORWARD/BACKWARD
diff --git a/src/hb-common.h b/src/hb-common.h
index d07b204..25249cc 100644
--- a/src/hb-common.h
+++ b/src/hb-common.h
@@ -81,6 +81,8 @@ typedef enum _hb_direction_t {
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((dir) == HB_DIRECTION_LTR || (dir) == HB_DIRECTION_RTL)
#define HB_DIRECTION_IS_VERTICAL(dir) ((dir) == HB_DIRECTION_TTB || (dir) == HB_DIRECTION_BTT)
+#define HB_DIRECTION_IS_FORWARD(dir) ((dir) == HB_DIRECTION_LTR || (dir) == HB_DIRECTION_TTB)
+#define HB_DIRECTION_IS_BACKWARD(dir) ((dir) == HB_DIRECTION_RTL || (dir) == HB_DIRECTION_BTT)
#endif /* HB_COMMON_H */
diff --git a/src/hb-shape.c b/src/hb-shape.c
index 197d4a0..2605af6 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -130,8 +130,7 @@ hb_shape (hb_font_t *font,
/* GPOS / kern */
- /* TODO: Vertical */
- if (buffer->direction == HB_DIRECTION_RTL)
+ if (HB_DIRECTION_IS_BACKWARD (buffer->direction))
hb_buffer_reverse (buffer);
buffer->direction = original_direction;
More information about the HarfBuzz
mailing list