2011-08-14 15:17:16 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Google, Inc.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping 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.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb.hh"
|
2011-08-14 15:17:16 +02:00
|
|
|
|
2019-06-18 07:41:49 +02:00
|
|
|
#ifdef HAVE_GOBJECT
|
|
|
|
|
2018-10-27 13:40:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:hb-gobject
|
|
|
|
* @title: hb-gobject
|
2019-05-20 18:36:55 +02:00
|
|
|
* @short_description: GObject integration support
|
2018-10-27 13:40:43 +02:00
|
|
|
* @include: hb-gobject.h
|
|
|
|
*
|
2019-05-20 18:36:55 +02:00
|
|
|
* Support for using HarfBuzz with the GObject library to provide
|
2018-10-27 13:40:43 +02:00
|
|
|
* type data.
|
2019-05-20 18:36:55 +02:00
|
|
|
*
|
|
|
|
* The types and functions listed here are solely a linkage between
|
|
|
|
* HarfBuzz's public data types and the GTypes used by the GObject framework.
|
|
|
|
* HarfBuzz uses GObject introspection to generate its Python bindings
|
|
|
|
* (and potentially other language bindings); client programs should never need
|
|
|
|
* to access the GObject-integration mechanics.
|
|
|
|
*
|
|
|
|
* For client programs using the GNOME and GTK software stack, please see the
|
|
|
|
* GLib and FreeType integration pages.
|
2018-10-27 13:40:43 +02:00
|
|
|
**/
|
|
|
|
|
|
|
|
|
2011-08-14 15:17:16 +02:00
|
|
|
/* g++ didn't like older gtype.h gcc-only code path. */
|
|
|
|
#include <glib.h>
|
|
|
|
#if !GLIB_CHECK_VERSION(2,29,16)
|
|
|
|
#undef __GNUC__
|
|
|
|
#undef __GNUC_MINOR__
|
|
|
|
#define __GNUC__ 2
|
|
|
|
#define __GNUC_MINOR__ 6
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "hb-gobject.h"
|
|
|
|
|
2013-08-27 02:56:58 +02:00
|
|
|
#define HB_DEFINE_BOXED_TYPE(name,copy_func,free_func) \
|
2011-08-14 15:17:16 +02:00
|
|
|
GType \
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_gobject_##name##_get_type () \
|
2011-08-14 15:17:16 +02:00
|
|
|
{ \
|
2013-08-27 02:56:58 +02:00
|
|
|
static gsize type_id = 0; \
|
|
|
|
if (g_once_init_enter (&type_id)) { \
|
|
|
|
GType id = g_boxed_type_register_static (g_intern_static_string ("hb_" #name "_t"), \
|
|
|
|
(GBoxedCopyFunc) copy_func, \
|
|
|
|
(GBoxedFreeFunc) free_func); \
|
|
|
|
g_once_init_leave (&type_id, id); \
|
2011-08-14 15:17:16 +02:00
|
|
|
} \
|
2013-08-27 02:56:58 +02:00
|
|
|
return type_id; \
|
2011-08-14 15:17:16 +02:00
|
|
|
}
|
|
|
|
|
2013-08-27 02:56:58 +02:00
|
|
|
#define HB_DEFINE_OBJECT_TYPE(name) \
|
2019-01-04 20:40:39 +01:00
|
|
|
HB_DEFINE_BOXED_TYPE (name, hb_##name##_reference, hb_##name##_destroy)
|
2011-08-14 15:17:16 +02:00
|
|
|
|
2015-05-20 02:20:58 +02:00
|
|
|
#define HB_DEFINE_VALUE_TYPE(name) \
|
|
|
|
static hb_##name##_t *_hb_##name##_reference (const hb_##name##_t *l) \
|
|
|
|
{ \
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_##name##_t *c = (hb_##name##_t *) hb_calloc (1, sizeof (hb_##name##_t)); \
|
2017-10-15 12:11:08 +02:00
|
|
|
if (unlikely (!c)) return nullptr; \
|
2015-05-20 02:20:58 +02:00
|
|
|
*c = *l; \
|
|
|
|
return c; \
|
|
|
|
} \
|
2021-07-08 18:58:50 +02:00
|
|
|
static void _hb_##name##_destroy (hb_##name##_t *l) { hb_free (l); } \
|
2019-01-04 20:40:39 +01:00
|
|
|
HB_DEFINE_BOXED_TYPE (name, _hb_##name##_reference, _hb_##name##_destroy)
|
2015-05-20 02:20:58 +02:00
|
|
|
|
2013-08-27 02:56:58 +02:00
|
|
|
HB_DEFINE_OBJECT_TYPE (buffer)
|
|
|
|
HB_DEFINE_OBJECT_TYPE (blob)
|
2022-02-12 00:43:11 +01:00
|
|
|
HB_DEFINE_OBJECT_TYPE (draw_funcs)
|
2013-08-27 02:56:58 +02:00
|
|
|
HB_DEFINE_OBJECT_TYPE (face)
|
|
|
|
HB_DEFINE_OBJECT_TYPE (font)
|
|
|
|
HB_DEFINE_OBJECT_TYPE (font_funcs)
|
|
|
|
HB_DEFINE_OBJECT_TYPE (set)
|
2018-08-01 07:28:28 +02:00
|
|
|
HB_DEFINE_OBJECT_TYPE (map)
|
2013-08-27 02:56:58 +02:00
|
|
|
HB_DEFINE_OBJECT_TYPE (shape_plan)
|
|
|
|
HB_DEFINE_OBJECT_TYPE (unicode_funcs)
|
2015-05-20 02:20:58 +02:00
|
|
|
HB_DEFINE_VALUE_TYPE (feature)
|
|
|
|
HB_DEFINE_VALUE_TYPE (glyph_info)
|
|
|
|
HB_DEFINE_VALUE_TYPE (glyph_position)
|
|
|
|
HB_DEFINE_VALUE_TYPE (segment_properties)
|
|
|
|
HB_DEFINE_VALUE_TYPE (user_data_key)
|
2016-10-23 14:39:43 +02:00
|
|
|
|
|
|
|
HB_DEFINE_VALUE_TYPE (ot_math_glyph_variant)
|
|
|
|
HB_DEFINE_VALUE_TYPE (ot_math_glyph_part)
|
2019-06-18 07:41:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|