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

\h fallback messes up positioning #42

Open
rcombs opened this issue Feb 9, 2014 · 14 comments
Open

\h fallback messes up positioning #42

rcombs opened this issue Feb 9, 2014 · 14 comments

Comments

@rcombs
Copy link
Member

rcombs commented Feb 9, 2014

libass:

xy-vs:
d6e625c3e6121e698a695be388fb0565

File is 9AD4509C

Dialogue: 0,0:03:58.53,0:04:02.02,Sign-SaberWork,,0,0,0,,{\fad(0,745)\frz2.5\fax0.05\fscx81\fscy80\1a&H00&\4c&HFFFEFF\3a&H00&\bord4\fsp15\b1\blur1\c&HEFB94C&\pos(325,767)\3c&HEFB94C&}Saber
Dialogue: 1,0:03:58.53,0:04:02.32,Sign-SaberWork2,,0,0,0,,{\fad(0,745)\frz2.5\fax0.05\fscx96\fscy92\1a&H00&\b1\blur0.5\bord6\pos(444,835)\c&HFFFFFF&\3c&HEFB94C&}Saber{\alpha&HFF&}\h\h\h\h\h\h\h\N{\alpha&H00&}at Work
Dialogue: 2,0:03:58.53,0:04:02.32,Sign-SaberWork2,,0,0,0,,{\fad(0,745)\frz2.5\fax0.025\fscx94\fscy91\1a&HFF&\b1\blur1\bord2\pos(444,835)\c&HFFFFFF&\3c&HFDE882&}Sa{\alpha&H2F&\1a&HFF&}be{\alpha&H50&\1a&HFF&}r{\alpha&HFF&}\h\h\h\h\h\h\h\N{\alpha&H00&\1a&HFF&}at {\alpha&H1F&\1a&HFF&}Wo{\alpha&H40&\1a&HFF&\bord0.5\3c&HFEF7C2&}rk
@astiob
Copy link
Member

astiob commented Feb 9, 2014

Sign-SaberWork is right- or middle-aligned? Duplicate of (the remaining sub-issue of) #16.

@rcombs
Copy link
Member Author

rcombs commented Feb 9, 2014

Style: Sign-SaberWork,Embryonic Inside-Mod,160,&H00FFFFFF,&H000000FF,&H00FFFFFF,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1
Style: Sign-SaberWork2,Embryonic Inside,160,&H00FFFFFF,&H000000FF,&H00FFFFFF,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,5,10,10,10,1

@astiob
Copy link
Member

astiob commented Feb 9, 2014

Yeah, I’d just compared the \pos to the screenshot and deduced it was \an5 when you replied. You haven’t copied enough “Saber” lines to be completely sure, but it must be #16.

@rcombs
Copy link
Member Author

rcombs commented Feb 9, 2014

those are the only lines with the SaberWork styles in the script.

@astiob
Copy link
Member

astiob commented Feb 9, 2014

Yeah, that was a derp.

I’m struggling to understand which line produces which part of the image. What I can say for sure is that the first line definitely has \fsp and thus definitely is misplaced as in #16.

@astiob
Copy link
Member

astiob commented Feb 11, 2014

What happens in VSFilter:

  1. VSFilter translates the \h used in the script to U+00A0.
  2. VSFilter selects the font specified in the script, Embryonic Inside.
  3. VSFilter calls GDI’s TextOut function to get the outline for the glyph run containing the U+00A0.
  4. GDI does not find U+00A0 in the currently selected font.
  5. ??? Another font is selected.
  6. GDI uses the U+00A0 outline from the other font.

What currently happens in libass:

  1. ass_parse selects the font specified in the script, Embryonic Inside.
  2. ass_parse translates the \h used in the script to U+00A0.
  3. ass_font translates U+00A0 to U+0020 “to avoid problems”.
  4. ass_font happily finds U+0020 in the currently selected font.
  5. libass uses the U+0020 outline from Embryonic Inside.

Two things need to be done:

@grigorig
Copy link
Member

Interesting. I added this substitution not for fun though, but to avoid rendering issues with various scripts. But that was back in 2009, libass has changed a whole lot since then.

