summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2009-10-27 16:08:38 -0700
committerEvan Martin <evanm@google.com>2009-10-27 16:08:38 -0700
commit620f1d90a7c7207492ff3eabf0f6185e8b78f9dc (patch)
treebde90d908d8f29feaf7af75795c0de7f50486e7d /contrib
parent4db7e36f46b735f8801d393b356f9c8ed41c409c (diff)
Implement HB_GetMirroredChar under contrib/
Diffstat (limited to 'contrib')
-rw-r--r--contrib/harfbuzz-unicode.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/contrib/harfbuzz-unicode.c b/contrib/harfbuzz-unicode.c
index 9b3c43e..51dd4ea 100644
--- a/contrib/harfbuzz-unicode.c
+++ b/contrib/harfbuzz-unicode.c
@@ -6,8 +6,9 @@
#include <harfbuzz-shaper.h>
#include "harfbuzz-unicode.h"
-#include "tables/script-properties.h"
#include "tables/grapheme-break-properties.h"
+#include "tables/mirroring-properties.h"
+#include "tables/script-properties.h"
uint32_t
utf16_to_code_point(const uint16_t *chars, size_t len, ssize_t *iter) {
@@ -234,10 +235,30 @@ HB_GetGraphemeAndLineBreakClass(HB_UChar32 ch, HB_GraphemeClass *gclass, HB_Line
*breakclass = HB_GetLineBreakClass(ch);
}
+static int
+mirroring_property_cmp(const void *vkey, const void *vcandidate) {
+ const uint32_t key = (uint32_t) (intptr_t) vkey;
+ const struct mirroring_property *candidate = vcandidate;
+
+ if (key < candidate->a) {
+ return -1;
+ } else if (key > candidate->a) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
HB_UChar16
HB_GetMirroredChar(HB_UChar16 ch) {
- abort();
- return 0;
+ const void *mprop = bsearch((void *) (intptr_t) ch, mirroring_properties,
+ mirroring_properties_count,
+ sizeof(struct mirroring_property),
+ mirroring_property_cmp);
+ if (!mprop)
+ return ch;
+
+ return ((const struct mirroring_property *) mprop)->b;
}
void *