[pango] [HB] Add hb-glib



commit 5586ef604f0212f8edebbbffbe7596d3bdca3474
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Aug 10 23:35:05 2009 -0400

    [HB] Add hb-glib

 pango/opentype/Makefile.am          |    4 ++-
 pango/opentype/hb-glib.c            |   56 +++++++++++++++++++++++++++++++++++
 pango/opentype/hb-glib.h            |   41 +++++++++++++++++++++++++
 pango/opentype/hb-unicode-private.h |    2 +-
 pango/opentype/hb-unicode.c         |   10 +++---
 pango/opentype/hb-unicode.h         |    6 ++--
 6 files changed, 109 insertions(+), 10 deletions(-)
---
diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am
index f4015bd..6c41d9e 100644
--- a/pango/opentype/Makefile.am
+++ b/pango/opentype/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/pango/opentype/hb-glib.c b/pango/opentype/hb-glib.c
new file mode 100644
index 0000000..3e4b450
--- /dev/null
+++ b/pango/opentype/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/pango/opentype/hb-glib.h b/pango/opentype/hb-glib.h
new file mode 100644
index 0000000..6a7f550
--- /dev/null
+++ b/pango/opentype/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/pango/opentype/hb-unicode-private.h b/pango/opentype/hb-unicode-private.h
index 5f62d39..8880245 100644
--- a/pango/opentype/hb-unicode-private.h
+++ b/pango/opentype/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/pango/opentype/hb-unicode.c b/pango/opentype/hb-unicode.c
index 3da5dc4..01b54f5 100644
--- a/pango/opentype/hb-unicode.c
+++ b/pango/opentype/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/pango/opentype/hb-unicode.h b/pango/opentype/hb-unicode.h
index 6182901..59f198d 100644
--- a/pango/opentype/hb-unicode.h
+++ b/pango/opentype/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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]