summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2021-05-14 02:05:45 +0300
committerOleg Oshmyan <chortos@inbox.lv>2021-09-09 02:32:49 +0300
commit8ed2a2f033207a5611691710e58a297f70410c50 (patch)
treef840da472ccb2c5eaf8ff60cf35357bd501ec107
parent5fa07dd5d0fd37534047cfdb79f4e75a864437c7 (diff)
downloadlibass-8ed2a2f033207a5611691710e58a297f70410c50.tar.bz2
libass-8ed2a2f033207a5611691710e58a297f70410c50.tar.xz
shaper: skip invisible characters earlier
Currently, this move does not affect functionality, as both shapers ignore `skip` on input, and the complex shaper resets `skip` on output. Later commits will use this `skip` flag to guide shaping run splitting and font fallback before shaping happens.
-rw-r--r--libass/ass_shaper.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
index 3c69548..960dab1 100644
--- a/libass/ass_shaper.c
+++ b/libass/ass_shaper.c
@@ -792,6 +792,28 @@ void ass_shaper_set_kerning(ASS_Shaper *shaper, bool kern)
}
/**
+ * \brief Remove all zero-width invisible characters from the text.
+ */
+static void ass_shaper_skip_characters(GlyphInfo *glyphs, size_t len)
+{
+ for (int i = 0; i < len; i++) {
+ // Skip direction override control characters
+ if ((glyphs[i].symbol <= 0x202e && glyphs[i].symbol >= 0x202a)
+ || (glyphs[i].symbol <= 0x200f && glyphs[i].symbol >= 0x200b)
+ || (glyphs[i].symbol <= 0x206f && glyphs[i].symbol >= 0x2060)
+ || (glyphs[i].symbol <= 0xfe0f && glyphs[i].symbol >= 0xfe00)
+ || (glyphs[i].symbol <= 0xe01ef && glyphs[i].symbol >= 0xe0100)
+ || (glyphs[i].symbol <= 0x180f && glyphs[i].symbol >= 0x180b)
+ || glyphs[i].symbol == 0x061c
+ || glyphs[i].symbol == 0xfeff
+ || glyphs[i].symbol == 0x00ad
+ || glyphs[i].symbol == 0x034f) {
+ glyphs[i].skip = true;
+ }
+ }
+}
+
+/**
* \brief Find shape runs according to the event's selected fonts
*/
void ass_shaper_find_runs(ASS_Shaper *shaper, ASS_Renderer *render_priv,
@@ -801,6 +823,7 @@ void ass_shaper_find_runs(ASS_Shaper *shaper, ASS_Renderer *render_priv,
int shape_run = 0;
ass_shaper_determine_script(shaper, glyphs, len);
+ ass_shaper_skip_characters(glyphs, len);
// find appropriate fonts for the shape runs
for (i = 0; i < len; i++) {
@@ -865,32 +888,6 @@ void ass_shaper_set_bidi_brackets(ASS_Shaper *shaper, bool match_brackets)
#endif
/**
- * \brief Remove all zero-width invisible characters from the text.
- * \param text_info text
- */
-static void ass_shaper_skip_characters(TextInfo *text_info)
-{
- int i;
- GlyphInfo *glyphs = text_info->glyphs;
-
- for (i = 0; i < text_info->length; i++) {
- // Skip direction override control characters
- if ((glyphs[i].symbol <= 0x202e && glyphs[i].symbol >= 0x202a)
- || (glyphs[i].symbol <= 0x200f && glyphs[i].symbol >= 0x200b)
- || (glyphs[i].symbol <= 0x206f && glyphs[i].symbol >= 0x2060)
- || (glyphs[i].symbol <= 0xfe0f && glyphs[i].symbol >= 0xfe00)
- || (glyphs[i].symbol <= 0xe01ef && glyphs[i].symbol >= 0xe0100)
- || (glyphs[i].symbol <= 0x180f && glyphs[i].symbol >= 0x180b)
- || glyphs[i].symbol == 0x061c
- || glyphs[i].symbol == 0xfeff
- || glyphs[i].symbol == 0x00ad
- || glyphs[i].symbol == 0x034f) {
- glyphs[i].skip = true;
- }
- }
-}
-
-/**
* \brief Shape an event's text. Calculates directional runs and shapes them.
* \param text_info event's text
* \return success, when 0
@@ -937,7 +934,6 @@ bool ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info)
switch (shaper->shaping_level) {
case ASS_SHAPING_SIMPLE:
shape_fribidi(shaper, glyphs, text_info->length);
- ass_shaper_skip_characters(text_info);
return true;
case ASS_SHAPING_COMPLEX:
default: