New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kerning is ignored between tags #648
Comments
Use VLC 3.0.18-rc or 3.0.16 (or a non-Windows VLC 3.0.17, or another player such as mpv). Generally, everything in ASS is terminated at override tags. What is your use case: are you making a subtitle file for public distribution, or is this an internal on-the-fly representation in a karaoke program of some sort? If it’s the former (and the fact you’re testing in VLC suggests it is), it’s impossible to achieve portable kerning across karaoke (or other) tags anyway, so your only option is to explicitly position the word parts, as horrible as that sounds. And you also need to add an invisible “complex-layout” character such as U+200B ZERO WIDTH SPACE to each (!) chunk to trigger kerning in non-libass renderers within those chunks. But if it’s the latter, we could in theory kern across tags when Lines 901 to 903 in 5b0dba4
except However, this would also break ligatures: consider
In a font with an “ffi” ligature, which are common, shaping across the karaoke tag would cause the whole “ffi” sequence to be a single glyph. We couldn’t paint the first “f” in one colour and the remaining “fi” in a different colour. So we’d have to display this as if it were this:
which is considerably different. This is, in fact, what happens in Web browsers: see for yourself. But I’m not sure this is a very good example to follow. |
Minor correction: that only appeas to apply to Blink-based browsers like Chromium (and for full transparency, I tested this with |
Thanks! Worth nothing that WebKit (based on a Safari 13 test on Catalina… the newest I could easily get my hands on via an online testing service) also doesn’t apply kerning in that case, just like libass. |
Thank you for the detailed answer! My use case is similar to the latter, I render the subtitles using ffmpeg I think, the best would be to support kerning between tags if this is set by the user using a property. Regarding ligatures, for some languages or fonts they are very important, and I understand that supporting ligatures between tags is even more difficult but But this again looks like a complex task and the easiest method would probably be enough. I think supporting ligatures between tags and then coloring only the whole ligature at once |
By the way… You showed an example with italics, but how do you even expect it to work? The italic font and the upright font are two different font faces. There literally is no kerning defined between an upright |
No, they are the same font. It's faked italics by angle (and thus there is kerning defined). But this was obviously just an example to show that tags break kerning in general. Maybe it does not make sense for some tags, but for the |
Hmm, I’ve just noticed another curious thing. I have no idea what exactly is going on here, but Chromium (Edge) is letting me select “f” and “i” separately when selecting text that displays the “fi” ligature, even if it’s |
Still no plans to implement this soon, but for posterity: it turns out some fonts have a Ligature Caret List table that HarfBuzz exposes via When the table is absent (or presumably when we can’t make sense of it because the number of caret points differs from the number of clusters we got), back in 2012 Behdad recommended splitting the width into equal parts (and opposed the idea of trying to look up the individual glyphs and making the split proportional to their widths). (I’m confused by the comment about kerning in HarfBuzz’s doc, though. It was first mentioned here but was never explained in detail. I don’t understand how kerning is relevant.) |
With
Kerning: yes
under[Script Info]
, the kerning normally renders as expected, but in karaoke mode between the syllables it seems it's ignored or at least extra space is added (tested with VLC and ffmpeg). I think, that's a bug or is there some extra setting likeKerningKaraoke: yes
which can activate this?The same applies to ligatures, but there it's
probablymaybe expected because the color border inside the ligature would not be clear. But with kerning it is clear, I think.Edit: it seems to be ignored between tags in general, probably the parser should understand that a word can still be a whole word, when there is a tag inside it.
Missing kerning between syllables
Only the second word has the expected kerning, because it has not tags in it.
Source code:
Missing kerning between tags (here italics)
Here, both words have ignored the kerning.
Source code:
I also tried the underscore tag, but VLC crashed immediately there.
The text was updated successfully, but these errors were encountered: