summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-08-10 23:35:05 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-11-02 14:40:39 -0500
commit49f261df2aa753e8b09e97f7835e6a827f92970a (patch)
treeffac355a61039a16b89904663b838323ea2ae361 /src
parenteb27ec0cef0d92740875ab5035b53acc639e5fae (diff)
[HB] Add hb-glib
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/hb-glib.c56
-rw-r--r--src/hb-glib.h41
-rw-r--r--src/hb-unicode-private.h2
-rw-r--r--src/hb-unicode.c10
-rw-r--r--src/hb-unicode.h6
6 files changed, 109 insertions, 10 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f4015bd1..6c41d9ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-## Process this file with automake to produce Makefile.in
+# Process this file with automake to produce Makefile.in
NULL =
@@ -13,6 +13,8 @@ HBSOURCES = \
hb-buffer-private.h \
hb-font.cc \
hb-font-private.h \
+ hb-glib.h \
+ hb-glib.c \
hb-private.h \
hb-unicode.c \
hb-unicode.h \
diff --git a/src/hb-glib.c b/src/hb-glib.c
new file mode 100644
index 00000000..3e4b4505
--- /dev/null
+++ b/src/hb-glib.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#include "hb-private.h"
+
+#include "hb-glib.h"
+
+#include "hb-unicode-private.h"
+
+static hb_unicode_funcs_t *glib_ufuncs;
+
+static hb_codepoint_t hb_glib_get_mirroring_nil (hb_codepoint_t unicode) { g_unichar_get_mirror_char (unicode, &unicode); return unicode; }
+static hb_category_t hb_glib_get_general_category_nil (hb_codepoint_t unicode) { return g_unichar_type (unicode); }
+static hb_script_t hb_glib_get_script_nil (hb_codepoint_t unicode) { return g_unichar_get_script (unicode); }
+static unsigned int hb_glib_get_combining_class_nil (hb_codepoint_t unicode) { return g_unichar_combining_class (unicode); }
+static unsigned int hb_glib_get_eastasian_width_nil (hb_codepoint_t unicode) { return g_unichar_iswide (unicode); }
+
+
+hb_unicode_funcs_t *
+hb_glib_unicode_funcs_create (void)
+{
+ if (HB_UNLIKELY (!glib_ufuncs)) {
+ glib_ufuncs = hb_unicode_funcs_create ();
+
+ hb_unicode_funcs_set_mirroring_func (glib_ufuncs, hb_glib_get_mirroring_nil);
+ hb_unicode_funcs_set_general_category_func (glib_ufuncs, hb_glib_get_general_category_nil);
+ hb_unicode_funcs_set_script_func (glib_ufuncs, hb_glib_get_script_nil);
+ hb_unicode_funcs_set_combining_class_func (glib_ufuncs, hb_glib_get_combining_class_nil);
+ hb_unicode_funcs_set_eastasian_width_func (glib_ufuncs, hb_glib_get_eastasian_width_nil);
+ }
+
+ return hb_unicode_funcs_reference (glib_ufuncs);
+}
diff --git a/src/hb-glib.h b/src/hb-glib.h
new file mode 100644
index 00000000..6a7f5508
--- /dev/null
+++ b/src/hb-glib.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_GLIB_H
+#define HB_GLIB_H
+
+#include "hb-common.h"
+
+#include "hb-unicode.h"
+
+HB_BEGIN_DECLS
+
+hb_unicode_funcs_t *
+hb_glib_unicode_funcs_create (void);
+
+HB_END_DECLS
+
+#endif /* HB_GLIB_H */
diff --git a/src/hb-unicode-private.h b/src/hb-unicode-private.h
index 5f62d395..88802455 100644
--- a/src/hb-unicode-private.h
+++ b/src/hb-unicode-private.h
@@ -44,7 +44,7 @@ struct _hb_unicode_funcs_t {
hb_unicode_get_general_category_func_t get_general_category;
hb_unicode_get_combining_class_func_t get_combining_class;
- hb_unicode_get_mirroring_char_func_t get_mirroring_char;
+ hb_unicode_get_mirroring_func_t get_mirroring;
hb_unicode_get_script_func_t get_script;
hb_unicode_get_eastasian_width_func_t get_eastasian_width;
};
diff --git a/src/hb-unicode.c b/src/hb-unicode.c
index 3da5dc4e..01b54f58 100644
--- a/src/hb-unicode.c
+++ b/src/hb-unicode.c
@@ -32,7 +32,7 @@
* hb_unicode_funcs_t
*/
-static hb_codepoint_t hb_unicode_get_mirroring_char_nil (hb_codepoint_t unicode) { return unicode; }
+static hb_codepoint_t hb_unicode_get_mirroring_nil (hb_codepoint_t unicode) { return unicode; }
static hb_category_t hb_unicode_get_general_category_nil (hb_codepoint_t unicode) { return HB_CATEGORY_OTHER_LETTER; }
static hb_script_t hb_unicode_get_script_nil (hb_codepoint_t unicode) { return HB_SCRIPT_UNKNOWN; }
static unsigned int hb_unicode_get_combining_class_nil (hb_codepoint_t unicode) { return 0; }
@@ -45,7 +45,7 @@ hb_unicode_funcs_t _hb_unicode_funcs_nil = {
hb_unicode_get_general_category_nil,
hb_unicode_get_combining_class_nil,
- hb_unicode_get_mirroring_char_nil,
+ hb_unicode_get_mirroring_nil,
hb_unicode_get_script_nil,
hb_unicode_get_eastasian_width_nil
};
@@ -110,13 +110,13 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
void
-hb_unicode_funcs_set_mirroring_char_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_mirroring_char_func_t mirroring_char_func)
+hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
+ hb_unicode_get_mirroring_func_t mirroring_func)
{
if (ufuncs->immutable)
return;
- ufuncs->get_mirroring_char = mirroring_char_func ? mirroring_char_func : hb_unicode_get_mirroring_char_nil;
+ ufuncs->get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mirroring_nil;
}
void
diff --git a/src/hb-unicode.h b/src/hb-unicode.h
index 61829014..59f198db 100644
--- a/src/hb-unicode.h
+++ b/src/hb-unicode.h
@@ -186,7 +186,7 @@ hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs);
/* funcs */
-typedef hb_codepoint_t (*hb_unicode_get_mirroring_char_func_t) (hb_codepoint_t unicode);
+typedef hb_codepoint_t (*hb_unicode_get_mirroring_func_t) (hb_codepoint_t unicode);
typedef hb_category_t (*hb_unicode_get_general_category_func_t) (hb_codepoint_t unicode);
typedef hb_script_t (*hb_unicode_get_script_func_t) (hb_codepoint_t unicode);
typedef unsigned int (*hb_unicode_get_combining_class_func_t) (hb_codepoint_t unicode);
@@ -194,8 +194,8 @@ typedef unsigned int (*hb_unicode_get_eastasian_width_func_t) (hb_codepoint_t un
void
-hb_unicode_funcs_set_mirroring_char_func (hb_unicode_funcs_t *ufuncs,
- hb_unicode_get_mirroring_char_func_t mirroring_char_func);
+hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
+ hb_unicode_get_mirroring_func_t mirroring_func);
void
hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,