#include <sys/stat.h>
#include <unistd.h>
#include <inttypes.h>
+#include <ctype.h>
#ifdef CONFIG_ICONV
#include <iconv.h>
}
free(track->style_format);
free(track->event_format);
+ free(track->Language);
if (track->styles) {
for (i = 0; i < track->n_styles; ++i)
ass_free_style(track, i);
track->ScaledBorderAndShadow = parse_bool(str + 22);
} else if (!strncmp(str, "Kerning:", 8)) {
track->Kerning = parse_bool(str + 8);
+ } else if (!strncmp(str, "Language:", 9)) {
+ char *p = str + 9;
+ while (*p && isspace(*p)) p++;
+ track->Language = malloc(3);
+ strncpy(track->Language, p, 2);
+ track->Language[2] = 0;
}
return 0;
}
render_priv->border_scale = 1.;
ass_shaper_set_kerning(render_priv->shaper, track->Kerning);
+ if (track->Language)
+ ass_shaper_set_language(render_priv->shaper, track->Language);
// PAR correction
render_priv->font_scale_x = render_priv->settings.aspect /
// OpenType features
int n_features;
hb_feature_t *features;
+ hb_language_t language;
// Glyph metrics cache, to speed up shaping
Cache *metrics_cache;
};
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,
shaper->base_direction = 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
void ass_shaper_find_runs(ASS_Shaper *shaper, ASS_Renderer *render_priv,
GlyphInfo *glyphs, size_t len);
void ass_shaper_set_base_direction(ASS_Shaper *shaper, FriBidiParType dir);
+void ass_shaper_set_language(ASS_Shaper *shaper, const char *code);
void ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info);
void ass_shaper_cleanup(ASS_Shaper *shaper, TextInfo *text_info);
FriBidiStrIndex *ass_shaper_reorder(ASS_Shaper *shaper, TextInfo *text_info);
int WrapStyle;
int ScaledBorderAndShadow;
int Kerning;
+ char *Language;
int default_style; // index of default style
char *name; // file name in case of external subs, 0 for streams