summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2020-11-14 00:41:54 +0200
committerOleg Oshmyan <chortos@inbox.lv>2021-04-29 03:15:40 +0300
commita2663bc3b24925df64dd81d7391928294661b47e (patch)
tree455a3cb31d87fc1d2625bb0ca15d277946f6a127
parent3f95d1701159e86b75dc49c8eaa1dfc03819bc32 (diff)
downloadlibass-a2663bc3b24925df64dd81d7391928294661b47e.tar.bz2
libass-a2663bc3b24925df64dd81d7391928294661b47e.tar.xz
Skip glyphs with \fscx0 or \fscy0 after layout
These glyphs are effectively invisible. VSFilter draws no border around them, either (because for BorderStyle 1 it finds no pixels to draw a border around, while BorderStyle 3 gets scaled a second time by the same \fscx or \fscy), except current MPC-HC (which doesn't double-scale BorderStyle 3). Since nothing is to be seen on screen, skip the rest of the pipeline altogether. They still affect the layout of other glyphs that may have nonzero scales, so we can only do this after text layout is done. This avoids subsequent divisions by zero when sheared pre-scale coordinates are computed from post-scale coordinates at scale zero. (We eagerly scale all coordinates before shearing because it makes text layout easier.) In apply_baseline_shear itself, the shear displacement for an \fscy0 glyph is always zero, so skipping its calculation is safe. For an \fscx0 glyph, we currently divide 0 by 0, which we want to avoid. Logically, this is supposed to take the cluster's pre-\fscx advance and compute shear from that, but this commit does not do this. When in VSFilter-compatible mode, we're actually supposed to reset the baseline when \fscx becomes nonzero, so this won't matter. Meanwhile, when we're trying to do a "sensible" thing, it's not clear whether shear-before-scale makes sense in the first place. At any rate, this improves upon the current behavior by avoiding the zero division, and at least on x86 this actually happens to match our current layouts in situations where the current code produces visible output at all. Fixes https://github.com/libass/libass/issues/185. Fixes https://github.com/libass/libass/issues/413. Fixes https://github.com/libass/libass/issues/428. Fixes https://github.com/libass/libass/issues/443.
-rw-r--r--libass/ass_render.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 058e0ac..7ccd5a8 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -2139,6 +2139,8 @@ static void apply_baseline_shear(ASS_Renderer *render_priv)
if (text_info->glyphs[i].linebreak || last_fay != info->fay)
shear = 0;
last_fay = info->fay;
+ if (!info->scale_x || !info->scale_y)
+ info->skip = true;
if (info->skip)
continue;
for (GlyphInfo *cur = info; cur; cur = cur->next)