astiob added a commit to astiob/libass that referenced this issue Feb 11, 2014
\h is often used in typesetting purely for horizontal padding.
This relies on its metrics being known. VSFilter uses the NBSP glyph
directly and substitutes Arial if it does not exist in the given
font. The previous commit dealt with the Arial substitution,
so what remains now is only to use NBSP directly.

This reverts commit 33a3ab2.
This fixes libass#42.
astiob added a commit to astiob/libass that referenced this issue Feb 12, 2014
\h is often used in typesetting purely for horizontal padding.
This relies on its metrics being known. VSFilter uses the NBSP glyph
directly and substitutes Arial if it does not exist in the given
font. The previous commit dealt with the Arial substitution,
so what remains now is only to use NBSP directly.

This reverts commit 33a3ab2.
This fixes libass#42.
@astiob astiob added the fonts label Feb 12, 2014
@astiob astiob removed their assignment Feb 16, 2014
astiob added a commit to astiob/libass that referenced this issue May 13, 2014
\h is often used in typesetting purely for horizontal padding.
This relies on its metrics being known. VSFilter uses the NBSP
glyph directly and substitutes Arial if it does not exist in
the given font. This commit adds the same behavior to libass.

This does not make our font selection closer to VSFilter's
in the general case. However, \h is particularly common
and sensitive, so this commit fixes is at a special case.

Part of this commit reverts commit
33a3ab2.

Fixes libass#2.
Fixes libass#42.
@astiob
Copy link
Member

astiob commented May 13, 2014

The \h issue is also very visible in JoJo’s (and probably Commie’s) JoJo episode 20 at 12:44.

Also, sorry for the “referenced this issue from a commit” spam! ._. GitHub adds one every single time I push a rebased or reworded or very slightly modified commit. I wish it would just delete the previous “referenced” line when it does that.

astiob added a commit to astiob/libass that referenced this issue May 13, 2014
\h is often used in typesetting purely for horizontal padding.
This relies on its metrics being known. VSFilter uses the NBSP
glyph directly and substitutes Arial if it does not exist in
the given font. This commit adds the same behavior to libass.

This does not make our font selection closer to VSFilter's
in the general case. However, \h is particularly common
and sensitive, so this commit fixes is at a special case.

Fixes libass#2.
Fixes libass#42.
astiob added a commit to astiob/libass that referenced this issue May 13, 2014
\h is often used in typesetting purely for horizontal padding.
This relies on its metrics being known. VSFilter uses the NBSP
glyph directly and substitutes Arial if it does not exist in
the given font. This commit adds the same behavior to libass.

This does not make our font selection closer to VSFilter's
in the general case. However, \h is particularly common
and sensitive, so this commit fixes it especially.

Fixes libass#2.
Fixes libass#42.
@rcombs
Copy link
Member Author

rcombs commented Apr 2, 2020

This looks to be fixed by @astiob's 2014 commit, or at least the sign looks pretty sensible now and I vaguely recall it being a fine mess:
image

@rcombs rcombs closed this as completed Apr 2, 2020
@astiob
Copy link
Member

astiob commented Apr 2, 2020

That commit never landed in master. (Maybe I was afraid to suggest we seriously make master always fall back on Arial. Maybe I was worried about glyphs not supported by Arial.)

This is what the Carnival Phantasm sample looks like in VSFilter:
9AD4509C mkv_snapshot_03 58_ 2020 04 03_02 56 09

@astiob astiob reopened this Apr 2, 2020
@astiob astiob changed the title Carnival Phantasm positioning issue \h fallback messes up positioning Apr 2, 2020
@astiob
Copy link
Member

astiob commented Apr 3, 2020

And the JoJo sample:

VSFilter screenshot

libass screenshot

@astiob

This comment was marked as outdated.

@astiob
Copy link
Member

astiob commented Nov 12, 2022

As tracked in #550, this probably depends on the \fe and/or the user’s locale (or more pertinently, the subtitle author’s locale, which might be estimated using the track’s language if we ever start getting language information from demuxers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@astiob @rcombs @grigorig and others