JavascriptSubtitlesOctopus icon indicating copy to clipboard operation
JavascriptSubtitlesOctopus copied to clipboard

Allow updating the available font list

Open adamunion opened this issue 6 years ago • 3 comments

If I initialize an instance with the subUrl option and a given font, JSO renders fine.

However, if I use setTrack with another font, the render is not updated to use the new font. The text and other style properties are updated, just not the font.

Both fonts have been specified in the availableFonts option.

Currently the only workaround I have is to dispose and reinitialize JSO.

adamunion avatar Jun 22 '19 18:06 adamunion

iinm, availableFonts is currently only sent to the worker on init, meaning later changes have no effect. So I guess this is a feature request to allow adding new fonts and possibly removing old fonts later on (which seems reasonable).

TheOneric avatar Aug 07 '21 18:08 TheOneric

I think you misunderstand the bug. What I'm running into is: I initialize JSO with availableFonts: {"font 1": "/path/to/font1.ttf", "font 2": "/path/to/font2.ttf"} and a subUrl that only uses font 1. Later on, I use setTrack to specify a new subtitles file that only uses font2. This should switch to font 2 in the rendering, but it does not. I do not want to change the value of availableFonts, I want to be able to change which fonts are used in the subtitles.

Here's a detailed timeline of the bug I notice:

  1. I run setTrack(font2subs) (the subs are a data url, not http, if that makes any difference)
  2. I notice a network request to fetch the font 2 ttf file, but the rendering does not change.
  3. I run setTrack(font1subs) and it changes back to font 1 instantly
  4. I run setTrack(font2subs) and it changes back to font 2 instantly.

So it seems that, when the font changes, if it has to download the font, it forgets to refresh the render after it downloads.

incidentist avatar Oct 27 '23 03:10 incidentist

I think you misunderstand the bug. What I'm running into is: I initialize JSO with availableFonts: {"font 1": "/path/to/font1.ttf", "font 2": "/path/to/font2.ttf"} and a subUrl that only uses font 1. Later on, I use setTrack to specify a new subtitles file that only uses font2. This should switch to font 2 in the rendering, but it does not. I do not want to change the value of availableFonts, I want to be able to change which fonts are used in the subtitles.

Here's a detailed timeline of the bug I notice:

  1. I run setTrack(font2subs) (the subs are a data url, not http, if that makes any difference)
  2. I notice a network request to fetch the font 2 ttf file, but the rendering does not change.
  3. I run setTrack(font1subs) and it changes back to font 1 instantly
  4. I run setTrack(font2subs) and it changes back to font 2 instantly.

So it seems that, when the font changes, if it has to download the font, it forgets to refresh the render after it downloads.

@incidentist Encountered the same problem 😄, have you solved it?

chenyangxx avatar Nov 16 '23 15:11 chenyangxx