2009-08-11 02:05:16 +02:00
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
* Copyright © 2009 Red Hat, Inc.
|
2012-08-02 00:07:42 +02:00
|
|
|
* Copyright © 2011 Codethink Limited
|
|
|
|
* Copyright © 2010,2011,2012 Google, Inc.
|
2009-08-11 02:05:16 +02:00
|
|
|
*
|
2010-04-22 06:11:43 +02:00
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
2009-08-11 02:05:16 +02:00
|
|
|
*
|
|
|
|
* 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
|
2011-04-20 06:19:20 +02:00
|
|
|
* Codethink Author(s): Ryan Lortie
|
2011-04-20 08:00:47 +02:00
|
|
|
* Google Author(s): Behdad Esfahbod
|
2009-08-11 02:05:16 +02:00
|
|
|
*/
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb.hh"
|
2009-08-11 02:05:16 +02:00
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-unicode.hh"
|
2009-08-11 02:05:16 +02:00
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2018-10-27 13:07:33 +02:00
|
|
|
/**
|
|
|
|
* SECTION: hb-unicode
|
2018-10-27 13:50:38 +02:00
|
|
|
* @title: hb-unicode
|
2018-10-27 13:07:33 +02:00
|
|
|
* @short_description: Unicode character property access
|
|
|
|
* @include: hb.h
|
|
|
|
*
|
|
|
|
* Unicode functions are used to access Unicode character properties.
|
2019-04-22 20:16:48 +02:00
|
|
|
* With these functions, client programs can query various properties from
|
|
|
|
* the Unicode Character Database for any code point, such as General
|
|
|
|
* Category (gc), Script (sc), Canonical Combining Class (ccc), etc.
|
2018-10-27 13:07:33 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Client programs can optionally pass in their own Unicode functions
|
|
|
|
* that implement the same queries. The set of functions available is
|
|
|
|
* defined by the virtual methods in #hb_unicode_funcs_t.
|
|
|
|
*
|
|
|
|
* HarfBuzz provides built-in default functions for each method in
|
|
|
|
* #hb_unicode_funcs_t.
|
2018-10-27 13:07:33 +02:00
|
|
|
**/
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2009-08-11 02:05:16 +02:00
|
|
|
/*
|
|
|
|
* hb_unicode_funcs_t
|
|
|
|
*/
|
|
|
|
|
2012-08-01 22:23:44 +02:00
|
|
|
static hb_unicode_combining_class_t
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_combining_class_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-07-08 05:19:27 +02:00
|
|
|
{
|
2012-08-01 22:23:44 +02:00
|
|
|
return HB_UNICODE_COMBINING_CLASS_NOT_REORDERED;
|
2011-04-20 06:19:20 +02:00
|
|
|
}
|
|
|
|
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2011-07-08 05:19:27 +02:00
|
|
|
static unsigned int
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_eastasian_width_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-07-08 05:19:27 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2011-07-08 05:19:27 +02:00
|
|
|
|
|
|
|
static hb_unicode_general_category_t
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_general_category_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-07-08 05:19:27 +02:00
|
|
|
{
|
|
|
|
return HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
static hb_codepoint_t
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_mirroring_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
2018-04-23 16:33:57 +02:00
|
|
|
hb_codepoint_t unicode,
|
2011-07-08 05:47:19 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2011-07-08 05:19:27 +02:00
|
|
|
{
|
|
|
|
return unicode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static hb_script_t
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_script_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-07-08 05:19:27 +02:00
|
|
|
{
|
|
|
|
return HB_SCRIPT_UNKNOWN;
|
|
|
|
}
|
2011-04-20 06:19:20 +02:00
|
|
|
|
2011-07-08 05:47:19 +02:00
|
|
|
static hb_bool_t
|
2011-07-21 03:51:37 +02:00
|
|
|
hb_unicode_compose_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_codepoint_t a HB_UNUSED,
|
|
|
|
hb_codepoint_t b HB_UNUSED,
|
|
|
|
hb_codepoint_t *ab HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-07-08 05:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static hb_bool_t
|
2011-07-21 03:51:37 +02:00
|
|
|
hb_unicode_decompose_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_codepoint_t ab HB_UNUSED,
|
|
|
|
hb_codepoint_t *a HB_UNUSED,
|
|
|
|
hb_codepoint_t *b HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-07-08 05:47:19 +02:00
|
|
|
}
|
|
|
|
|
2009-08-11 05:05:05 +02:00
|
|
|
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2012-08-01 03:36:16 +02:00
|
|
|
static unsigned int
|
|
|
|
hb_unicode_decompose_compatibility_nil (hb_unicode_funcs_t *ufuncs HB_UNUSED,
|
|
|
|
hb_codepoint_t u HB_UNUSED,
|
|
|
|
hb_codepoint_t *decomposed HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2012-08-01 03:36:16 +02:00
|
|
|
|
2019-07-17 18:35:56 +02:00
|
|
|
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HAVE_GLIB)
|
|
|
|
#include "hb-glib.h"
|
|
|
|
#endif
|
|
|
|
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HAVE_ICU) && defined(HAVE_ICU_BUILTIN)
|
|
|
|
#include "hb-icu.h"
|
|
|
|
#endif
|
2019-07-08 09:19:49 +02:00
|
|
|
|
2019-04-22 20:16:48 +02:00
|
|
|
/**
|
2020-09-26 10:22:39 +02:00
|
|
|
* hb_unicode_funcs_get_default:
|
2019-04-22 20:16:48 +02:00
|
|
|
*
|
2020-09-26 10:22:39 +02:00
|
|
|
* Fetches a pointer to the default Unicode-functions structure that is used
|
|
|
|
* when no functions are explicitly set on #hb_buffer_t.
|
2019-04-22 20:16:48 +02:00
|
|
|
*
|
2020-09-26 10:22:39 +02:00
|
|
|
* Return value: (transfer none): a pointer to the #hb_unicode_funcs_t Unicode-functions structure
|
2019-04-22 20:16:48 +02:00
|
|
|
*
|
2020-09-26 10:22:39 +02:00
|
|
|
* Since: 0.9.2
|
2019-04-22 20:16:48 +02:00
|
|
|
**/
|
2011-04-27 15:24:37 +02:00
|
|
|
hb_unicode_funcs_t *
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_unicode_funcs_get_default ()
|
2011-04-27 15:24:37 +02:00
|
|
|
{
|
2019-05-22 22:21:21 +02:00
|
|
|
#if !defined(HB_NO_UNICODE_FUNCS) && !defined(HB_NO_UCD)
|
|
|
|
return hb_ucd_get_unicode_funcs ();
|
2019-04-10 21:38:15 +02:00
|
|
|
#elif !defined(HB_NO_UNICODE_FUNCS) && defined(HAVE_GLIB)
|
2018-10-30 06:46:19 +01:00
|
|
|
return hb_glib_get_unicode_funcs ();
|
2019-04-10 21:38:15 +02:00
|
|
|
#elif !defined(HB_NO_UNICODE_FUNCS) && defined(HAVE_ICU) && defined(HAVE_ICU_BUILTIN)
|
2018-10-30 06:46:19 +01:00
|
|
|
return hb_icu_get_unicode_funcs ();
|
2012-08-12 03:26:25 +02:00
|
|
|
#else
|
|
|
|
#define HB_UNICODE_FUNCS_NIL 1
|
2018-10-30 06:46:19 +01:00
|
|
|
return hb_unicode_funcs_get_empty ();
|
2012-08-12 03:26:25 +02:00
|
|
|
#endif
|
2011-04-27 15:24:37 +02:00
|
|
|
}
|
|
|
|
|
2012-08-12 03:26:25 +02:00
|
|
|
#if !defined(HB_NO_UNICODE_FUNCS) && defined(HB_UNICODE_FUNCS_NIL)
|
2015-04-08 22:25:04 +02:00
|
|
|
#error "Could not find any Unicode functions implementation, you have to provide your own"
|
2019-05-22 22:21:21 +02:00
|
|
|
#error "Consider building hb-ucd.cc. If you absolutely want to build without any, check the code."
|
2014-03-19 20:00:17 +01:00
|
|
|
#endif
|
2012-08-12 03:26:25 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
2013-09-12 23:14:33 +02:00
|
|
|
* hb_unicode_funcs_create: (Xconstructor)
|
2019-04-22 20:16:48 +02:00
|
|
|
* @parent: (nullable): Parent Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Creates a new #hb_unicode_funcs_t structure of Unicode functions.
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Return value: (transfer full): The Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_unicode_funcs_t *
|
2011-04-20 06:19:20 +02:00
|
|
|
hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
|
2009-08-11 02:05:16 +02:00
|
|
|
{
|
|
|
|
hb_unicode_funcs_t *ufuncs;
|
|
|
|
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!(ufuncs = hb_object_create<hb_unicode_funcs_t> ()))
|
2012-06-05 18:31:51 +02:00
|
|
|
return hb_unicode_funcs_get_empty ();
|
2009-08-11 02:05:16 +02:00
|
|
|
|
2011-05-02 21:59:57 +02:00
|
|
|
if (!parent)
|
2012-06-05 18:31:51 +02:00
|
|
|
parent = hb_unicode_funcs_get_empty ();
|
2011-04-20 08:00:47 +02:00
|
|
|
|
2011-05-02 21:59:57 +02:00
|
|
|
hb_unicode_funcs_make_immutable (parent);
|
|
|
|
ufuncs->parent = hb_unicode_funcs_reference (parent);
|
2011-04-20 08:00:47 +02:00
|
|
|
|
2011-07-08 05:47:19 +02:00
|
|
|
ufuncs->func = parent->func;
|
2011-05-02 21:59:57 +02:00
|
|
|
|
|
|
|
/* We can safely copy user_data from parent since we hold a reference
|
|
|
|
* onto it and it's immutable. We should not copy the destroy notifiers
|
|
|
|
* though. */
|
|
|
|
ufuncs->user_data = parent->user_data;
|
2009-08-11 05:05:05 +02:00
|
|
|
|
2009-08-11 02:05:16 +02:00
|
|
|
return ufuncs;
|
|
|
|
}
|
|
|
|
|
2012-06-05 18:31:51 +02:00
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) =
|
|
|
|
{
|
2012-06-06 00:14:03 +02:00
|
|
|
HB_OBJECT_HEADER_STATIC,
|
|
|
|
|
2017-10-15 12:11:08 +02:00
|
|
|
nullptr, /* parent */
|
2012-06-06 00:14:03 +02:00
|
|
|
{
|
2012-06-05 18:31:51 +02:00
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil,
|
2012-06-06 00:14:03 +02:00
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
2012-06-05 18:31:51 +02:00
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT
|
2012-06-06 00:14:03 +02:00
|
|
|
}
|
|
|
|
};
|
2012-06-05 18:31:51 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_get_empty:
|
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the singleton empty Unicode-functions structure.
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Return value: (transfer full): The empty Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-06-06 00:14:03 +02:00
|
|
|
hb_unicode_funcs_t *
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_unicode_funcs_get_empty ()
|
2012-06-06 00:14:03 +02:00
|
|
|
{
|
2020-04-20 11:42:45 +02:00
|
|
|
return const_cast<hb_unicode_funcs_t *> (&Null (hb_unicode_funcs_t));
|
2011-05-12 00:14:44 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_reference: (skip)
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Increases the reference count on a Unicode-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Return value: (transfer full): The Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_unicode_funcs_t *
|
|
|
|
hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
|
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
return hb_object_reference (ufuncs);
|
2009-08-11 02:05:16 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_destroy: (skip)
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Decreases the reference count on a Unicode-functions structure. When
|
|
|
|
* the reference count reaches zero, the Unicode-functions structure is
|
|
|
|
* destroyed, freeing all memory.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
void
|
|
|
|
hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
|
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!hb_object_destroy (ufuncs)) return;
|
2009-08-11 02:05:16 +02:00
|
|
|
|
2011-07-08 05:19:27 +02:00
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(name) \
|
2011-07-08 05:14:42 +02:00
|
|
|
if (ufuncs->destroy.name) ufuncs->destroy.name (ufuncs->user_data.name);
|
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT
|
2011-04-20 08:00:47 +02:00
|
|
|
|
2011-05-02 21:59:57 +02:00
|
|
|
hb_unicode_funcs_destroy (ufuncs->parent);
|
2011-04-20 06:19:20 +02:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (ufuncs);
|
2009-08-11 02:05:16 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_set_user_data: (skip)
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
|
|
|
* @key: The user-data key
|
|
|
|
* @data: A pointer to the user data
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
2019-04-22 20:16:48 +02:00
|
|
|
* @replace: Whether to replace an existing data with the same key
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Attaches a user-data key/data pair to the specified Unicode-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2020-12-24 20:28:37 +01:00
|
|
|
* Return value: %true if success, %false otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_unicode_funcs_set_user_data (hb_unicode_funcs_t *ufuncs,
|
2019-10-01 12:19:55 +02:00
|
|
|
hb_user_data_key_t *key,
|
|
|
|
void * data,
|
|
|
|
hb_destroy_func_t destroy,
|
2011-08-09 00:43:24 +02:00
|
|
|
hb_bool_t replace)
|
2011-04-28 03:46:01 +02:00
|
|
|
{
|
2011-08-09 00:43:24 +02:00
|
|
|
return hb_object_set_user_data (ufuncs, key, data, destroy, replace);
|
2011-04-28 03:46:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_get_user_data: (skip)
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
|
|
|
* @key: The user-data key to query
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the user-data associated with the specified key,
|
|
|
|
* attached to the specified Unicode-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Return value: (transfer none): A pointer to the user data
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
void *
|
|
|
|
hb_unicode_funcs_get_user_data (hb_unicode_funcs_t *ufuncs,
|
2019-10-01 12:19:55 +02:00
|
|
|
hb_user_data_key_t *key)
|
2011-04-28 03:46:01 +02:00
|
|
|
{
|
|
|
|
return hb_object_get_user_data (ufuncs, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_make_immutable:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Makes the specified Unicode-functions structure
|
|
|
|
* immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 05:25:28 +02:00
|
|
|
void
|
|
|
|
hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (ufuncs))
|
2018-09-26 21:03:07 +02:00
|
|
|
return;
|
2009-08-11 05:25:28 +02:00
|
|
|
|
2018-11-03 19:51:38 +01:00
|
|
|
hb_object_make_immutable (ufuncs);
|
2009-08-11 05:25:28 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_is_immutable:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Tests whether the specified Unicode-functions structure
|
|
|
|
* is immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2020-12-30 22:08:40 +01:00
|
|
|
* Return value: %true if @ufuncs is immutable, %false otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-04 23:01:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
return hb_object_is_immutable (ufuncs);
|
2010-10-04 23:01:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_funcs_get_parent:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the parent of the Unicode-functions structure
|
|
|
|
* @ufuncs.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Return value: The parent Unicode-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-20 08:00:47 +02:00
|
|
|
hb_unicode_funcs_t *
|
|
|
|
hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs)
|
|
|
|
{
|
2012-06-05 18:31:51 +02:00
|
|
|
return ufuncs->parent ? ufuncs->parent : hb_unicode_funcs_get_empty ();
|
2011-04-20 08:00:47 +02:00
|
|
|
}
|
|
|
|
|
2009-08-11 04:58:56 +02:00
|
|
|
|
2011-07-08 05:19:27 +02:00
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(name) \
|
2011-07-08 05:14:42 +02:00
|
|
|
\
|
|
|
|
void \
|
|
|
|
hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_##name##_func_t func, \
|
2011-07-08 05:14:42 +02:00
|
|
|
void *user_data, \
|
|
|
|
hb_destroy_func_t destroy) \
|
|
|
|
{ \
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (ufuncs)) \
|
2011-07-08 05:14:42 +02:00
|
|
|
return; \
|
|
|
|
\
|
|
|
|
if (ufuncs->destroy.name) \
|
|
|
|
ufuncs->destroy.name (ufuncs->user_data.name); \
|
|
|
|
\
|
|
|
|
if (func) { \
|
2011-07-08 05:47:19 +02:00
|
|
|
ufuncs->func.name = func; \
|
2011-07-08 05:14:42 +02:00
|
|
|
ufuncs->user_data.name = user_data; \
|
|
|
|
ufuncs->destroy.name = destroy; \
|
|
|
|
} else { \
|
2011-07-08 05:47:19 +02:00
|
|
|
ufuncs->func.name = ufuncs->parent->func.name; \
|
2011-07-08 05:14:42 +02:00
|
|
|
ufuncs->user_data.name = ufuncs->parent->user_data.name; \
|
2017-10-15 12:11:08 +02:00
|
|
|
ufuncs->destroy.name = nullptr; \
|
2011-07-08 05:14:42 +02:00
|
|
|
} \
|
2011-07-08 05:19:27 +02:00
|
|
|
}
|
|
|
|
|
2012-08-01 23:01:59 +02:00
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
2011-07-08 05:19:27 +02:00
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT
|
|
|
|
|
|
|
|
|
|
|
|
#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name) \
|
2011-07-08 05:14:42 +02:00
|
|
|
\
|
|
|
|
return_type \
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_unicode_##name (hb_unicode_funcs_t *ufuncs, \
|
|
|
|
hb_codepoint_t unicode) \
|
2011-07-08 05:14:42 +02:00
|
|
|
{ \
|
2012-08-01 23:01:59 +02:00
|
|
|
return ufuncs->name (unicode); \
|
2011-07-08 05:14:42 +02:00
|
|
|
}
|
2012-08-01 23:01:59 +02:00
|
|
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
|
2011-07-08 05:14:42 +02:00
|
|
|
#undef HB_UNICODE_FUNC_IMPLEMENT
|
2009-12-20 15:29:16 +01:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_compose:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
|
|
|
* @a: The first Unicode code point to compose
|
|
|
|
* @b: The second Unicode code point to compose
|
|
|
|
* @ab: (out): The composition of @a, @b
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the composition of a sequence of two Unicode
|
|
|
|
* code points.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Calls the composition function of the specified
|
|
|
|
* Unicode-functions structure @ufuncs.
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2020-12-30 22:08:40 +01:00
|
|
|
* Return value: %true if @a and @b composed, %false otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
|
|
|
|
hb_codepoint_t a,
|
|
|
|
hb_codepoint_t b,
|
|
|
|
hb_codepoint_t *ab)
|
|
|
|
{
|
2012-08-01 23:01:59 +02:00
|
|
|
return ufuncs->compose (a, b, ab);
|
2011-07-08 05:47:19 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_decompose:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
|
|
|
* @ab: Unicode code point to decompose
|
|
|
|
* @a: (out): The first code point of the decomposition of @ab
|
|
|
|
* @b: (out): The second code point of the decomposition of @ab
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the decomposition of a Unicode code point.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Calls the decomposition function of the specified
|
|
|
|
* Unicode-functions structure @ufuncs.
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2020-12-30 22:08:40 +01:00
|
|
|
* Return value: %true if @ab was decomposed, %false otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-07-08 05:47:19 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
|
|
|
|
hb_codepoint_t ab,
|
|
|
|
hb_codepoint_t *a,
|
|
|
|
hb_codepoint_t *b)
|
|
|
|
{
|
2012-08-01 23:01:59 +02:00
|
|
|
return ufuncs->decompose (ab, a, b);
|
2011-07-08 05:47:19 +02:00
|
|
|
}
|
2009-12-20 15:29:16 +01:00
|
|
|
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_unicode_decompose_compatibility:
|
2019-04-22 20:16:48 +02:00
|
|
|
* @ufuncs: The Unicode-functions structure
|
|
|
|
* @u: Code point to decompose
|
|
|
|
* @decomposed: (out): Compatibility decomposition of @u
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 20:16:48 +02:00
|
|
|
* Fetches the compatibility decomposition of a Unicode
|
|
|
|
* code point. Deprecated.
|
2018-12-17 19:01:01 +01:00
|
|
|
*
|
2020-12-30 22:46:13 +01:00
|
|
|
* Return value: length of @decomposed.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2018-10-21 01:49:16 +02:00
|
|
|
* Deprecated: 2.0.0
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-08-01 03:36:16 +02:00
|
|
|
unsigned int
|
|
|
|
hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs,
|
|
|
|
hb_codepoint_t u,
|
|
|
|
hb_codepoint_t *decomposed)
|
|
|
|
{
|
2012-08-01 23:01:59 +02:00
|
|
|
return ufuncs->decompose_compatibility (u, decomposed);
|
2012-08-01 03:36:16 +02:00
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2012-04-05 22:40:37 +02:00
|
|
|
|
|
|
|
|
2019-06-26 23:51:17 +02:00
|
|
|
#ifndef HB_NO_OT_SHAPE
|
2018-08-26 07:36:36 +02:00
|
|
|
/* See hb-unicode.hh for details. */
|
2012-08-02 00:07:42 +02:00
|
|
|
const uint8_t
|
|
|
|
_hb_modified_combining_class[256] =
|
2012-04-05 22:40:37 +02:00
|
|
|
{
|
2012-08-02 00:07:42 +02:00
|
|
|
0, /* HB_UNICODE_COMBINING_CLASS_NOT_REORDERED */
|
|
|
|
1, /* HB_UNICODE_COMBINING_CLASS_OVERLAY */
|
|
|
|
2, 3, 4, 5, 6,
|
|
|
|
7, /* HB_UNICODE_COMBINING_CLASS_NUKTA */
|
|
|
|
8, /* HB_UNICODE_COMBINING_CLASS_KANA_VOICING */
|
|
|
|
9, /* HB_UNICODE_COMBINING_CLASS_VIRAMA */
|
|
|
|
|
|
|
|
/* Hebrew */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC10,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC11,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC12,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC13,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC14,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC15,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC16,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC17,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC18,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC19,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC20,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC21,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC22,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC23,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC24,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC25,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC26,
|
2012-08-02 00:07:42 +02:00
|
|
|
|
|
|
|
/* Arabic */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC27,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC28,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC29,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC30,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC31,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC32,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC33,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC34,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC35,
|
2012-08-02 00:07:42 +02:00
|
|
|
|
|
|
|
/* Syriac */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC36,
|
2012-08-02 00:07:42 +02:00
|
|
|
|
|
|
|
37, 38, 39,
|
|
|
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
|
|
|
|
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
|
|
|
|
80, 81, 82, 83,
|
|
|
|
|
|
|
|
/* Telugu */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC84,
|
2012-08-02 00:07:42 +02:00
|
|
|
85, 86, 87, 88, 89, 90,
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC91,
|
2012-08-02 00:07:42 +02:00
|
|
|
92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
|
|
|
|
|
|
|
|
/* Thai */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC103,
|
2012-08-02 00:07:42 +02:00
|
|
|
104, 105, 106,
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC107,
|
2012-08-02 00:07:42 +02:00
|
|
|
108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
|
|
|
|
|
|
|
|
/* Lao */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC118,
|
2012-08-02 00:07:42 +02:00
|
|
|
119, 120, 121,
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC122,
|
2012-08-02 00:07:42 +02:00
|
|
|
123, 124, 125, 126, 127, 128,
|
|
|
|
|
|
|
|
/* Tibetan */
|
2012-08-08 07:20:45 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC129,
|
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC130,
|
2012-08-02 00:07:42 +02:00
|
|
|
131,
|
2012-08-10 03:12:30 +02:00
|
|
|
HB_MODIFIED_COMBINING_CLASS_CCC132,
|
2012-08-02 00:07:42 +02:00
|
|
|
133, 134, 135, 136, 137, 138, 139,
|
|
|
|
|
|
|
|
|
|
|
|
140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
|
|
|
|
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
|
|
|
160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
|
|
|
|
170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
|
|
|
|
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
|
|
|
|
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
|
|
|
|
|
|
|
|
200, /* HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT */
|
|
|
|
201,
|
|
|
|
202, /* HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW */
|
|
|
|
203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
|
|
|
|
214, /* HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE */
|
|
|
|
215,
|
|
|
|
216, /* HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE_RIGHT */
|
|
|
|
217,
|
|
|
|
218, /* HB_UNICODE_COMBINING_CLASS_BELOW_LEFT */
|
|
|
|
219,
|
|
|
|
220, /* HB_UNICODE_COMBINING_CLASS_BELOW */
|
|
|
|
221,
|
|
|
|
222, /* HB_UNICODE_COMBINING_CLASS_BELOW_RIGHT */
|
|
|
|
223,
|
|
|
|
224, /* HB_UNICODE_COMBINING_CLASS_LEFT */
|
|
|
|
225,
|
|
|
|
226, /* HB_UNICODE_COMBINING_CLASS_RIGHT */
|
|
|
|
227,
|
|
|
|
228, /* HB_UNICODE_COMBINING_CLASS_ABOVE_LEFT */
|
|
|
|
229,
|
|
|
|
230, /* HB_UNICODE_COMBINING_CLASS_ABOVE */
|
|
|
|
231,
|
|
|
|
232, /* HB_UNICODE_COMBINING_CLASS_ABOVE_RIGHT */
|
|
|
|
233, /* HB_UNICODE_COMBINING_CLASS_DOUBLE_BELOW */
|
|
|
|
234, /* HB_UNICODE_COMBINING_CLASS_DOUBLE_ABOVE */
|
|
|
|
235, 236, 237, 238, 239,
|
|
|
|
240, /* HB_UNICODE_COMBINING_CLASS_IOTA_SUBSCRIPT */
|
|
|
|
241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
|
|
|
|
255, /* HB_UNICODE_COMBINING_CLASS_INVALID */
|
|
|
|
};
|
2019-06-26 23:51:17 +02:00
|
|
|
#endif
|
2018-10-03 17:46:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Emoji
|
|
|
|
*/
|
2019-06-26 23:57:48 +02:00
|
|
|
#ifndef HB_NO_EMOJI_SEQUENCES
|
2018-10-03 17:46:48 +02:00
|
|
|
|
|
|
|
#include "hb-unicode-emoji-table.hh"
|
|
|
|
|
|
|
|
bool
|
|
|
|
_hb_unicode_is_emoji_Extended_Pictographic (hb_codepoint_t cp)
|
|
|
|
{
|
2019-06-26 23:49:15 +02:00
|
|
|
return _hb_emoji_is_Extended_Pictographic (cp);
|
2018-10-03 17:46:48 +02:00
|
|
|
}
|
2019-06-26 23:29:39 +02:00
|
|
|
#endif
|