diff options
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-shape.cc')
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-shape.cc | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-shape.cc b/src/3rdparty/harfbuzz-ng/src/hb-shape.cc index 39355b337d..cf4e1525a2 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-shape.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-shape.cc @@ -26,35 +26,70 @@ * Google Author(s): Behdad Esfahbod */ -#include "hb-private.hh" +#include "hb.hh" + +#include "hb-shaper.hh" +#include "hb-shape-plan.hh" +#include "hb-buffer.hh" +#include "hb-font.hh" +#include "hb-machinery.hh" -#include "hb-shaper-private.hh" -#include "hb-shape-plan-private.hh" -#include "hb-buffer-private.hh" -#include "hb-font-private.hh" /** * SECTION:hb-shape - * @title: Shaping + * @title: hb-shape * @short_description: Conversion of text strings into positioned glyphs * @include: hb.h * * Shaping is the central operation of HarfBuzz. Shaping operates on buffers, * which are sequences of Unicode characters that use the same font and have - * the same text direction, script and language. After shaping the buffer + * the same text direction, script, and language. After shaping the buffer * contains the output glyphs and their positions. **/ -static const char **static_shaper_list; -#ifdef HB_USE_ATEXIT +#if HB_USE_ATEXIT +static void free_static_shaper_list (); +#endif + +static const char *nil_shaper_list[] = {nullptr}; + +static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t<const char *, + hb_shaper_list_lazy_loader_t> +{ + static const char ** create () + { + const char **shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *)); + if (unlikely (!shaper_list)) + return nullptr; + + const hb_shaper_entry_t *shapers = _hb_shapers_get (); + unsigned int i; + for (i = 0; i < HB_SHAPERS_COUNT; i++) + shaper_list[i] = shapers[i].name; + shaper_list[i] = nullptr; + +#if HB_USE_ATEXIT + atexit (free_static_shaper_list); +#endif + + return shaper_list; + } + static void destroy (const char **l) + { free (l); } + static const char ** get_null () + { return nil_shaper_list; } +} static_shaper_list; + +#if HB_USE_ATEXIT static -void free_static_shaper_list (void) +void free_static_shaper_list () { - free (static_shaper_list); + static_shaper_list.free_instance (); } #endif + /** * hb_shape_list_shapers: * @@ -66,37 +101,9 @@ void free_static_shaper_list (void) * Since: 0.9.2 **/ const char ** -hb_shape_list_shapers (void) +hb_shape_list_shapers () { -retry: - const char **shaper_list = (const char **) hb_atomic_ptr_get (&static_shaper_list); - - if (unlikely (!shaper_list)) - { - /* Not found; allocate one. */ - shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *)); - if (unlikely (!shaper_list)) { - static const char *nil_shaper_list[] = {nullptr}; - return nil_shaper_list; - } - - const hb_shaper_pair_t *shapers = _hb_shapers_get (); - unsigned int i; - for (i = 0; i < HB_SHAPERS_COUNT; i++) - shaper_list[i] = shapers[i].name; - shaper_list[i] = nullptr; - - if (!hb_atomic_ptr_cmpexch (&static_shaper_list, nullptr, shaper_list)) { - free (shaper_list); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_static_shaper_list); /* First person registers atexit() callback. */ -#endif - } - - return shaper_list; + return static_shaper_list.get_unconst (); } @@ -147,7 +154,9 @@ hb_shape_full (hb_font_t *font, * * Shapes @buffer using @font turning its Unicode characters content to * positioned glyphs. If @features is not %NULL, it will be used to control the - * features applied during shaping. + * features applied during shaping. If two @features have the same tag but + * overlapping ranges the value of the feature with the higher index takes + * precedence. * * Since: 0.9.2 **/ |