summaryrefslogtreecommitdiffstats
path: root/libass/ass_shaper.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2012-10-01 17:37:00 +0200
committerGrigori Goronzy <greg@blackbox>2012-10-01 17:37:00 +0200
commit840ce4c2d9381e340c3239d104933fea85fff3e5 (patch)
treec113cc481f569a9e6e253db40b94cc7775761c55 /libass/ass_shaper.c
parent146d60f698e9a5ef79e68a27e768d2f4dd40068d (diff)
downloadlibass-840ce4c2d9381e340c3239d104933fea85fff3e5.tar.bz2
libass-840ce4c2d9381e340c3239d104933fea85fff3e5.tar.xz
shaper: add UCDN support
Add explicit support for UCDN, without relying on any HarfBuzz integration. This finally allows easy usage of HarfBuzz without glib, ICU, or some other big bloated library!
Diffstat (limited to 'libass/ass_shaper.c')
-rw-r--r--libass/ass_shaper.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
index 89ea97a..16f1c35 100644
--- a/libass/ass_shaper.c
+++ b/libass/ass_shaper.c
@@ -29,6 +29,9 @@
#define MAX_RUNS 50
#ifdef CONFIG_HARFBUZZ
+#ifdef CONFIG_UCDN
+#include "hb-ucdn.h"
+#endif
#include <hb-ft.h>
enum {
VERT = 0,
@@ -57,6 +60,7 @@ struct ass_shaper {
// Glyph metrics cache, to speed up shaping
Cache *metrics_cache;
+ hb_unicode_funcs_t *unicode_funcs;
#endif
};
@@ -108,6 +112,9 @@ void ass_shaper_free(ASS_Shaper *shaper)
{
#ifdef CONFIG_HARFBUZZ
ass_cache_done(shaper->metrics_cache);
+#ifdef CONFIG_UCDN
+ hb_unicode_funcs_destroy(shaper->unicode_funcs);
+#endif
free(shaper->features);
#endif
free(shaper->event_text);
@@ -435,6 +442,9 @@ static void shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
runs[run].buf = hb_buffer_create();
runs[run].font = get_hb_font(shaper, glyphs + k);
set_run_features(shaper, glyphs + k);
+#ifdef CONFIG_UCDN
+ hb_buffer_set_unicode_funcs(runs[run].buf, shaper->unicode_funcs);
+#endif
hb_buffer_pre_allocate(runs[run].buf, i - k + 1);
hb_buffer_set_direction(runs[run].buf, direction ? HB_DIRECTION_RTL :
HB_DIRECTION_LTR);
@@ -662,6 +672,9 @@ ASS_Shaper *ass_shaper_new(size_t prealloc)
#ifdef CONFIG_HARFBUZZ
init_features(shaper);
shaper->metrics_cache = ass_glyph_metrics_cache_create();
+#ifdef CONFIG_UCDN
+ shaper->unicode_funcs = hb_ucdn_make_unicode_funcs();
+#endif
#endif
return shaper;