Add hb_shape_list_shapers()
This commit is contained in:
parent
d7bf473ef2
commit
9da554504e
|
@ -66,8 +66,16 @@ static struct static_shaper_list_t
|
||||||
{
|
{
|
||||||
char *env = getenv ("HB_SHAPER_LIST");
|
char *env = getenv ("HB_SHAPER_LIST");
|
||||||
shaper_list = NULL;
|
shaper_list = NULL;
|
||||||
if (!env || !*env)
|
if (!env || !*env) {
|
||||||
|
fallback:
|
||||||
|
ASSERT_STATIC ((ARRAY_LENGTH (shapers) + 1) * sizeof (*shaper_list) <= sizeof (static_buffer));
|
||||||
|
shaper_list = (const char **) static_buffer;
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; i < ARRAY_LENGTH (shapers); i++)
|
||||||
|
shaper_list[i] = shapers[i].name;
|
||||||
|
shaper_list[i] = NULL;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int count = 3; /* initial, fallback, null */
|
unsigned int count = 3; /* initial, fallback, null */
|
||||||
for (const char *p = env; (p == strchr (p, ',')) && p++; )
|
for (const char *p = env; (p == strchr (p, ',')) && p++; )
|
||||||
|
@ -76,7 +84,7 @@ static struct static_shaper_list_t
|
||||||
unsigned int len = strlen (env);
|
unsigned int len = strlen (env);
|
||||||
|
|
||||||
if (count > 100 || len > 1000)
|
if (count > 100 || len > 1000)
|
||||||
return;
|
goto fallback;
|
||||||
|
|
||||||
len += count * sizeof (*shaper_list) + 1;
|
len += count * sizeof (*shaper_list) + 1;
|
||||||
char *buffer = len < sizeof (static_buffer) ? static_buffer : (char *) malloc (len);
|
char *buffer = len < sizeof (static_buffer) ? static_buffer : (char *) malloc (len);
|
||||||
|
@ -100,7 +108,13 @@ static struct static_shaper_list_t
|
||||||
|
|
||||||
const char **shaper_list;
|
const char **shaper_list;
|
||||||
char static_buffer[32];
|
char static_buffer[32];
|
||||||
} env_shaper_list;
|
} static_shaper_list;
|
||||||
|
|
||||||
|
const char **
|
||||||
|
hb_shape_list_shapers (void)
|
||||||
|
{
|
||||||
|
return static_shaper_list.shaper_list;
|
||||||
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_shape_full (hb_font_t *font,
|
hb_shape_full (hb_font_t *font,
|
||||||
|
@ -111,7 +125,7 @@ hb_shape_full (hb_font_t *font,
|
||||||
const char **shaper_list)
|
const char **shaper_list)
|
||||||
{
|
{
|
||||||
if (likely (!shaper_list))
|
if (likely (!shaper_list))
|
||||||
shaper_list = env_shaper_list.shaper_list;
|
shaper_list = static_shaper_list.shaper_list;
|
||||||
|
|
||||||
if (likely (!shaper_list)) {
|
if (likely (!shaper_list)) {
|
||||||
for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++)
|
for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++)
|
||||||
|
|
|
@ -56,6 +56,9 @@ hb_shape_full (hb_font_t *font,
|
||||||
const char *shaper_options,
|
const char *shaper_options,
|
||||||
const char **shaper_list);
|
const char **shaper_list);
|
||||||
|
|
||||||
|
const char **
|
||||||
|
hb_shape_list_shapers (void);
|
||||||
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,11 @@ TEST_PROGS = \
|
||||||
test-version \
|
test-version \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
if HAVE_OT
|
||||||
TEST_PROGS += \
|
TEST_PROGS += \
|
||||||
test-ot-tag \
|
test-ot-tag \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
# Tests for header compilation
|
# Tests for header compilation
|
||||||
TEST_PROGS += \
|
TEST_PROGS += \
|
||||||
|
|
|
@ -43,6 +43,14 @@
|
||||||
#include <hb-ft.h>
|
#include <hb-ft.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_OT
|
||||||
|
#include <hb-ot.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISCRIBE
|
||||||
|
#include <hb-uniscribe.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,6 +138,18 @@ test_shape (void)
|
||||||
hb_font_destroy (font);
|
hb_font_destroy (font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_shape_list (void)
|
||||||
|
{
|
||||||
|
const char **shapers = hb_shape_list_shapers ();
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
|
for (i = 0; shapers[i]; i++)
|
||||||
|
;
|
||||||
|
|
||||||
|
g_assert_cmpint (i, >, 1);
|
||||||
|
g_assert (!strcmp (shapers[i - 1], "fallback"));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
|
@ -145,6 +157,9 @@ main (int argc, char **argv)
|
||||||
hb_test_init (&argc, &argv);
|
hb_test_init (&argc, &argv);
|
||||||
|
|
||||||
hb_test_add (test_shape);
|
hb_test_add (test_shape);
|
||||||
|
/* TODO test fallback shaper */
|
||||||
|
/* TODO test shaper_full */
|
||||||
|
hb_test_add (test_shape_list);
|
||||||
|
|
||||||
return hb_test_run();
|
return hb_test_run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue