TODO | 8 +++++- src/hb-blob.h | 2 - src/hb-common.cc | 7 +++-- src/hb-common.h | 29 +++++++++++----------- src/hb-ot-layout-private.hh | 2 - src/hb-ot-shape-normalize.cc | 11 ++++++-- src/hb-ot-shape-private.hh | 49 ------------------------------------- src/hb-ot-shape.cc | 56 +++++++++++++++++++++++++++++++++++++++---- test/api/test-common.c | 16 ++++++++++-- 9 files changed, 102 insertions(+), 78 deletions(-)
New commits: commit 683b503f30bba29d57a93d7e8ac7138c2e7f49f1 Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 20:47:14 2012 -0400 Minor diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index f7b3547..b9834ca 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -68,12 +68,19 @@ * matra for the Indic shaper. */ +static inline void +set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode) +{ + info->general_category() = hb_unicode_general_category (unicode, info->codepoint); + info->combining_class() = _hb_unicode_modified_combining_class (unicode, info->codepoint); +} + static void output_glyph (hb_font_t *font, hb_buffer_t *buffer, hb_codepoint_t glyph) { buffer->output_glyph (glyph); - hb_glyph_info_set_unicode_props (&buffer->out_info[buffer->out_len - 1], buffer->unicode); + set_unicode_props (&buffer->out_info[buffer->out_len - 1], buffer->unicode); } static bool @@ -262,7 +269,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer, { /* Composes. Modify starter and carry on. */ buffer->out_info[starter].codepoint = composed; - hb_glyph_info_set_unicode_props (&buffer->out_info[starter], buffer->unicode); + set_unicode_props (&buffer->out_info[starter], buffer->unicode); buffer->skip_glyph (); continue; diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 8685ece..5fc69b1 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -47,19 +47,10 @@ struct hb_ot_shape_plan_t -static inline void -hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode) -{ - info->general_category() = hb_unicode_general_category (unicode, info->codepoint); - info->combining_class() = _hb_unicode_modified_combining_class (unicode, info->codepoint); -} - HB_INTERNAL hb_bool_t _hb_ot_shape (hb_font_t *font, hb_buffer_t *buffer, const hb_feature_t *features, unsigned int num_features); -#include "hb-ot-shape-complex-private.hh" - #endif /* HB_OT_SHAPE_PRIVATE_HH */ diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index f5f9fd3..d21559c 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -169,12 +169,19 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c) /* Prepare */ +static inline void +set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode) +{ + info->general_category() = hb_unicode_general_category (unicode, info->codepoint); + info->combining_class() = _hb_unicode_modified_combining_class (unicode, info->codepoint); +} + static void hb_set_unicode_props (hb_buffer_t *buffer) { unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) - hb_glyph_info_set_unicode_props (&buffer->info[i], buffer->unicode); + set_unicode_props (&buffer->info[i], buffer->unicode); } static void commit b9f199c8e38cc5ed0d73845568630f3bcbdd4374 Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 20:23:58 2012 -0400 Move code around diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh index 2ceb6f2..8685ece 100644 --- a/src/hb-ot-shape-private.hh +++ b/src/hb-ot-shape-private.hh @@ -31,13 +31,10 @@ #include "hb-ot-map-private.hh" #include "hb-ot-shape-complex-private.hh" -#include "hb-ot-shape-normalize-private.hh" struct hb_ot_shape_plan_t { - friend struct hb_ot_shape_planner_t; - hb_ot_map_t map; hb_ot_complex_shaper_t shaper; @@ -48,41 +45,6 @@ struct hb_ot_shape_plan_t NO_COPY (hb_ot_shape_plan_t); }; -struct hb_ot_shape_planner_t -{ - hb_ot_map_builder_t map; - hb_ot_complex_shaper_t shaper; - - hb_ot_shape_planner_t (void) : map () {} - ~hb_ot_shape_planner_t (void) { map.finish (); } - - inline void compile (hb_face_t *face, - const hb_segment_properties_t *props, - struct hb_ot_shape_plan_t &plan) - { - plan.shaper = shaper; - map.compile (face, props, plan.map); - } - - private: - NO_COPY (hb_ot_shape_planner_t); -}; - - -struct hb_ot_shape_context_t -{ - /* Input to hb_ot_shape_execute() */ - hb_ot_shape_plan_t *plan; - hb_font_t *font; - hb_face_t *face; - hb_buffer_t *buffer; - const hb_feature_t *user_features; - unsigned int num_user_features; - - /* Transient stuff */ - hb_direction_t target_direction; - hb_bool_t applied_position_complex; -}; static inline void @@ -92,8 +54,6 @@ hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unic info->combining_class() = _hb_unicode_modified_combining_class (unicode, info->codepoint); } -HB_INTERNAL void _hb_set_unicode_props (hb_buffer_t *buffer); - HB_INTERNAL hb_bool_t _hb_ot_shape (hb_font_t *font, hb_buffer_t *buffer, diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 6960acf..f5f9fd3 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -27,7 +27,7 @@ */ #include "hb-ot-shape-private.hh" -#include "hb-ot-shape-complex-private.hh" +#include "hb-ot-shape-normalize-private.hh" #include "hb-font-private.hh" @@ -62,6 +62,28 @@ hb_tag_t vertical_features[] = { HB_TAG('v','r','t','2'), }; + + +struct hb_ot_shape_planner_t +{ + hb_ot_map_builder_t map; + hb_ot_complex_shaper_t shaper; + + hb_ot_shape_planner_t (void) : map () {} + ~hb_ot_shape_planner_t (void) { map.finish (); } + + inline void compile (hb_face_t *face, + const hb_segment_properties_t *props, + struct hb_ot_shape_plan_t &plan) + { + plan.shaper = shaper; + map.compile (face, props, plan.map); + } + + private: + NO_COPY (hb_ot_shape_planner_t); +}; + static void hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props, @@ -108,6 +130,21 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, } +struct hb_ot_shape_context_t +{ + /* Input to hb_ot_shape_execute() */ + hb_ot_shape_plan_t *plan; + hb_font_t *font; + hb_face_t *face; + hb_buffer_t *buffer; + const hb_feature_t *user_features; + unsigned int num_user_features; + + /* Transient stuff */ + hb_direction_t target_direction; + hb_bool_t applied_position_complex; +}; + static void hb_ot_shape_setup_masks (hb_ot_shape_context_t *c) { @@ -132,8 +169,8 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c) /* Prepare */ -void -_hb_set_unicode_props (hb_buffer_t *buffer) +static void +hb_set_unicode_props (hb_buffer_t *buffer) { unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) @@ -349,7 +386,7 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c) HB_BUFFER_ALLOCATE_VAR (c->buffer, general_category); HB_BUFFER_ALLOCATE_VAR (c->buffer, combining_class); - _hb_set_unicode_props (c->buffer); /* BUFFER: Set general_category and combining_class */ + hb_set_unicode_props (c->buffer); /* BUFFER: Set general_category and combining_class */ hb_form_clusters (c->buffer); commit 38a83019e6a7f4aa47662fd557344f62ae001abe Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 19:40:18 2012 -0400 Minor diff --git a/src/hb-common.h b/src/hb-common.h index eefe984..562b04c 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -119,7 +119,7 @@ hb_direction_to_string (hb_direction_t direction); #define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4) #define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5) #define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4) -#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) +#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) /* Direction must be valid */ /* hb_language_t */ commit d4adade217a61007dd2da5cd9eccf889f79a019a Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 19:23:17 2012 -0400 Add assert diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4b20cb3..6960acf 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -400,6 +400,8 @@ hb_ot_shape_plan_internal (hb_ot_shape_plan_t *plan, { hb_ot_shape_planner_t planner; + assert (HB_DIRECTION_IS_VALID (props->direction)); + planner.shaper = hb_ot_shape_complex_categorize (props); hb_ot_shape_collect_features (&planner, props, user_features, num_user_features); commit fe28b997fbbeb2cfeab62ac453993ccffe3e6719 Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 19:19:26 2012 -0400 Add HB_DIRECTION_IS_VALID diff --git a/src/hb-common.h b/src/hb-common.h index 26c056b..eefe984 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -118,6 +118,7 @@ hb_direction_to_string (hb_direction_t direction); #define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6) #define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4) #define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5) +#define HB_DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4) #define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) diff --git a/test/api/test-common.c b/test/api/test-common.c index 7441d09..74b50be 100644 --- a/test/api/test-common.c +++ b/test/api/test-common.c @@ -78,6 +78,13 @@ test_types_direction (void) g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_BTT)); g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_INVALID)); + g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_LTR)); + g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_TTB)); + g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_RTL)); + g_assert (HB_DIRECTION_IS_VALID (HB_DIRECTION_BTT)); + g_assert (!HB_DIRECTION_IS_VALID (HB_DIRECTION_INVALID)); + g_assert (!HB_DIRECTION_IS_VALID ((hb_direction_t) 0x12345678)); + g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_LTR), ==, HB_DIRECTION_RTL); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_RTL), ==, HB_DIRECTION_LTR); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_TTB), ==, HB_DIRECTION_BTT); commit 5e88aa66822ba64324b4428c9ffbe06a43b4f310 Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 18:51:50 2012 -0400 Remove public enum names again As was reported to me, glib-mkenum does not understand named enums, so remove for now. diff --git a/src/hb-blob.h b/src/hb-blob.h index d47cc90..360310b 100644 --- a/src/hb-blob.h +++ b/src/hb-blob.h @@ -36,7 +36,7 @@ HB_BEGIN_DECLS -typedef enum _hb_memory_mode_t { +typedef enum { HB_MEMORY_MODE_DUPLICATE, HB_MEMORY_MODE_READONLY, HB_MEMORY_MODE_WRITABLE, diff --git a/src/hb-common.h b/src/hb-common.h index 5d9015d..26c056b 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -99,7 +99,7 @@ hb_tag_t hb_tag_from_string (const char *str, int len); /* hb_direction_t */ -typedef enum _hb_direction_t { +typedef enum { HB_DIRECTION_INVALID = 0, HB_DIRECTION_LTR = 4, HB_DIRECTION_RTL, @@ -140,7 +140,7 @@ hb_language_get_default (void); /* hb_unicode_general_category_t */ -typedef enum _hb_unicode_general_category_t +typedef enum { HB_UNICODE_GENERAL_CATEGORY_CONTROL, /* Cc */ HB_UNICODE_GENERAL_CATEGORY_FORMAT, /* Cf */ @@ -179,7 +179,7 @@ typedef enum _hb_unicode_general_category_t /* http://unicode.org/iso15924/ */ /* http://goo.gl/x9ilM */ -typedef enum _hb_script_t +typedef enum { /* Unicode-1.1 additions */ HB_SCRIPT_COMMON = HB_TAG ('Z','y','y','y'), diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 943fba1..bf7e43b 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -44,7 +44,7 @@ #define props_cache() var1.u16[1] /* glyph_props cache */ /* XXX cleanup */ -typedef enum _hb_ot_layout_glyph_class_t { +typedef enum { HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0001, HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002, HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004, commit 08569c0eaab026c7122c0dc29922cf44011c4d10 Author: Behdad Esfahbod <[email protected]> Date: Sat Apr 14 18:47:07 2012 -0400 Minor diff --git a/TODO b/TODO index fbc9b0d..b0eac7a 100644 --- a/TODO +++ b/TODO @@ -80,6 +80,8 @@ Tests to write: - Finish test-unicode.c, grep for TODO +- GObject, FreeType, etc + Optimizations: ============= commit 4bf90f648313e35d21b427a956aa1fe762bae757 Author: Behdad Esfahbod <[email protected]> Date: Thu Apr 12 17:38:23 2012 -0400 Make HB_DIRECTION_INVALID be zero This changes all the HB_DIRECTION_* enum member values, but is nicer, in preparation for making hb_segment_properties_t public. diff --git a/src/hb-common.cc b/src/hb-common.cc index 8737934..bfbba65 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -80,7 +80,7 @@ hb_direction_from_string (const char *str, int len) char c = TOLOWER (str[0]); for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++) if (c == direction_strings[i][0]) - return (hb_direction_t) i; + return (hb_direction_t) (HB_DIRECTION_LTR + i); return HB_DIRECTION_INVALID; } @@ -88,8 +88,9 @@ hb_direction_from_string (const char *str, int len) const char * hb_direction_to_string (hb_direction_t direction) { - if (likely ((unsigned int) direction < ARRAY_LENGTH (direction_strings))) - return direction_strings[direction]; + if (likely ((unsigned int) (direction - HB_DIRECTION_LTR) + < ARRAY_LENGTH (direction_strings))) + return direction_strings[direction - HB_DIRECTION_LTR]; return "invalid"; } diff --git a/src/hb-common.h b/src/hb-common.h index dd86334..5d9015d 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -93,31 +93,31 @@ typedef uint32_t hb_tag_t; #define HB_TAG_NONE HB_TAG(0,0,0,0) -/* len=-1 means s is NUL-terminated */ -hb_tag_t hb_tag_from_string (const char *s, int len); +/* len=-1 means str is NUL-terminated */ +hb_tag_t hb_tag_from_string (const char *str, int len); /* hb_direction_t */ typedef enum _hb_direction_t { - HB_DIRECTION_INVALID = -1, - HB_DIRECTION_LTR = 0, + HB_DIRECTION_INVALID = 0, + HB_DIRECTION_LTR = 4, HB_DIRECTION_RTL, HB_DIRECTION_TTB, HB_DIRECTION_BTT } hb_direction_t; -/* len=-1 means s is NUL-terminated */ +/* len=-1 means str is NUL-terminated */ hb_direction_t hb_direction_from_string (const char *str, int len); const char * hb_direction_to_string (hb_direction_t direction); -#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 0) -#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 2) -#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 0) -#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 1) +#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4) +#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6) +#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4) +#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5) #define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1)) @@ -125,7 +125,7 @@ hb_direction_to_string (hb_direction_t direction); typedef struct _hb_language_t *hb_language_t; -/* len=-1 means s is NUL-terminated */ +/* len=-1 means str is NUL-terminated */ hb_language_t hb_language_from_string (const char *str, int len); diff --git a/test/api/test-common.c b/test/api/test-common.c index e00e601..7441d09 100644 --- a/test/api/test-common.c +++ b/test/api/test-common.c @@ -51,33 +51,38 @@ test_types_int (void) static void test_types_direction (void) { - g_assert_cmpint ((signed) HB_DIRECTION_INVALID, ==, -1); - g_assert_cmpint (HB_DIRECTION_LTR, ==, 0); + g_assert_cmpint ((signed) HB_DIRECTION_INVALID, ==, 0); + g_assert_cmpint (HB_DIRECTION_LTR, !=, 0); g_assert (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_LTR)); g_assert (HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_RTL)); g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_TTB)); g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_BTT)); + g_assert (!HB_DIRECTION_IS_HORIZONTAL (HB_DIRECTION_INVALID)); g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_LTR)); g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_RTL)); g_assert (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_TTB)); g_assert (HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_BTT)); + g_assert (!HB_DIRECTION_IS_VERTICAL (HB_DIRECTION_INVALID)); g_assert (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_LTR)); g_assert (HB_DIRECTION_IS_FORWARD (HB_DIRECTION_TTB)); g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_RTL)); g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_BTT)); + g_assert (!HB_DIRECTION_IS_FORWARD (HB_DIRECTION_INVALID)); g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_LTR)); g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_TTB)); g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_RTL)); g_assert (HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_BTT)); + g_assert (!HB_DIRECTION_IS_BACKWARD (HB_DIRECTION_INVALID)); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_LTR), ==, HB_DIRECTION_RTL); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_RTL), ==, HB_DIRECTION_LTR); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_TTB), ==, HB_DIRECTION_BTT); g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_BTT), ==, HB_DIRECTION_TTB); + //g_assert_cmpint (HB_DIRECTION_REVERSE (HB_DIRECTION_INVALID), ==, HB_DIRECTION_INVALID); g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string (NULL, -1)); g_assert_cmpint (HB_DIRECTION_INVALID, ==, hb_direction_from_string ("", -1)); commit d01402da9c756f90a84bfb1f964fd56caf2b35c3 Author: Behdad Esfahbod <[email protected]> Date: Thu Apr 12 17:38:02 2012 -0400 Minor diff --git a/TODO b/TODO index a1ee9a8..fbc9b0d 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,9 @@ General fixes: ============= -- Fix TT 'kern' on/off and GPOS interaction (move kerning before GPOS) +- In hb_shape(), assert if direction is INVALID. + +- Fix TT 'kern' on/off and GPOS interaction (move kerning before GPOS). - Do proper rounding when scaling from font space? May be a non-issue. @@ -31,6 +33,7 @@ API issues to fix before 1.0: API additions ============= +- Buffer (de)serialize API ala hb-shape? - Move feature parsing from util into the library - Add hb-cairo glue @@ -65,6 +68,7 @@ hb-view / hb-shape enhancements: - Add --width, --height, --auto-size, --align, etc? - Add XML and JSON formats to hb-shape +- --features="init=medi=isol=fina=0" Tests to write: _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
