diff options
author | Grigori Goronzy <greg@blackbox> | 2011-08-01 15:51:27 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2011-08-01 15:51:27 +0200 |
commit | c979365946b2dc2499ede862b6f7da15f9bc0ed1 (patch) | |
tree | 688d0ecc6d17dbdd2df22719a2702ecba29a8b69 /libass/ass_shaper.c | |
parent | d7544850775344879dd3049046c5b7ce2d52d3b3 (diff) | |
download | libass-c979365946b2dc2499ede862b6f7da15f9bc0ed1.tar.bz2 libass-c979365946b2dc2499ede862b6f7da15f9bc0ed1.tar.xz |
Support language hint in the Script Info section
Parse a hint in the form "Language: xx" with xx being an ISO 639-1
language code, and pass it to HarfBuzz. This can be useful to render
scripts with language-specific character variants.
Diffstat (limited to 'libass/ass_shaper.c')
-rw-r--r-- | libass/ass_shaper.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 15dc549..16026f5 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -45,6 +45,7 @@ struct ass_shaper { // OpenType features int n_features; hb_feature_t *features; + hb_language_t language; // Glyph metrics cache, to speed up shaping Cache *metrics_cache; }; @@ -428,6 +429,7 @@ static void shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len) set_run_features(shaper, glyphs + k); hb_buffer_set_direction(runs[run].buf, direction ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); + hb_buffer_set_language(runs[run].buf, shaper->language); hb_buffer_add_utf32(runs[run].buf, shaper->event_text + k, i - k + 1, 0, i - k + 1); hb_shape(runs[run].font, runs[run].buf, shaper->features, @@ -559,6 +561,17 @@ void ass_shaper_set_base_direction(ASS_Shaper *shaper, FriBidiParType dir) } /** + * \brief Set language hint. Some languages have specific character variants, + * like Serbian Cyrillic. + * \param lang ISO 639-1 two-letter language code + */ +void ass_shaper_set_language(ASS_Shaper *shaper, const char *code) +{ + printf("setting language to '%s'\n", code); + shaper->language = hb_language_from_string(code); +} + +/** * \brief Shape an event's text. Calculates directional runs and shapes them. * \param text_info event's text */ |