fix: improve default fonts for subtitle renderer

This commit is contained in:
ThaUnknown 2024-06-16 22:20:18 +02:00
parent 7b3020bf35
commit 33f9124cc9
5 changed files with 19 additions and 12 deletions

View file

@ -30,6 +30,7 @@ const capacitorConfig = {
...alias,
wrtc: false,
'node-datachannel': false,
'hybrid-chunk-store': false,
'bittorrent-tracker/lib/client/http-tracker.js': resolve('../node_modules/bittorrent-tracker/lib/client/http-tracker.js'),
'webrtc-polyfill': false // no webrtc on mobile, need the resources
}

View file

@ -175,10 +175,6 @@ export default class Subtitles {
useLocalFonts: settings.value.missingFont,
dropAllBlur: settings.value.disableSubtitleBlur
}
if (settings.value.font) {
options.availableFonts[settings.value.font.name.toLowerCase()] = new Uint8Array(settings.value.font.data)
this.fonts.push(new Uint8Array(settings.value.font.data))
}
this.renderer = new JASSUB(options)
}
}

View file

@ -6,6 +6,9 @@ import Parser from './parser.js'
import { defaults, fontRx, subRx, videoRx } from './util.js'
import { SUPPORTS } from './support.js'
// HACK: this is https only, but electron doesnt run in https, weirdge
if (!globalThis.FileSystemFileHandle) globalThis.FileSystemFileHandle = false
const LARGE_FILESIZE = 32_000_000_000
const announce = [
@ -27,9 +30,6 @@ const announce = [
let storedSettings = {}
// HACK: this is https only, but electron doesnt run in https
if (!globalThis.FileSystemFileHandle) globalThis.FileSystemFileHandle = false
try {
storedSettings = JSON.parse(localStorage.getItem('settings')) || {}
} catch (error) {}

View file

@ -10,12 +10,12 @@
async function changeFont ({ detail }) {
try {
const blob = await detail.blob()
const data = await blob.arrayBuffer()
await blob.arrayBuffer()
settings.font = {
name: detail.fullName,
value: detail.postscriptName,
data: [...new Uint8Array(data)]
value: detail.postscriptName
}
settings.missingFont = true
} catch (error) {
console.warn(error)
toast.error('File Error', {
@ -24,15 +24,24 @@
})
}
}
function removeFont () {
settings.font = null
}
function handleExecutable () {
IPC.emit('player')
}
$: if (!settings.missingFont) removeFont()
</script>
<h4 class='mb-10 font-weight-bold'>Subtitle Settings</h4>
{#if ('queryLocalFonts' in self)}
<h4 class='mb-10 font-weight-bold'>Subtitle Settings</h4>
<SettingCard title='Default Subtitle Font' description={"What font to use when the current loaded video doesn't provide or specify one.\nThis uses fonts installed on your OS."}>
<FontSelect class='form-control bg-dark w-300 mw-full' on:change={changeFont} value={settings.font?.name} />
<div class='input-group w-400 mw-full'>
<FontSelect class='form-control bg-dark w-300 mw-full' on:change={changeFont} value={settings.font?.name} />
<div class='input-group-append'>
<button type='button' class='btn btn-danger btn-square px-5 material-symbols-outlined font-size-20' use:click={() => removeFont()}>delete</button>
</div>
</div>
</SettingCard>
<SettingCard title='Find Missing Subtitle Fonts' description="Automatically finds and loads fonts that are missing from a video's subtitles.">
<div class='custom-switch'>

View file

@ -27,6 +27,7 @@ module.exports = [
'node-fetch': false,
ws: false,
wrtc: false,
'hybrid-chunk-store': false,
'bittorrent-tracker/lib/client/http-tracker.js': resolve('../node_modules/bittorrent-tracker/lib/client/http-tracker.js'),
'webrtc-polyfill': resolve('../node_modules/webrtc-polyfill/browser.js')
}