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 @@
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 @@
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";
}