Move fonts to new path

This commit is contained in:
Luke Hubmayer-Werner 2024-12-19 16:06:44 +10:30
parent 6dfdb8f49d
commit bf59cc5ef3
5 changed files with 7 additions and 3 deletions

View File

@ -66,7 +66,7 @@ class h extends EventTarget {
* @param {String} [options.subUrl=options.subContent] The URL of the subtitle file to play. * @param {String} [options.subUrl=options.subContent] The URL of the subtitle file to play.
* @param {String} [options.subContent=options.subUrl] The content of the subtitle file to play. * @param {String} [options.subContent=options.subUrl] The content of the subtitle file to play.
* @param {String[]|Uint8Array[]} [options.fonts] An array of links or Uint8Arrays to the fonts used in the subtitle. If Uint8Array is used the array is copied, not referenced. This forces all the fonts in this array to be loaded by the renderer, regardless of if they are used. * @param {String[]|Uint8Array[]} [options.fonts] An array of links or Uint8Arrays to the fonts used in the subtitle. If Uint8Array is used the array is copied, not referenced. This forces all the fonts in this array to be loaded by the renderer, regardless of if they are used.
* @param {Object} [options.availableFonts={'droid sans japanese': './DroidSansJapanese.ttf', 'noto sans japanese': 'NotoSansJPRegular.woff', 'liberation sans': './default.woff2'}] Object with all available fonts - Key is font family in lower case, value is link or Uint8Array: { arial: '/font1.ttf' }. These fonts are selectively loaded if detected as used in the current subtitle track. * @param {Object} [options.availableFonts={'droid sans japanese': '../fonts/DroidSansJapanese.ttf', 'noto sans japanese': '../fonts/NotoSansJPRegular.woff', 'liberation sans': '../fonts/default.woff2'}] Object with all available fonts - Key is font family in lower case, value is link or Uint8Array: { arial: '/font1.ttf' }. These fonts are selectively loaded if detected as used in the current subtitle track.
* @param {String} [options.fallbackFont='liberation sans'] The font family key of the fallback font in availableFonts to use if the other font for the style is missing special glyphs or unicode. * @param {String} [options.fallbackFont='liberation sans'] The font family key of the fallback font in availableFonts to use if the other font for the style is missing special glyphs or unicode.
* @param {Boolean} [options.useLocalFonts=false] If the Local Font Access API is enabled [chrome://flags/#font-access], the library will query for permissions to use local fonts and use them if any are missing. The permission can be queried beforehand using navigator.permissions.request({ name: 'local-fonts' }). * @param {Boolean} [options.useLocalFonts=false] If the Local Font Access API is enabled [chrome://flags/#font-access], the library will query for permissions to use local fonts and use them if any are missing. The permission can be queried beforehand using navigator.permissions.request({ name: 'local-fonts' }).
* @param {Number} [options.libassMemoryLimit] libass bitmap cache memory limit in MiB (approximate). * @param {Number} [options.libassMemoryLimit] libass bitmap cache memory limit in MiB (approximate).
@ -101,7 +101,7 @@ class h extends EventTarget {
subUrl: e.subUrl, subUrl: e.subUrl,
subContent: e.subContent || null, subContent: e.subContent || null,
fonts: e.fonts || [], fonts: e.fonts || [],
availableFonts: e.availableFonts || { 'droid sans japanese': './DroidSansJapanese.ttf', 'noto sans japanese': 'NotoSansJPRegular.woff', 'liberation sans': './default.woff2' }, availableFonts: e.availableFonts || { 'droid sans japanese': '../fonts/DroidSansJapanese.ttf', 'noto sans japanese': '../fonts/NotoSansJPRegular.woff', 'liberation sans': '../fonts/default.woff2' },
fallbackFont: e.fallbackFont || "liberation sans", fallbackFont: e.fallbackFont || "liberation sans",
debug: this.debug, debug: this.debug,
targetFps: e.targetFps || 24, targetFps: e.targetFps || 24,
@ -175,6 +175,8 @@ class h extends EventTarget {
* @param {Boolean} [force=false] * @param {Boolean} [force=false]
*/ */
resize(e = 0, t = 0, s = 0, a = 0, n = this._video?.paused) { resize(e = 0, t = 0, s = 0, a = 0, n = this._video?.paused) {
console.info(`Video resize called with e=${e} t=${t} s=${s} a=${a} n=${n}`);
if ((!e || !t) && this._video) { if ((!e || !t) && this._video) {
const r = this._getVideoPosition(); const r = this._getVideoPosition();
let i = null; let i = null;
@ -185,6 +187,8 @@ class h extends EventTarget {
i = this._computeCanvasSize(r.width || 0, r.height || 0); i = this._computeCanvasSize(r.width || 0, r.height || 0);
e = i.width, t = i.height, this._canvasParent && (s = r.y - (this._canvasParent.getBoundingClientRect().top - this._video.getBoundingClientRect().top), a = r.x), this._canvas.style.width = r.width + "px", this._canvas.style.height = r.height + "px"; e = i.width, t = i.height, this._canvasParent && (s = r.y - (this._canvasParent.getBoundingClientRect().top - this._video.getBoundingClientRect().top), a = r.x), this._canvas.style.width = r.width + "px", this._canvas.style.height = r.height + "px";
} }
console.info(`Video resize set with e=${e} t=${t} s=${s} a=${a} n=${n}`);
this._canvas.style.top = s + "px", this._canvas.style.left = a + "px", n && this.busy === !1 ? this.busy = !0 : n = !1, this.sendMessage("canvas", { width: e, height: t, force: n }); this._canvas.style.top = s + "px", this._canvas.style.left = a + "px", n && this.busy === !1 ? this.busy = !0 : n = !1, this.sendMessage("canvas", { width: e, height: t, force: n });
} }
_getVideoPosition(e = this._video.videoWidth, t = this._video.videoHeight) { _getVideoPosition(e = this._video.videoWidth, t = this._video.videoHeight) {

File diff suppressed because one or more lines are too long