Skip to content
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

Subtitles without spaces do not break to a new line when overfull #360

Closed
svenper opened this issue Nov 17, 2019 · 3 comments · Fixed by #486
Closed

Subtitles without spaces do not break to a new line when overfull #360

svenper opened this issue Nov 17, 2019 · 3 comments · Fixed by #486
Labels

Comments

@svenper
Copy link

svenper commented Nov 17, 2019

by way of mpv-player/mpv#7158 :

Expected behavior

Subtitle lines without spaces (Chinese, Japanese, etc.) wrap automatically when too long.

Actual behavior

Such lines extend outside the window, with characters cropped.

See e.g. at 43:00 in sub.ass with a large font size:

Dialogue: 0,0:43:00.01,0:43:06.16,Default,,0,0,0,,任何一个有远大抱负的男人都不会因为区区一个女人

(Many lines in the subtitles do indeed have spaces between short phrases, which is an exeption to the rule in East Asian scripts.)

@siikamiika
Copy link

Found this function while investigating this myself:

wrap_lines_smart(ASS_Renderer *render_priv, double max_text_width)

I'd implement line breaking so that first priority would be for spaces as listed here, and if the line would still be too long I would break before any CJK character that goes above max_text_width.

However, I see the problem that the function loops the text char by char instead of unicode characters. I'm not sure if it can be assumed to be UTF-8.

@ghost
Copy link

ghost commented Feb 15, 2020

It's definitely UTF-8, except when it's not. The latter could happen if an .ass file contains invalid UTF-8 sequences, but then libass doesn't need to render anything sane. But it shouldn't crash or so.
Due to the properties of UTF-8, looping by char is not a problem. If you need to skip codepoints that consist of multiple bytes, then I guess the current code structure is going to be very annoying.

@ghost
Copy link

ghost commented Feb 15, 2020

PS: if you haven't seen it yet, ass_utf8_get_char should be useful to compute the length of UTF-8 sequences (although there are faster methods if you don't need the codepoint itself).

cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

As opposed to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much
simpler: we just split in any case where we will overflow the buffer as
a last resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

As opposed to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much
simpler: we just split in any case where we will overflow the buffer as
a last resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

As opposed to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much
simpler: we just split in any case where we will overflow the buffer as
a last resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

As opposed to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much
simpler: we just split in any case where we will overflow the buffer as
a last resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Comapred to libass#372, which is
CJK-specific and seems pretty stalled, this pull request is much simpler
(but complementary): we just split in any case where we will overflow
the buffer as a last resort. Cases like
mpv-player/mpv#8115 demonstrate demand for
this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is
CJK-specific, this pull request is much simpler (but complementary): we
just split in any case where we will overflow the buffer as a last
resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 3, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is
CJK-specific, this pull request is much simpler (but complementary): we
just split in any case where we will overflow the buffer as a last
resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 4, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is
CJK-specific, this pull request is much simpler (but complementary): we
just split in any case where we will overflow the buffer as a last
resort. Cases like mpv-player/mpv#8115
demonstrate demand for this even outside of CJK character context.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 4, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is about
Unicode line breaking, this pull request is much simpler (but
complementary): we just split in any case where we will overflow the
buffer as a last resort.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 5, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is about
Unicode line breaking, this pull request is much simpler (but
complementary): we just split in any case where we will overflow the
buffer as a last resort.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
cdown added a commit to cdown/libass that referenced this issue Mar 5, 2021
It's pretty common (in Chinese/Japanese/Korean especially) to not have
any spaces to split on. Currently, these cases simply overflow the
render area.

If this happens, try a last ditch attempt to wrap at the last character
seen. This dramatically improves the usability of long subtitles with no
clear break point.

Compared to libass#372, which is about
Unicode line breaking, this pull request is much simpler (but
complementary): we just split in any case where we will overflow the
buffer as a last resort.

Example previous issues which show demand for this behaviour:

- mpv-player/mpv#8115
- mpv-player/mpv#2203
- libass#348
- libass#360
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants