[HB] Add hb-glib

This commit is contained in:
Behdad Esfahbod 2009-08-10 23:35:05 -04:00
parent eb27ec0cef
commit 49f261df2a
6 changed files with 109 additions and 10 deletions

View File

@ -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 \

56
src/hb-glib.c Normal file
View File

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

41
src/hb-glib.h Normal file
View File

@ -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 */

View File

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

View File

@ -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

View File

@ -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,