[HarfBuzz] harfbuzz-ng: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Nov 6 13:49:16 PST 2009
src/hb-buffer-private.h | 6 ----
src/hb-buffer.c | 2 -
src/hb-buffer.h | 13 +--------
src/hb-ft.c | 2 -
src/hb-ot-layout-gpos-private.hh | 8 +++---
src/hb-ot-layout.cc | 52 +++++++++++++++++++++++++++++++++++++++
src/hb-ot-layout.h | 16 ++++++++----
7 files changed, 72 insertions(+), 27 deletions(-)
New commits:
commit 9db8ad75317d589807e7725455f49cafece58d5d
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 6 16:47:31 2009 -0500
Add hb_ot_layout_position_finish()
We expect buffer to be setup with default positions before GPOS.
diff --git a/src/hb-buffer-private.h b/src/hb-buffer-private.h
index f98f768..3a74f2e 100644
--- a/src/hb-buffer-private.h
+++ b/src/hb-buffer-private.h
@@ -51,11 +51,7 @@ typedef struct _hb_internal_glyph_position_t {
hb_position_t y_advance;
hb_position_t x_offset;
hb_position_t y_offset;
- uint32_t new_advance :1; /* if set, the advance width values are
- absolute, i.e., they won't be
- added to the original glyph's value
- but rather replace them */
- uint32_t back : 15; /* number of glyphs to go back
+ uint32_t back : 16; /* number of glyphs to go back
for drawing current glyph */
int32_t cursive_chain : 16; /* character to which this connects,
may be positive or negative; used
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 195ad34..fb87220 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -56,16 +56,7 @@ typedef struct _hb_glyph_position_t {
hb_position_t y_advance;
hb_position_t x_offset;
hb_position_t y_offset;
- /* XXX these should all be replaced by "uint32_t internal" */
- uint32_t new_advance :1; /* if set, the advance width values are
- absolute, i.e., they won't be
- added to the original glyph's value
- but rather replace them */
- uint32_t back : 15; /* number of glyphs to go back
- for drawing current glyph */
- int32_t cursive_chain : 16; /* character to which this connects,
- may be positive or negative; used
- only internally */
+ uint32_t internal;
} hb_glyph_position_t;
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 3159ab1..f8cbe78 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -840,13 +840,13 @@ struct CursivePosFormat1
if (buffer->direction == HB_DIRECTION_RTL)
{
- POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
- POSITION (buffer->in_pos)->new_advance = true;
+ /* advance is absolute, not relative */
+ POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
}
else
{
- POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
- POSITION (last_pos)->new_advance = true;
+ /* advance is absolute, not relative */
+ POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x;
}
if (lookup_flag & LookupFlag::RightToLeft)
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index d48ef70..45ace5b 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -564,3 +564,55 @@ hb_ot_layout_position_lookup (hb_face_t *face,
context.face = face;
return _get_gpos (face).position_lookup (&context, buffer, lookup_index, mask);
}
+
+#include <stdio.h>
+void
+hb_ot_layout_position_finish (hb_face_t *face,
+ hb_font_t *font,
+ hb_buffer_t *buffer)
+{
+ unsigned int i, j;
+ unsigned int len = hb_buffer_get_length (buffer);
+ hb_internal_glyph_position_t *positions = (hb_internal_glyph_position_t *) hb_buffer_get_glyph_positions (buffer);
+
+ /* TODO: Vertical */
+
+ /* Handle cursive connections */
+ /* First handle all left-to-right connections */
+ for (j = 0; j < len; j++) {
+ if (positions[j].cursive_chain > 0) {
+ printf ("0000000000000\n");
+ positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
+ positions[j].cursive_chain = 0;
+ }
+ }
+ /* Then handle all right-to-left connections */
+ for (i = len; i > 0; i--) {
+ j = i - 1;
+ if (positions[j].cursive_chain < 0) {
+ positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
+ positions[j].cursive_chain = 0;
+ }
+ }
+
+ /* Handle attachments */
+ for (i = 0; i < len; i++)
+ if (positions[i].back)
+ {
+ unsigned int back = i - positions[i].back;
+ positions[i].back = 0;
+ positions[i].x_offset += positions[back].x_offset;
+ positions[i].y_offset += positions[back].y_offset;
+
+ if (buffer->direction == HB_DIRECTION_RTL)
+ for (j = back + 1; j < i + 1; j++) {
+ positions[i].x_offset += positions[j].x_advance;
+ positions[i].y_offset += positions[j].y_advance;
+ }
+ else
+ for (j = back; j < i; j++) {
+ positions[i].x_offset -= positions[j].x_advance;
+ positions[i].y_offset -= positions[j].y_advance;
+ }
+ }
+}
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 773828e..40ead82 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -198,11 +198,17 @@ hb_bool_t
hb_ot_layout_has_positioning (hb_face_t *face);
hb_bool_t
-hb_ot_layout_position_lookup (hb_face_t *face,
- hb_font_t *font,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask);
+hb_ot_layout_position_lookup (hb_face_t *face,
+ hb_font_t *font,
+ hb_buffer_t *buffer,
+ unsigned int lookup_index,
+ hb_mask_t mask);
+
+/* Should be called after all the position_lookup's are done */
+void
+hb_ot_layout_position_finish (hb_face_t *face,
+ hb_font_t *font,
+ hb_buffer_t *buffer);
HB_END_DECLS
commit edb54e9aeca25f4120a69ed3d5562cbb68fdb348
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 6 15:19:22 2009 -0500
Fix FT_Face finalizer call
diff --git a/src/hb-ft.c b/src/hb-ft.c
index 83eb2db..e8295cf 100644
--- a/src/hb-ft.c
+++ b/src/hb-ft.c
@@ -192,7 +192,7 @@ hb_ft_face_create_cached (FT_Face ft_face)
if (HB_UNLIKELY (!ft_face->generic.data || ft_face->generic.finalizer != (FT_Generic_Finalizer) hb_ft_face_finalize))
{
if (ft_face->generic.finalizer)
- ft_face->generic.finalizer (ft_face->generic.data);
+ ft_face->generic.finalizer (ft_face);
ft_face->generic.data = hb_ft_face_create (ft_face, NULL);
ft_face->generic.finalizer = (FT_Generic_Finalizer) hb_ft_face_finalize;
commit 3d14528b8b2e7da425a9df7057fc9fb326d8298c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 6 15:13:17 2009 -0500
Rename hb_buffer_get_len() to hb_buffer_get_length()
diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index d70a6cd..1e4867d 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -413,7 +413,7 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer)
unsigned int
-hb_buffer_get_len (hb_buffer_t *buffer)
+hb_buffer_get_length (hb_buffer_t *buffer)
{
return buffer->in_length;
}
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 5c9d408..195ad34 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -159,7 +159,7 @@ hb_buffer_add_utf32 (hb_buffer_t *buffer,
/* Return value valid as long as buffer not modified */
unsigned int
-hb_buffer_get_len (hb_buffer_t *buffer);
+hb_buffer_get_length (hb_buffer_t *buffer);
/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
More information about the HarfBuzz
mailing list