2010-05-21 14:43:49 +02:00
|
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
|
* Copyright © 2009,2010 Red Hat, Inc.
|
2012-03-07 23:13:25 +01:00
|
|
|
|
* Copyright © 2011,2012 Google, Inc.
|
2010-05-21 14:43:49 +02:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Red Hat Author(s): Behdad Esfahbod
|
2011-04-21 23:14:28 +02:00
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
2010-05-21 14:43:49 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
|
#include "hb.hh"
|
2010-05-21 14:43:49 +02:00
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
|
#include "hb-machinery.hh"
|
2011-05-05 21:14:04 +02:00
|
|
|
|
|
2011-05-06 06:04:28 +02:00
|
|
|
|
#include <locale.h>
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#ifdef HAVE_XLOCALE_H
|
|
|
|
|
#include <xlocale.h>
|
|
|
|
|
#endif
|
2011-05-06 06:04:28 +02:00
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
|
2018-10-27 13:07:33 +02:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:hb-common
|
2018-10-27 13:50:38 +02:00
|
|
|
|
* @title: hb-common
|
2018-10-27 13:07:33 +02:00
|
|
|
|
* @short_description: Common data types
|
|
|
|
|
* @include: hb.h
|
|
|
|
|
*
|
|
|
|
|
* Common data types used across HarfBuzz are defined here.
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
2013-02-12 21:26:45 +01:00
|
|
|
|
/* hb_options_t */
|
|
|
|
|
|
2018-08-01 06:05:51 +02:00
|
|
|
|
hb_atomic_int_t _hb_options;
|
2013-02-12 21:26:45 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_hb_options_init (void)
|
|
|
|
|
{
|
|
|
|
|
hb_options_union_t u;
|
|
|
|
|
u.i = 0;
|
2018-10-18 17:18:42 +02:00
|
|
|
|
u.opts.initialized = true;
|
2013-02-12 21:26:45 +01:00
|
|
|
|
|
2018-10-10 23:44:46 +02:00
|
|
|
|
const char *c = getenv ("HB_OPTIONS");
|
|
|
|
|
if (c)
|
|
|
|
|
{
|
|
|
|
|
while (*c)
|
|
|
|
|
{
|
|
|
|
|
const char *p = strchr (c, ':');
|
|
|
|
|
if (!p)
|
|
|
|
|
p = c + strlen (c);
|
|
|
|
|
|
|
|
|
|
#define OPTION(name, symbol) \
|
2018-10-11 00:59:07 +02:00
|
|
|
|
if (0 == strncmp (c, name, p - c) && strlen (name) == p - c) u.opts.symbol = true;
|
2018-10-10 23:44:46 +02:00
|
|
|
|
|
|
|
|
|
OPTION ("uniscribe-bug-compatible", uniscribe_bug_compatible);
|
|
|
|
|
OPTION ("aat", aat);
|
|
|
|
|
|
|
|
|
|
#undef OPTION
|
|
|
|
|
|
|
|
|
|
c = *p ? p + 1 : p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-12 21:26:45 +01:00
|
|
|
|
|
|
|
|
|
/* This is idempotent and threadsafe. */
|
2018-08-01 06:05:51 +02:00
|
|
|
|
_hb_options.set_relaxed (u.i);
|
2013-02-12 21:26:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
|
2011-04-11 23:55:58 +02:00
|
|
|
|
/* hb_tag_t */
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_tag_from_string:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @str: (array length=len) (element-type uint8_t):
|
|
|
|
|
* @len:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Return value:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2010-05-21 14:43:49 +02:00
|
|
|
|
hb_tag_t
|
2013-09-06 23:35:57 +02:00
|
|
|
|
hb_tag_from_string (const char *str, int len)
|
2010-05-21 14:43:49 +02:00
|
|
|
|
{
|
|
|
|
|
char tag[4];
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
if (!str || !len || !*str)
|
2011-04-11 19:27:30 +02:00
|
|
|
|
return HB_TAG_NONE;
|
|
|
|
|
|
2011-08-26 09:18:53 +02:00
|
|
|
|
if (len < 0 || len > 4)
|
|
|
|
|
len = 4;
|
2013-09-06 23:35:57 +02:00
|
|
|
|
for (i = 0; i < (unsigned) len && str[i]; i++)
|
|
|
|
|
tag[i] = str[i];
|
2010-05-21 14:43:49 +02:00
|
|
|
|
for (; i < 4; i++)
|
|
|
|
|
tag[i] = ' ';
|
|
|
|
|
|
2017-10-31 22:30:06 +01:00
|
|
|
|
return HB_TAG (tag[0], tag[1], tag[2], tag[3]);
|
2010-05-21 14:43:49 +02:00
|
|
|
|
}
|
2010-07-23 21:11:18 +02:00
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_tag_to_string:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @tag:
|
|
|
|
|
* @buf: (out caller-allocates) (array fixed-size=4) (element-type uint8_t):
|
|
|
|
|
*
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
|
* Since: 0.9.5
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2012-09-07 04:09:06 +02:00
|
|
|
|
void
|
|
|
|
|
hb_tag_to_string (hb_tag_t tag, char *buf)
|
|
|
|
|
{
|
|
|
|
|
buf[0] = (char) (uint8_t) (tag >> 24);
|
|
|
|
|
buf[1] = (char) (uint8_t) (tag >> 16);
|
|
|
|
|
buf[2] = (char) (uint8_t) (tag >> 8);
|
|
|
|
|
buf[3] = (char) (uint8_t) (tag >> 0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
|
2011-04-27 20:48:19 +02:00
|
|
|
|
/* hb_direction_t */
|
|
|
|
|
|
|
|
|
|
const char direction_strings[][4] = {
|
|
|
|
|
"ltr",
|
|
|
|
|
"rtl",
|
|
|
|
|
"ttb",
|
|
|
|
|
"btt"
|
|
|
|
|
};
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_direction_from_string:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @str: (array length=len) (element-type uint8_t):
|
|
|
|
|
* @len:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Return value:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-27 20:48:19 +02:00
|
|
|
|
hb_direction_t
|
2011-08-26 09:18:53 +02:00
|
|
|
|
hb_direction_from_string (const char *str, int len)
|
2011-04-27 20:48:19 +02:00
|
|
|
|
{
|
2011-08-26 09:18:53 +02:00
|
|
|
|
if (unlikely (!str || !len || !*str))
|
2011-04-27 20:48:19 +02:00
|
|
|
|
return HB_DIRECTION_INVALID;
|
|
|
|
|
|
|
|
|
|
/* Lets match loosely: just match the first letter, such that
|
|
|
|
|
* all of "ltr", "left-to-right", etc work!
|
|
|
|
|
*/
|
|
|
|
|
char c = TOLOWER (str[0]);
|
|
|
|
|
for (unsigned int i = 0; i < ARRAY_LENGTH (direction_strings); i++)
|
|
|
|
|
if (c == direction_strings[i][0])
|
2012-04-12 23:38:23 +02:00
|
|
|
|
return (hb_direction_t) (HB_DIRECTION_LTR + i);
|
2011-04-27 20:48:19 +02:00
|
|
|
|
|
|
|
|
|
return HB_DIRECTION_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_direction_to_string:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @direction:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Return value: (transfer none):
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-27 20:48:19 +02:00
|
|
|
|
const char *
|
|
|
|
|
hb_direction_to_string (hb_direction_t direction)
|
|
|
|
|
{
|
2012-04-12 23:38:23 +02:00
|
|
|
|
if (likely ((unsigned int) (direction - HB_DIRECTION_LTR)
|
|
|
|
|
< ARRAY_LENGTH (direction_strings)))
|
|
|
|
|
return direction_strings[direction - HB_DIRECTION_LTR];
|
2011-04-27 20:48:19 +02:00
|
|
|
|
|
|
|
|
|
return "invalid";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-04-11 23:55:58 +02:00
|
|
|
|
/* hb_language_t */
|
|
|
|
|
|
2012-06-16 21:21:55 +02:00
|
|
|
|
struct hb_language_impl_t {
|
2011-04-15 18:32:06 +02:00
|
|
|
|
const char s[1];
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-11 23:55:58 +02:00
|
|
|
|
static const char canon_map[256] = {
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0,
|
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
|
|
|
|
|
'-', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, '-',
|
|
|
|
|
0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
|
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0, 0, 0, 0, 0
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-09 01:26:24 +02:00
|
|
|
|
static bool
|
2012-06-06 00:00:45 +02:00
|
|
|
|
lang_equal (hb_language_t v1,
|
|
|
|
|
const void *v2)
|
2011-04-11 23:55:58 +02:00
|
|
|
|
{
|
2011-04-21 00:50:27 +02:00
|
|
|
|
const unsigned char *p1 = (const unsigned char *) v1;
|
|
|
|
|
const unsigned char *p2 = (const unsigned char *) v2;
|
2011-04-11 23:55:58 +02:00
|
|
|
|
|
2017-04-18 08:25:24 +02:00
|
|
|
|
while (*p1 && *p1 == canon_map[*p2]) {
|
|
|
|
|
p1++;
|
|
|
|
|
p2++;
|
|
|
|
|
}
|
2011-04-11 23:55:58 +02:00
|
|
|
|
|
2012-06-06 00:00:45 +02:00
|
|
|
|
return *p1 == canon_map[*p2];
|
2011-04-11 23:55:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static unsigned int
|
|
|
|
|
lang_hash (const void *key)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char *p = key;
|
|
|
|
|
unsigned int h = 0;
|
|
|
|
|
while (canon_map[*p])
|
|
|
|
|
{
|
|
|
|
|
h = (h << 5) - h + canon_map[*p];
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return h;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2011-05-05 21:00:43 +02:00
|
|
|
|
struct hb_language_item_t {
|
|
|
|
|
|
2012-06-06 00:00:45 +02:00
|
|
|
|
struct hb_language_item_t *next;
|
2011-05-05 21:00:43 +02:00
|
|
|
|
hb_language_t lang;
|
|
|
|
|
|
|
|
|
|
inline bool operator == (const char *s) const {
|
|
|
|
|
return lang_equal (lang, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline hb_language_item_t & operator = (const char *s) {
|
2017-05-29 19:53:30 +02:00
|
|
|
|
/* If a custom allocated is used calling strdup() pairs
|
2018-05-02 01:01:25 +02:00
|
|
|
|
badly with a call to the custom free() in fini() below.
|
2017-05-29 19:53:30 +02:00
|
|
|
|
Therefore don't call strdup(), implement its behavior.
|
|
|
|
|
*/
|
|
|
|
|
size_t len = strlen(s) + 1;
|
|
|
|
|
lang = (hb_language_t) malloc(len);
|
2017-06-01 17:44:42 +02:00
|
|
|
|
if (likely (lang))
|
|
|
|
|
{
|
|
|
|
|
memcpy((unsigned char *) lang, s, len);
|
|
|
|
|
for (unsigned char *p = (unsigned char *) lang; *p; p++)
|
|
|
|
|
*p = canon_map[*p];
|
|
|
|
|
}
|
2011-05-05 21:00:43 +02:00
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 01:01:25 +02:00
|
|
|
|
void fini (void) { free ((void *) lang); }
|
2011-05-05 21:00:43 +02:00
|
|
|
|
};
|
|
|
|
|
|
2012-06-06 00:00:45 +02:00
|
|
|
|
|
|
|
|
|
/* Thread-safe lock-free language list */
|
|
|
|
|
|
2018-08-09 09:22:37 +02:00
|
|
|
|
static hb_atomic_ptr_t <hb_language_item_t> langs;
|
2012-06-06 00:00:45 +02:00
|
|
|
|
|
2014-08-06 19:34:49 +02:00
|
|
|
|
#ifdef HB_USE_ATEXIT
|
2017-09-15 02:50:35 +02:00
|
|
|
|
static void
|
|
|
|
|
free_langs (void)
|
2012-06-06 00:00:45 +02:00
|
|
|
|
{
|
2018-03-29 00:33:51 +02:00
|
|
|
|
retry:
|
2018-11-05 19:23:54 +01:00
|
|
|
|
hb_language_item_t *first_lang = langs;
|
2018-08-09 09:22:37 +02:00
|
|
|
|
if (unlikely (!langs.cmpexch (first_lang, nullptr)))
|
2018-03-29 00:33:51 +02:00
|
|
|
|
goto retry;
|
|
|
|
|
|
|
|
|
|
while (first_lang) {
|
|
|
|
|
hb_language_item_t *next = first_lang->next;
|
2018-05-02 01:01:25 +02:00
|
|
|
|
first_lang->fini ();
|
2018-03-29 00:33:51 +02:00
|
|
|
|
free (first_lang);
|
|
|
|
|
first_lang = next;
|
2012-06-06 00:00:45 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-16 09:25:17 +01:00
|
|
|
|
#endif
|
2012-06-06 00:00:45 +02:00
|
|
|
|
|
|
|
|
|
static hb_language_item_t *
|
|
|
|
|
lang_find_or_insert (const char *key)
|
|
|
|
|
{
|
|
|
|
|
retry:
|
2018-11-05 19:23:54 +01:00
|
|
|
|
hb_language_item_t *first_lang = langs;
|
2012-06-06 00:00:45 +02:00
|
|
|
|
|
|
|
|
|
for (hb_language_item_t *lang = first_lang; lang; lang = lang->next)
|
|
|
|
|
if (*lang == key)
|
|
|
|
|
return lang;
|
|
|
|
|
|
|
|
|
|
/* Not found; allocate one. */
|
|
|
|
|
hb_language_item_t *lang = (hb_language_item_t *) calloc (1, sizeof (hb_language_item_t));
|
|
|
|
|
if (unlikely (!lang))
|
2017-10-15 12:11:08 +02:00
|
|
|
|
return nullptr;
|
2012-06-06 00:00:45 +02:00
|
|
|
|
lang->next = first_lang;
|
|
|
|
|
*lang = key;
|
2017-06-01 17:44:42 +02:00
|
|
|
|
if (unlikely (!lang->lang))
|
|
|
|
|
{
|
|
|
|
|
free (lang);
|
2017-10-15 12:11:08 +02:00
|
|
|
|
return nullptr;
|
2017-06-01 17:44:42 +02:00
|
|
|
|
}
|
2012-06-06 00:00:45 +02:00
|
|
|
|
|
2018-08-09 09:22:37 +02:00
|
|
|
|
if (unlikely (!langs.cmpexch (first_lang, lang)))
|
|
|
|
|
{
|
2018-05-02 01:01:25 +02:00
|
|
|
|
lang->fini ();
|
2012-06-06 00:00:45 +02:00
|
|
|
|
free (lang);
|
|
|
|
|
goto retry;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-06 19:34:49 +02:00
|
|
|
|
#ifdef HB_USE_ATEXIT
|
2012-06-06 00:30:19 +02:00
|
|
|
|
if (!first_lang)
|
|
|
|
|
atexit (free_langs); /* First person registers atexit() callback. */
|
2012-06-06 00:00:45 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return lang;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-05 21:14:04 +02:00
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_language_from_string:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @str: (array length=len) (element-type uint8_t): a string representing
|
2017-12-28 15:59:29 +01:00
|
|
|
|
* a BCP 47 language tag
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @len: length of the @str, or -1 if it is %NULL-terminated.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2017-12-28 15:59:29 +01:00
|
|
|
|
* Converts @str representing a BCP 47 language tag to the corresponding
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* #hb_language_t.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-04-10 17:49:01 +02:00
|
|
|
|
* Return value: (transfer none):
|
2017-12-28 15:59:29 +01:00
|
|
|
|
* The #hb_language_t corresponding to the BCP 47 language tag.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-11 23:55:58 +02:00
|
|
|
|
hb_language_t
|
2011-08-26 09:18:53 +02:00
|
|
|
|
hb_language_from_string (const char *str, int len)
|
2011-04-11 23:55:58 +02:00
|
|
|
|
{
|
2011-08-26 09:18:53 +02:00
|
|
|
|
if (!str || !len || !*str)
|
2011-05-14 04:55:32 +02:00
|
|
|
|
return HB_LANGUAGE_INVALID;
|
2011-04-11 23:55:58 +02:00
|
|
|
|
|
2017-10-15 12:11:08 +02:00
|
|
|
|
hb_language_item_t *item = nullptr;
|
2013-09-26 22:48:42 +02:00
|
|
|
|
if (len >= 0)
|
|
|
|
|
{
|
2014-06-03 23:57:00 +02:00
|
|
|
|
/* NUL-terminate it. */
|
2015-09-29 15:34:56 +02:00
|
|
|
|
char strbuf[64];
|
2011-08-26 09:18:53 +02:00
|
|
|
|
len = MIN (len, (int) sizeof (strbuf) - 1);
|
2014-06-03 23:57:00 +02:00
|
|
|
|
memcpy (strbuf, str, len);
|
2011-08-26 09:18:53 +02:00
|
|
|
|
strbuf[len] = '\0';
|
2015-09-29 15:34:56 +02:00
|
|
|
|
item = lang_find_or_insert (strbuf);
|
2011-08-26 09:18:53 +02:00
|
|
|
|
}
|
2015-09-29 15:34:56 +02:00
|
|
|
|
else
|
|
|
|
|
item = lang_find_or_insert (str);
|
2011-04-11 23:55:58 +02:00
|
|
|
|
|
2011-05-14 04:55:32 +02:00
|
|
|
|
return likely (item) ? item->lang : HB_LANGUAGE_INVALID;
|
2011-04-11 23:55:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_language_to_string:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @language: an #hb_language_t to convert.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* See hb_language_from_string().
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* Return value: (transfer none):
|
|
|
|
|
* A %NULL-terminated string representing the @language. Must not be freed by
|
|
|
|
|
* the caller.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-11 23:55:58 +02:00
|
|
|
|
const char *
|
|
|
|
|
hb_language_to_string (hb_language_t language)
|
|
|
|
|
{
|
2017-10-15 12:11:08 +02:00
|
|
|
|
/* This is actually nullptr-safe! */
|
2011-04-15 18:32:06 +02:00
|
|
|
|
return language->s;
|
2011-04-11 23:55:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_language_get_default:
|
|
|
|
|
*
|
2018-09-30 09:49:52 +02:00
|
|
|
|
* Get default language from current locale.
|
|
|
|
|
*
|
|
|
|
|
* Note that the first time this function is called, it calls
|
|
|
|
|
* "setlocale (LC_CTYPE, nullptr)" to fetch current locale. The underlying
|
|
|
|
|
* setlocale function is, in many implementations, NOT threadsafe. To avoid
|
|
|
|
|
* problems, call this function once before multiple threads can call it.
|
|
|
|
|
* This function is only used from hb_buffer_guess_segment_properties() by
|
|
|
|
|
* HarfBuzz itself.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-06-13 02:46:06 +02:00
|
|
|
|
* Return value: (transfer none):
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-05-06 06:04:28 +02:00
|
|
|
|
hb_language_t
|
|
|
|
|
hb_language_get_default (void)
|
|
|
|
|
{
|
2018-08-09 09:22:37 +02:00
|
|
|
|
static hb_atomic_ptr_t <hb_language_t> default_language;
|
2011-05-06 06:04:28 +02:00
|
|
|
|
|
2018-11-05 19:23:54 +01:00
|
|
|
|
hb_language_t language = default_language;
|
2018-08-09 09:22:37 +02:00
|
|
|
|
if (unlikely (language == HB_LANGUAGE_INVALID))
|
|
|
|
|
{
|
2017-10-15 12:11:08 +02:00
|
|
|
|
language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1);
|
2018-08-09 09:22:37 +02:00
|
|
|
|
(void) default_language.cmpexch (HB_LANGUAGE_INVALID, language);
|
2011-05-06 06:04:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-09 09:22:37 +02:00
|
|
|
|
return language;
|
2011-05-06 06:04:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-11 23:55:58 +02:00
|
|
|
|
|
2011-04-16 01:16:54 +02:00
|
|
|
|
/* hb_script_t */
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_script_from_iso15924_tag:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @tag: an #hb_tag_t representing an ISO 15924 tag.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* Converts an ISO 15924 script tag to a corresponding #hb_script_t.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* Return value:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* An #hb_script_t corresponding to the ISO 15924 tag.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-16 01:16:54 +02:00
|
|
|
|
hb_script_t
|
|
|
|
|
hb_script_from_iso15924_tag (hb_tag_t tag)
|
|
|
|
|
{
|
2011-04-20 08:54:42 +02:00
|
|
|
|
if (unlikely (tag == HB_TAG_NONE))
|
|
|
|
|
return HB_SCRIPT_INVALID;
|
|
|
|
|
|
2011-04-16 01:16:54 +02:00
|
|
|
|
/* Be lenient, adjust case (one capital letter followed by three small letters) */
|
2014-07-11 20:54:42 +02:00
|
|
|
|
tag = (tag & 0xDFDFDFDFu) | 0x00202020u;
|
2011-04-16 01:16:54 +02:00
|
|
|
|
|
2011-04-19 05:40:21 +02:00
|
|
|
|
switch (tag) {
|
2011-05-02 18:35:14 +02:00
|
|
|
|
|
|
|
|
|
/* These graduated from the 'Q' private-area codes, but
|
|
|
|
|
* the old code is still aliased by Unicode, and the Qaai
|
|
|
|
|
* one in use by ICU. */
|
|
|
|
|
case HB_TAG('Q','a','a','i'): return HB_SCRIPT_INHERITED;
|
|
|
|
|
case HB_TAG('Q','a','a','c'): return HB_SCRIPT_COPTIC;
|
|
|
|
|
|
2018-04-12 11:10:45 +02:00
|
|
|
|
/* Script variants from https://unicode.org/iso15924/ */
|
2011-04-19 05:40:21 +02:00
|
|
|
|
case HB_TAG('C','y','r','s'): return HB_SCRIPT_CYRILLIC;
|
|
|
|
|
case HB_TAG('L','a','t','f'): return HB_SCRIPT_LATIN;
|
|
|
|
|
case HB_TAG('L','a','t','g'): return HB_SCRIPT_LATIN;
|
|
|
|
|
case HB_TAG('S','y','r','e'): return HB_SCRIPT_SYRIAC;
|
|
|
|
|
case HB_TAG('S','y','r','j'): return HB_SCRIPT_SYRIAC;
|
|
|
|
|
case HB_TAG('S','y','r','n'): return HB_SCRIPT_SYRIAC;
|
|
|
|
|
}
|
2011-04-16 01:16:54 +02:00
|
|
|
|
|
|
|
|
|
/* If it looks right, just use the tag as a script */
|
2014-07-11 20:54:42 +02:00
|
|
|
|
if (((uint32_t) tag & 0xE0E0E0E0u) == 0x40606060u)
|
2011-04-16 01:16:54 +02:00
|
|
|
|
return (hb_script_t) tag;
|
|
|
|
|
|
|
|
|
|
/* Otherwise, return unknown */
|
|
|
|
|
return HB_SCRIPT_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_script_from_string:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @str: (array length=len) (element-type uint8_t): a string representing an
|
|
|
|
|
* ISO 15924 tag.
|
|
|
|
|
* @len: length of the @str, or -1 if it is %NULL-terminated.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* Converts a string @str representing an ISO 15924 script tag to a
|
|
|
|
|
* corresponding #hb_script_t. Shorthand for hb_tag_from_string() then
|
|
|
|
|
* hb_script_from_iso15924_tag().
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* Return value:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* An #hb_script_t corresponding to the ISO 15924 tag.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-16 01:16:54 +02:00
|
|
|
|
hb_script_t
|
2015-12-29 14:42:16 +01:00
|
|
|
|
hb_script_from_string (const char *str, int len)
|
2011-04-16 01:16:54 +02:00
|
|
|
|
{
|
2015-12-29 14:42:16 +01:00
|
|
|
|
return hb_script_from_iso15924_tag (hb_tag_from_string (str, len));
|
2011-04-16 01:16:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_script_to_iso15924_tag:
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* @script: an #hb_script_ to convert.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* See hb_script_from_iso15924_tag().
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-12-29 14:42:16 +01:00
|
|
|
|
* Return value:
|
|
|
|
|
* An #hb_tag_t representing an ISO 15924 script tag.
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-16 01:16:54 +02:00
|
|
|
|
hb_tag_t
|
|
|
|
|
hb_script_to_iso15924_tag (hb_script_t script)
|
|
|
|
|
{
|
2011-04-19 05:40:21 +02:00
|
|
|
|
return (hb_tag_t) script;
|
2011-04-16 01:16:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_script_get_horizontal_direction:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @script:
|
|
|
|
|
*
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* Return value:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-04-16 01:16:54 +02:00
|
|
|
|
hb_direction_t
|
|
|
|
|
hb_script_get_horizontal_direction (hb_script_t script)
|
|
|
|
|
{
|
2018-04-12 11:10:45 +02:00
|
|
|
|
/* https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o */
|
2011-04-19 05:40:21 +02:00
|
|
|
|
switch ((hb_tag_t) script)
|
|
|
|
|
{
|
2012-03-07 21:52:02 +01:00
|
|
|
|
/* Unicode-1.1 additions */
|
2011-04-19 05:40:21 +02:00
|
|
|
|
case HB_SCRIPT_ARABIC:
|
|
|
|
|
case HB_SCRIPT_HEBREW:
|
2012-03-07 21:52:02 +01:00
|
|
|
|
|
|
|
|
|
/* Unicode-3.0 additions */
|
2011-04-19 05:40:21 +02:00
|
|
|
|
case HB_SCRIPT_SYRIAC:
|
|
|
|
|
case HB_SCRIPT_THAANA:
|
|
|
|
|
|
|
|
|
|
/* Unicode-4.0 additions */
|
|
|
|
|
case HB_SCRIPT_CYPRIOT:
|
|
|
|
|
|
2012-03-07 18:49:08 +01:00
|
|
|
|
/* Unicode-4.1 additions */
|
|
|
|
|
case HB_SCRIPT_KHAROSHTHI:
|
|
|
|
|
|
2011-04-19 05:40:21 +02:00
|
|
|
|
/* Unicode-5.0 additions */
|
|
|
|
|
case HB_SCRIPT_PHOENICIAN:
|
|
|
|
|
case HB_SCRIPT_NKO:
|
|
|
|
|
|
2012-03-07 18:49:08 +01:00
|
|
|
|
/* Unicode-5.1 additions */
|
|
|
|
|
case HB_SCRIPT_LYDIAN:
|
|
|
|
|
|
2011-04-19 05:40:21 +02:00
|
|
|
|
/* Unicode-5.2 additions */
|
|
|
|
|
case HB_SCRIPT_AVESTAN:
|
|
|
|
|
case HB_SCRIPT_IMPERIAL_ARAMAIC:
|
|
|
|
|
case HB_SCRIPT_INSCRIPTIONAL_PAHLAVI:
|
|
|
|
|
case HB_SCRIPT_INSCRIPTIONAL_PARTHIAN:
|
|
|
|
|
case HB_SCRIPT_OLD_SOUTH_ARABIAN:
|
|
|
|
|
case HB_SCRIPT_OLD_TURKIC:
|
|
|
|
|
case HB_SCRIPT_SAMARITAN:
|
|
|
|
|
|
|
|
|
|
/* Unicode-6.0 additions */
|
|
|
|
|
case HB_SCRIPT_MANDAIC:
|
|
|
|
|
|
2012-03-07 21:52:02 +01:00
|
|
|
|
/* Unicode-6.1 additions */
|
|
|
|
|
case HB_SCRIPT_MEROITIC_CURSIVE:
|
|
|
|
|
case HB_SCRIPT_MEROITIC_HIEROGLYPHS:
|
|
|
|
|
|
2014-04-29 00:06:42 +02:00
|
|
|
|
/* Unicode-7.0 additions */
|
|
|
|
|
case HB_SCRIPT_MANICHAEAN:
|
|
|
|
|
case HB_SCRIPT_MENDE_KIKAKUI:
|
|
|
|
|
case HB_SCRIPT_NABATAEAN:
|
|
|
|
|
case HB_SCRIPT_OLD_NORTH_ARABIAN:
|
|
|
|
|
case HB_SCRIPT_PALMYRENE:
|
|
|
|
|
case HB_SCRIPT_PSALTER_PAHLAVI:
|
|
|
|
|
|
2015-07-15 02:36:39 +02:00
|
|
|
|
/* Unicode-8.0 additions */
|
2018-01-18 22:49:40 +01:00
|
|
|
|
case HB_SCRIPT_HATRAN:
|
2015-07-15 02:36:39 +02:00
|
|
|
|
|
2016-05-06 13:08:18 +02:00
|
|
|
|
/* Unicode-9.0 additions */
|
|
|
|
|
case HB_SCRIPT_ADLAM:
|
|
|
|
|
|
2018-06-06 02:31:46 +02:00
|
|
|
|
/* Unicode-11.0 additions */
|
|
|
|
|
case HB_SCRIPT_HANIFI_ROHINGYA:
|
|
|
|
|
case HB_SCRIPT_OLD_SOGDIAN:
|
|
|
|
|
case HB_SCRIPT_SOGDIAN:
|
|
|
|
|
|
2011-04-19 05:40:21 +02:00
|
|
|
|
return HB_DIRECTION_RTL;
|
2018-05-07 22:58:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* https://github.com/harfbuzz/harfbuzz/issues/1000 */
|
2018-09-17 17:09:51 +02:00
|
|
|
|
case HB_SCRIPT_OLD_HUNGARIAN:
|
2018-05-07 22:58:32 +02:00
|
|
|
|
case HB_SCRIPT_OLD_ITALIC:
|
2018-07-06 21:47:03 +02:00
|
|
|
|
case HB_SCRIPT_RUNIC:
|
2018-05-07 22:58:32 +02:00
|
|
|
|
|
|
|
|
|
return HB_DIRECTION_INVALID;
|
2011-04-19 05:40:21 +02:00
|
|
|
|
}
|
2011-04-16 01:16:54 +02:00
|
|
|
|
|
2011-04-19 05:40:21 +02:00
|
|
|
|
return HB_DIRECTION_LTR;
|
2011-04-16 01:16:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-05-05 21:28:37 +02:00
|
|
|
|
/* hb_user_data_array_t */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
hb_user_data_array_t::set (hb_user_data_key_t *key,
|
|
|
|
|
void * data,
|
2011-08-09 00:43:24 +02:00
|
|
|
|
hb_destroy_func_t destroy,
|
2012-12-03 23:35:54 +01:00
|
|
|
|
hb_bool_t replace)
|
2011-05-05 21:28:37 +02:00
|
|
|
|
{
|
|
|
|
|
if (!key)
|
|
|
|
|
return false;
|
2011-05-05 21:33:19 +02:00
|
|
|
|
|
2011-08-09 00:43:24 +02:00
|
|
|
|
if (replace) {
|
|
|
|
|
if (!data && !destroy) {
|
2012-06-05 21:37:19 +02:00
|
|
|
|
items.remove (key, lock);
|
2011-08-09 00:43:24 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-05-05 21:28:37 +02:00
|
|
|
|
}
|
|
|
|
|
hb_user_data_item_t item = {key, data, destroy};
|
2015-11-27 01:22:22 +01:00
|
|
|
|
bool ret = !!items.replace_or_insert (item, lock, (bool) replace);
|
2011-05-05 21:33:19 +02:00
|
|
|
|
|
|
|
|
|
return ret;
|
2011-05-05 21:28:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *
|
2012-12-03 23:35:54 +01:00
|
|
|
|
hb_user_data_array_t::get (hb_user_data_key_t *key)
|
2011-05-05 21:28:37 +02:00
|
|
|
|
{
|
2017-10-15 12:11:08 +02:00
|
|
|
|
hb_user_data_item_t item = {nullptr, nullptr, nullptr};
|
2011-05-05 21:33:19 +02:00
|
|
|
|
|
2017-10-15 12:11:08 +02:00
|
|
|
|
return items.find (key, &item, lock) ? item.data : nullptr;
|
2011-05-11 01:12:49 +02:00
|
|
|
|
}
|
2011-05-05 21:33:19 +02:00
|
|
|
|
|
2011-05-05 21:28:37 +02:00
|
|
|
|
|
2011-05-06 03:31:04 +02:00
|
|
|
|
/* hb_version */
|
|
|
|
|
|
2018-10-27 13:07:33 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:hb-version
|
2018-10-27 13:50:38 +02:00
|
|
|
|
* @title: hb-version
|
2018-10-27 13:07:33 +02:00
|
|
|
|
* @short_description: Information about the version of HarfBuzz in use
|
|
|
|
|
* @include: hb.h
|
|
|
|
|
*
|
|
|
|
|
* These functions and macros allow accessing version of the HarfBuzz
|
|
|
|
|
* library used at compile- as well as run-time, and to direct code
|
|
|
|
|
* conditionally based on those versions, again, at compile- or run-time.
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_version:
|
|
|
|
|
* @major: (out): Library major version component.
|
|
|
|
|
* @minor: (out): Library minor version component.
|
|
|
|
|
* @micro: (out): Library micro version component.
|
|
|
|
|
*
|
|
|
|
|
* Returns library version as three integer components.
|
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-05-06 03:31:04 +02:00
|
|
|
|
void
|
|
|
|
|
hb_version (unsigned int *major,
|
|
|
|
|
unsigned int *minor,
|
|
|
|
|
unsigned int *micro)
|
|
|
|
|
{
|
|
|
|
|
*major = HB_VERSION_MAJOR;
|
|
|
|
|
*minor = HB_VERSION_MINOR;
|
|
|
|
|
*micro = HB_VERSION_MICRO;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* hb_version_string:
|
|
|
|
|
*
|
|
|
|
|
* Returns library version as a string with three components.
|
|
|
|
|
*
|
|
|
|
|
* Return value: library version string.
|
|
|
|
|
*
|
2015-09-03 13:23:22 +02:00
|
|
|
|
* Since: 0.9.2
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-05-06 03:31:04 +02:00
|
|
|
|
const char *
|
|
|
|
|
hb_version_string (void)
|
|
|
|
|
{
|
|
|
|
|
return HB_VERSION_STRING;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
|
/**
|
2014-06-20 20:09:57 +02:00
|
|
|
|
* hb_version_atleast:
|
2018-03-30 02:30:28 +02:00
|
|
|
|
* @major:
|
|
|
|
|
* @minor:
|
|
|
|
|
* @micro:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
|
|
|
|
*
|
2018-03-30 02:30:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Return value:
|
2013-09-06 23:35:57 +02:00
|
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
|
* Since: 0.9.30
|
2013-09-06 23:35:57 +02:00
|
|
|
|
**/
|
2011-05-06 03:31:04 +02:00
|
|
|
|
hb_bool_t
|
2014-06-20 20:09:57 +02:00
|
|
|
|
hb_version_atleast (unsigned int major,
|
|
|
|
|
unsigned int minor,
|
|
|
|
|
unsigned int micro)
|
2011-05-06 03:31:04 +02:00
|
|
|
|
{
|
2014-06-20 20:09:57 +02:00
|
|
|
|
return HB_VERSION_ATLEAST (major, minor, micro);
|
2011-05-06 03:31:04 +02:00
|
|
|
|
}
|
2017-01-21 05:16:53 +01:00
|
|
|
|
|
|
|
|
|
|
2017-01-21 05:30:03 +01:00
|
|
|
|
|
2017-01-22 02:41:37 +01:00
|
|
|
|
/* hb_feature_t and hb_variation_t */
|
2017-01-21 05:16:53 +01:00
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_space (const char **pp, const char *end)
|
|
|
|
|
{
|
|
|
|
|
while (*pp < end && ISSPACE (**pp))
|
|
|
|
|
(*pp)++;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_char (const char **pp, const char *end, char c)
|
|
|
|
|
{
|
|
|
|
|
parse_space (pp, end);
|
|
|
|
|
|
|
|
|
|
if (*pp == end || **pp != c)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
(*pp)++;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_uint (const char **pp, const char *end, unsigned int *pv)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
|
|
|
|
strncpy (buf, *pp, len);
|
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
|
|
|
|
|
char *p = buf;
|
|
|
|
|
char *pend = p;
|
|
|
|
|
unsigned int v;
|
|
|
|
|
|
|
|
|
|
/* Intentionally use strtol instead of strtoul, such that
|
|
|
|
|
* -1 turns into "big number"... */
|
|
|
|
|
errno = 0;
|
|
|
|
|
v = strtol (p, &pend, 0);
|
|
|
|
|
if (errno || p == pend)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*pv = v;
|
|
|
|
|
*pp += pend - p;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 12:17:09 +02:00
|
|
|
|
static bool
|
|
|
|
|
parse_uint32 (const char **pp, const char *end, uint32_t *pv)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
|
|
|
|
strncpy (buf, *pp, len);
|
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
|
|
|
|
|
char *p = buf;
|
|
|
|
|
char *pend = p;
|
|
|
|
|
unsigned int v;
|
|
|
|
|
|
|
|
|
|
/* Intentionally use strtol instead of strtoul, such that
|
|
|
|
|
* -1 turns into "big number"... */
|
|
|
|
|
errno = 0;
|
|
|
|
|
v = strtol (p, &pend, 0);
|
|
|
|
|
if (errno || p == pend)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*pv = v;
|
|
|
|
|
*pp += pend - p;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L)
|
|
|
|
|
#define USE_XLOCALE 1
|
2017-11-14 00:04:13 +01:00
|
|
|
|
#define HB_LOCALE_T locale_t
|
|
|
|
|
#define HB_CREATE_LOCALE(locName) newlocale (LC_ALL_MASK, locName, nullptr)
|
|
|
|
|
#define HB_FREE_LOCALE(loc) freelocale (loc)
|
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
|
#define USE_XLOCALE 1
|
|
|
|
|
#define HB_LOCALE_T _locale_t
|
|
|
|
|
#define HB_CREATE_LOCALE(locName) _create_locale (LC_ALL, locName)
|
|
|
|
|
#define HB_FREE_LOCALE(loc) _free_locale (loc)
|
|
|
|
|
#define strtod_l(a, b, c) _strtod_l ((a), (b), (c))
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef USE_XLOCALE
|
|
|
|
|
|
2018-08-14 23:47:20 +02:00
|
|
|
|
#ifdef HB_USE_ATEXIT
|
2018-08-13 02:42:16 +02:00
|
|
|
|
static void free_static_C_locale (void);
|
2018-08-14 23:47:20 +02:00
|
|
|
|
#endif
|
2018-03-30 02:30:28 +02:00
|
|
|
|
|
2018-10-23 06:18:27 +02:00
|
|
|
|
static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t<hb_remove_pointer<HB_LOCALE_T>::value,
|
2018-08-13 02:42:16 +02:00
|
|
|
|
hb_C_locale_lazy_loader_t>
|
2017-09-15 02:50:35 +02:00
|
|
|
|
{
|
2018-08-13 02:42:16 +02:00
|
|
|
|
static inline HB_LOCALE_T create (void)
|
2017-09-15 02:50:35 +02:00
|
|
|
|
{
|
2018-08-13 02:42:16 +02:00
|
|
|
|
HB_LOCALE_T C_locale = HB_CREATE_LOCALE ("C");
|
2017-09-15 02:50:35 +02:00
|
|
|
|
|
|
|
|
|
#ifdef HB_USE_ATEXIT
|
2018-08-13 02:42:16 +02:00
|
|
|
|
atexit (free_static_C_locale);
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#endif
|
2018-08-13 02:42:16 +02:00
|
|
|
|
|
|
|
|
|
return C_locale;
|
|
|
|
|
}
|
|
|
|
|
static inline void destroy (HB_LOCALE_T p)
|
|
|
|
|
{
|
|
|
|
|
HB_FREE_LOCALE (p);
|
|
|
|
|
}
|
|
|
|
|
static inline HB_LOCALE_T get_null (void)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
2017-09-15 02:50:35 +02:00
|
|
|
|
}
|
2018-08-13 02:42:16 +02:00
|
|
|
|
} static_C_locale;
|
2017-09-15 02:50:35 +02:00
|
|
|
|
|
2018-08-13 02:42:16 +02:00
|
|
|
|
#ifdef HB_USE_ATEXIT
|
|
|
|
|
static
|
|
|
|
|
void free_static_C_locale (void)
|
|
|
|
|
{
|
|
|
|
|
static_C_locale.free_instance ();
|
2017-09-15 02:50:35 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-08-13 02:42:16 +02:00
|
|
|
|
static HB_LOCALE_T
|
|
|
|
|
get_C_locale (void)
|
|
|
|
|
{
|
|
|
|
|
return static_C_locale.get_unconst ();
|
|
|
|
|
}
|
|
|
|
|
#endif /* USE_XLOCALE */
|
|
|
|
|
|
2017-01-21 05:30:03 +01:00
|
|
|
|
static bool
|
|
|
|
|
parse_float (const char **pp, const char *end, float *pv)
|
|
|
|
|
{
|
|
|
|
|
char buf[32];
|
|
|
|
|
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
|
|
|
|
|
strncpy (buf, *pp, len);
|
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
|
|
|
|
|
char *p = buf;
|
|
|
|
|
char *pend = p;
|
|
|
|
|
float v;
|
|
|
|
|
|
|
|
|
|
errno = 0;
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#ifdef USE_XLOCALE
|
|
|
|
|
v = strtod_l (p, &pend, get_C_locale ());
|
|
|
|
|
#else
|
2017-02-24 10:58:25 +01:00
|
|
|
|
v = strtod (p, &pend);
|
2017-09-15 02:50:35 +02:00
|
|
|
|
#endif
|
2017-01-21 05:30:03 +01:00
|
|
|
|
if (errno || p == pend)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
*pv = v;
|
|
|
|
|
*pp += pend - p;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-21 05:16:53 +01:00
|
|
|
|
static bool
|
2017-06-19 12:17:09 +02:00
|
|
|
|
parse_bool (const char **pp, const char *end, uint32_t *pv)
|
2017-01-21 05:16:53 +01:00
|
|
|
|
{
|
|
|
|
|
parse_space (pp, end);
|
|
|
|
|
|
|
|
|
|
const char *p = *pp;
|
|
|
|
|
while (*pp < end && ISALPHA(**pp))
|
|
|
|
|
(*pp)++;
|
|
|
|
|
|
|
|
|
|
/* CSS allows on/off as aliases 1/0. */
|
2017-12-04 21:15:27 +01:00
|
|
|
|
if (*pp - p == 2 && 0 == strncmp (p, "on", 2))
|
2017-01-21 05:16:53 +01:00
|
|
|
|
*pv = 1;
|
2017-12-04 21:15:27 +01:00
|
|
|
|
else if (*pp - p == 3 && 0 == strncmp (p, "off", 3))
|
2017-01-21 05:16:53 +01:00
|
|
|
|
*pv = 0;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-21 05:30:03 +01:00
|
|
|
|
/* hb_feature_t */
|
|
|
|
|
|
2017-01-21 05:16:53 +01:00
|
|
|
|
static bool
|
|
|
|
|
parse_feature_value_prefix (const char **pp, const char *end, hb_feature_t *feature)
|
|
|
|
|
{
|
|
|
|
|
if (parse_char (pp, end, '-'))
|
|
|
|
|
feature->value = 0;
|
|
|
|
|
else {
|
|
|
|
|
parse_char (pp, end, '+');
|
|
|
|
|
feature->value = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
2017-01-21 05:30:03 +01:00
|
|
|
|
parse_tag (const char **pp, const char *end, hb_tag_t *tag)
|
2017-01-21 05:16:53 +01:00
|
|
|
|
{
|
|
|
|
|
parse_space (pp, end);
|
|
|
|
|
|
|
|
|
|
char quote = 0;
|
|
|
|
|
|
|
|
|
|
if (*pp < end && (**pp == '\'' || **pp == '"'))
|
|
|
|
|
{
|
|
|
|
|
quote = **pp;
|
|
|
|
|
(*pp)++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *p = *pp;
|
2018-08-09 10:16:32 +02:00
|
|
|
|
while (*pp < end && (ISALNUM(**pp) || **pp == '_'))
|
2017-01-21 05:16:53 +01:00
|
|
|
|
(*pp)++;
|
|
|
|
|
|
|
|
|
|
if (p == *pp || *pp - p > 4)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-01-21 05:30:03 +01:00
|
|
|
|
*tag = hb_tag_from_string (p, *pp - p);
|
2017-01-21 05:16:53 +01:00
|
|
|
|
|
|
|
|
|
if (quote)
|
|
|
|
|
{
|
|
|
|
|
/* CSS expects exactly four bytes. And we only allow quotations for
|
|
|
|
|
* CSS compatibility. So, enforce the length. */
|
|
|
|
|
if (*pp - p != 4)
|
|
|
|
|
return false;
|
|
|
|
|
if (*pp == end || **pp != quote)
|
|
|
|
|
return false;
|
|
|
|
|
(*pp)++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_feature_indices (const char **pp, const char *end, hb_feature_t *feature)
|
|
|
|
|
{
|
|
|
|
|
parse_space (pp, end);
|
|
|
|
|
|
|
|
|
|
bool has_start;
|
|
|
|
|
|
2018-09-11 01:26:18 +02:00
|
|
|
|
feature->start = HB_FEATURE_GLOBAL_START;
|
|
|
|
|
feature->end = HB_FEATURE_GLOBAL_END;
|
2017-01-21 05:16:53 +01:00
|
|
|
|
|
|
|
|
|
if (!parse_char (pp, end, '['))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
has_start = parse_uint (pp, end, &feature->start);
|
|
|
|
|
|
2018-10-23 12:07:48 +02:00
|
|
|
|
if (parse_char (pp, end, ':') || parse_char (pp, end, ';')) {
|
2017-01-21 05:16:53 +01:00
|
|
|
|
parse_uint (pp, end, &feature->end);
|
|
|
|
|
} else {
|
|
|
|
|
if (has_start)
|
|
|
|
|
feature->end = feature->start + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parse_char (pp, end, ']');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_feature_value_postfix (const char **pp, const char *end, hb_feature_t *feature)
|
|
|
|
|
{
|
|
|
|
|
bool had_equal = parse_char (pp, end, '=');
|
2017-06-19 12:17:09 +02:00
|
|
|
|
bool had_value = parse_uint32 (pp, end, &feature->value) ||
|
2017-01-21 05:16:53 +01:00
|
|
|
|
parse_bool (pp, end, &feature->value);
|
|
|
|
|
/* CSS doesn't use equal-sign between tag and value.
|
|
|
|
|
* If there was an equal-sign, then there *must* be a value.
|
2018-01-31 14:44:45 +01:00
|
|
|
|
* A value without an equal-sign is ok, but not required. */
|
2017-01-21 05:16:53 +01:00
|
|
|
|
return !had_equal || had_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
|
parse_one_feature (const char **pp, const char *end, hb_feature_t *feature)
|
|
|
|
|
{
|
|
|
|
|
return parse_feature_value_prefix (pp, end, feature) &&
|
2017-01-21 05:30:03 +01:00
|
|
|
|
parse_tag (pp, end, &feature->tag) &&
|
2017-01-21 05:16:53 +01:00
|
|
|
|
parse_feature_indices (pp, end, feature) &&
|
|
|
|
|
parse_feature_value_postfix (pp, end, feature) &&
|
|
|
|
|
parse_space (pp, end) &&
|
|
|
|
|
*pp == end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* hb_feature_from_string:
|
|
|
|
|
* @str: (array length=len) (element-type uint8_t): a string to parse
|
|
|
|
|
* @len: length of @str, or -1 if string is %NULL terminated
|
|
|
|
|
* @feature: (out): the #hb_feature_t to initialize with the parsed values
|
|
|
|
|
*
|
|
|
|
|
* Parses a string into a #hb_feature_t.
|
|
|
|
|
*
|
|
|
|
|
* TODO: document the syntax here.
|
|
|
|
|
*
|
|
|
|
|
* Return value:
|
|
|
|
|
* %true if @str is successfully parsed, %false otherwise.
|
|
|
|
|
*
|
|
|
|
|
* Since: 0.9.5
|
|
|
|
|
**/
|
|
|
|
|
hb_bool_t
|
|
|
|
|
hb_feature_from_string (const char *str, int len,
|
|
|
|
|
hb_feature_t *feature)
|
|
|
|
|
{
|
|
|
|
|
hb_feature_t feat;
|
|
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
|
len = strlen (str);
|
|
|
|
|
|
|
|
|
|
if (likely (parse_one_feature (&str, str + len, &feat)))
|
|
|
|
|
{
|
|
|
|
|
if (feature)
|
|
|
|
|
*feature = feat;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (feature)
|
|
|
|
|
memset (feature, 0, sizeof (*feature));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* hb_feature_to_string:
|
|
|
|
|
* @feature: an #hb_feature_t to convert
|
|
|
|
|
* @buf: (array length=size) (out): output string
|
|
|
|
|
* @size: the allocated size of @buf
|
|
|
|
|
*
|
|
|
|
|
* Converts a #hb_feature_t into a %NULL-terminated string in the format
|
|
|
|
|
* understood by hb_feature_from_string(). The client in responsible for
|
|
|
|
|
* allocating big enough size for @buf, 128 bytes is more than enough.
|
|
|
|
|
*
|
|
|
|
|
* Since: 0.9.5
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
hb_feature_to_string (hb_feature_t *feature,
|
|
|
|
|
char *buf, unsigned int size)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely (!size)) return;
|
|
|
|
|
|
|
|
|
|
char s[128];
|
|
|
|
|
unsigned int len = 0;
|
|
|
|
|
if (feature->value == 0)
|
|
|
|
|
s[len++] = '-';
|
|
|
|
|
hb_tag_to_string (feature->tag, s + len);
|
|
|
|
|
len += 4;
|
|
|
|
|
while (len && s[len - 1] == ' ')
|
|
|
|
|
len--;
|
|
|
|
|
if (feature->start != 0 || feature->end != (unsigned int) -1)
|
|
|
|
|
{
|
|
|
|
|
s[len++] = '[';
|
|
|
|
|
if (feature->start)
|
|
|
|
|
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->start));
|
|
|
|
|
if (feature->end != feature->start + 1) {
|
|
|
|
|
s[len++] = ':';
|
|
|
|
|
if (feature->end != (unsigned int) -1)
|
|
|
|
|
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->end));
|
|
|
|
|
}
|
|
|
|
|
s[len++] = ']';
|
|
|
|
|
}
|
|
|
|
|
if (feature->value > 1)
|
|
|
|
|
{
|
|
|
|
|
s[len++] = '=';
|
|
|
|
|
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%u", feature->value));
|
|
|
|
|
}
|
|
|
|
|
assert (len < ARRAY_LENGTH (s));
|
|
|
|
|
len = MIN (len, size - 1);
|
|
|
|
|
memcpy (buf, s, len);
|
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
}
|
2017-01-21 05:30:03 +01:00
|
|
|
|
|
2017-01-22 02:41:37 +01:00
|
|
|
|
/* hb_variation_t */
|
2017-01-21 05:30:03 +01:00
|
|
|
|
|
|
|
|
|
static bool
|
2017-01-22 02:41:37 +01:00
|
|
|
|
parse_variation_value (const char **pp, const char *end, hb_variation_t *variation)
|
2017-01-21 05:30:03 +01:00
|
|
|
|
{
|
|
|
|
|
parse_char (pp, end, '='); /* Optional. */
|
2017-01-22 02:41:37 +01:00
|
|
|
|
return parse_float (pp, end, &variation->value);
|
2017-01-21 05:30:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool
|
2017-01-22 02:41:37 +01:00
|
|
|
|
parse_one_variation (const char **pp, const char *end, hb_variation_t *variation)
|
2017-01-21 05:30:03 +01:00
|
|
|
|
{
|
2017-01-22 02:41:37 +01:00
|
|
|
|
return parse_tag (pp, end, &variation->tag) &&
|
|
|
|
|
parse_variation_value (pp, end, variation) &&
|
2017-01-21 05:30:03 +01:00
|
|
|
|
parse_space (pp, end) &&
|
|
|
|
|
*pp == end;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* hb_variation_from_string:
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.4.2
|
|
|
|
|
*/
|
2017-01-21 05:30:03 +01:00
|
|
|
|
hb_bool_t
|
2017-01-22 02:41:37 +01:00
|
|
|
|
hb_variation_from_string (const char *str, int len,
|
|
|
|
|
hb_variation_t *variation)
|
2017-01-21 05:30:03 +01:00
|
|
|
|
{
|
2017-01-22 02:41:37 +01:00
|
|
|
|
hb_variation_t var;
|
2017-01-21 05:30:03 +01:00
|
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
|
len = strlen (str);
|
|
|
|
|
|
2017-01-22 02:41:37 +01:00
|
|
|
|
if (likely (parse_one_variation (&str, str + len, &var)))
|
2017-01-21 05:30:03 +01:00
|
|
|
|
{
|
2017-01-22 02:41:37 +01:00
|
|
|
|
if (variation)
|
|
|
|
|
*variation = var;
|
2017-01-21 05:30:03 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-22 02:41:37 +01:00
|
|
|
|
if (variation)
|
|
|
|
|
memset (variation, 0, sizeof (*variation));
|
2017-01-21 05:30:03 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
|
/**
|
|
|
|
|
* hb_variation_to_string:
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.4.2
|
|
|
|
|
*/
|
2017-01-21 05:30:03 +01:00
|
|
|
|
void
|
2017-01-22 02:41:37 +01:00
|
|
|
|
hb_variation_to_string (hb_variation_t *variation,
|
2017-01-21 05:30:03 +01:00
|
|
|
|
char *buf, unsigned int size)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely (!size)) return;
|
|
|
|
|
|
|
|
|
|
char s[128];
|
|
|
|
|
unsigned int len = 0;
|
2017-01-22 02:41:37 +01:00
|
|
|
|
hb_tag_to_string (variation->tag, s + len);
|
2017-01-21 05:30:03 +01:00
|
|
|
|
len += 4;
|
|
|
|
|
while (len && s[len - 1] == ' ')
|
|
|
|
|
len--;
|
|
|
|
|
s[len++] = '=';
|
2018-10-04 00:44:18 +02:00
|
|
|
|
len += MAX (0, snprintf (s + len, ARRAY_LENGTH (s) - len, "%g", (double) variation->value));
|
2017-01-21 05:30:03 +01:00
|
|
|
|
|
|
|
|
|
assert (len < ARRAY_LENGTH (s));
|
|
|
|
|
len = MIN (len, size - 1);
|
|
|
|
|
memcpy (buf, s, len);
|
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
}
|
2018-07-23 22:24:26 +02:00
|
|
|
|
|
|
|
|
|
/* If there is no visibility control, then hb-static.cc will NOT
|
|
|
|
|
* define anything. Instead, we get it to define one set in here
|
|
|
|
|
* only, so only libharfbuzz.so defines them, not other libs. */
|
|
|
|
|
#ifdef HB_NO_VISIBILITY
|
|
|
|
|
#undef HB_NO_VISIBILITY
|
|
|
|
|
#include "hb-static.cc"
|
|
|
|
|
#define HB_NO_VISIBILITY 1
|
|
|
|
|
#endif
|