From 4bec78fbaffd09791c09157be3dc96161c668ebe Mon Sep 17 00:00:00 2001 From: Kylart Date: Wed, 20 Jun 2018 00:26:51 +0900 Subject: [PATCH] Fix handling of alignment tag yet again --- assets/subtitle-parser/ass/tags.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/subtitle-parser/ass/tags.js b/assets/subtitle-parser/ass/tags.js index 9143e94..b2a7f9a 100644 --- a/assets/subtitle-parser/ass/tags.js +++ b/assets/subtitle-parser/ass/tags.js @@ -308,16 +308,25 @@ const handleAlignment = (cue, style, info) => { cue.position = (left + 100 - right) / 2 cue.horiz = 'left' cue.align = -50 + cue.textAlign = 'center' } else { const isLeft = alignDir.left.includes(align) cue.position = isLeft ? left : right cue.horiz = isLeft ? 'left' : 'right' + cue.align = 0 + cue.textAlign = cue.horiz } // Vertical - cue.line = vert - cue.vert = alignDir.top.includes(align) ? 'top' : 'bottom' - cue.vAlign = alignDir.vCenter.includes(align) ? 50 : 0 + if (alignDir.vCenter.includes(align)) { + cue.vAlign = 50 + cue.vert = 'bottom' + cue.line = 50 + } else { + cue.vAlign = 0 + cue.line = vert + cue.vert = alignDir.top.includes(align) ? 'top' : 'bottom' + } cue.text = string.replace(re.alignment, '') }