Skip to content

A self-hosted media server and file management system

feat: add auto font generation flag on libraries

aminnausin925e21c429e8
diff --git a/app/Http/Controllers/Api/V1/CategoryController.php b/app/Http/Controllers/Api/V1/CategoryController.php
index 2bac7a4d..096bfabf 100755
--- a/app/Http/Controllers/Api/V1/CategoryController.php
+++ b/app/Http/Controllers/Api/V1/CategoryController.php
@@ -85,6 +85,7 @@ class CategoryController extends Controller {
'downloads_enabled' => 'sometimes|boolean',
'downloads_require_auth' => 'sometimes|boolean',
'storyboard_enabled' => 'sometimes|boolean',
+ 'fonts_enabled' => 'sometimes|boolean',
]);
$category->update(array_merge($validated, ['editor_id' => Auth::id()]));
diff --git a/app/Http/Resources/CategoryResource.php b/app/Http/Resources/CategoryResource.php
index 3f12f9c1..8fee92b1 100755
--- a/app/Http/Resources/CategoryResource.php
+++ b/app/Http/Resources/CategoryResource.php
@@ -43,6 +43,7 @@ class CategoryResource extends JsonResource {
'downloads_enabled' => $authenticatedRequest ? $this->downloads_enabled : false,
'downloads_require_auth' => $authenticatedRequest ? $this->downloads_require_auth : true,
'storyboard_enabled' => $this->storyboard_enabled,
+ 'fonts_enabled' => $this->fonts_enabled,
];
}
}
diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.php
index 309a0289..401e4da7 100755
--- a/app/Jobs/VerifyFiles.php
+++ b/app/Jobs/VerifyFiles.php
@@ -6,6 +6,7 @@ use App\Data\Subtitles\SubtitleScanTarget;
use App\Enums\ImageType;
use App\Enums\MediaType;
use App\Enums\TaskStatus;
+use App\Jobs\Metadata\ExtractFonts;
use App\Jobs\Metadata\GenerateStoryboard;
use App\Jobs\Utility\Subtitles\ScanSubtitles;
use App\Models\Metadata;
@@ -32,6 +33,8 @@ class VerifyFiles extends ManagedSubTask {
protected $storyboardChain = [];
+ protected $fontChain = [];
+
protected $scannedDirectories = []; // this could go in the indexer but realistically it is only scanning each directory once and caching the "result" to later batch actual subtitle indexing
protected $fileMetaData = [];
@@ -69,7 +72,7 @@ class VerifyFiles extends ManagedSubTask {
);
}
- $additionalTaskChain = array_merge($this->embedChain, $this->subtitleScanChain, $this->storyboardChain);
+ $additionalTaskChain = array_merge($this->embedChain, $this->subtitleScanChain, $this->storyboardChain, $this->fontChain);
$additionalTaskCount = count($additionalTaskChain);
$taskCountUpdates = [
@@ -386,7 +389,7 @@ class VerifyFiles extends ManagedSubTask {
// If no storyboard and storyboard_scanned_at is null OR storyboard was scanned before file was last modified or file was just updated
$needsStoryboard = $fileUpdated || (! $metadata->storyboard_scanned_at && ! $metadata->storyboard) || $metadata->storyboard_scanned_at?->lt($metadata->file_modified_at);
- if ($this->generateImageTasks && ! $is_audio && $video->folder->category->storyboard_enabled && ($needsStoryboard)) {
+ if ($this->generateImageTasks && ! $is_audio && $video->folder->category->storyboard_enabled && $needsStoryboard) {
$this->storyboardChain[] = new GenerateStoryboard(
filePath: $filePath,
uuid: $uuid,
@@ -394,6 +397,15 @@ class VerifyFiles extends ManagedSubTask {
);
}
+ $needsFonts = $fileUpdated || (! $metadata->fonts_scanned_at && ! $metadata->fonts) || $metadata->fonts_scanned_at?->lt($metadata->file_modified_at);
+ if (! $is_audio && $video->folder->category->fonts_enabled && $needsFonts) {
+ $this->fontChain[] = new ExtractFonts(
+ filePath: $filePath,
+ uuid: $uuid,
+ taskId: $this->taskId,
+ );
+ }
+
if (! empty($changes)) {
$changes['file_scanned_at'] = now();
diff --git a/app/Models/Category.php b/app/Models/Category.php
index f1a38cd5..74fa04dc 100755
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -21,6 +21,7 @@ class Category extends Model {
'downloads_enabled',
'downloads_require_auth',
'storyboard_enabled',
+ 'fonts_enabled',
'is_private',
];
@@ -29,6 +30,7 @@ class Category extends Model {
'downloads_enabled' => 'boolean',
'downloads_require_auth' => 'boolean',
'storyboard_enabled' => 'boolean',
+ 'fonts_enabled' => 'boolean',
];
public function folders(): HasMany {
@@ -55,6 +57,10 @@ class Category extends Model {
return $this->storyboard_enabled;
}
+ public function fontsEnabled(): bool {
+ return $this->fonts_enabled;
+ }
+
public function isVisibleTo(?User $user): bool {
return ! $this->is_private || (bool) $user?->isAdmin();
}
diff --git a/app/Traits/HasUpsert.php b/app/Traits/HasUpsert.php
index a868a617..556f0ede 100644
--- a/app/Traits/HasUpsert.php
+++ b/app/Traits/HasUpsert.php
@@ -9,8 +9,8 @@ trait HasUpsert {
* Generates tag relationships for any model
*
* @param string $context Custom Error Message
- * @param Throwable $th Original Error
- * @param array $transactions Upsert Transactions
+ * @param \Throwable $th Original Error
+ * @param array $ids Upsert transactions by id
* @param int $updateCount Number of updates attempted
* @param int|null $checkCount Number of checks attempted (optional)
*/
diff --git a/database/migrations/2026_09_07_202103_add_fonts_toggle_to_categories.php b/database/migrations/2026_09_07_202103_add_fonts_toggle_to_categories.php
new file mode 100644
index 00000000..8d3bc38f
--- /dev/null
+++ b/database/migrations/2026_09_07_202103_add_fonts_toggle_to_categories.php
@@ -0,0 +1,25 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ */
+ public function up(): void {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->boolean('fonts_enabled')->default(false);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->dropColumn(['fonts_enabled']);
+ });
+ }
+};
diff --git a/resources/js/components/cards/data/LibraryCard.vue b/resources/js/components/cards/data/LibraryCard.vue
index 5f84bd6b..73faeb25 100644
--- a/resources/js/components/cards/data/LibraryCard.vue
+++ b/resources/js/components/cards/data/LibraryCard.vue
@@ -84,7 +84,7 @@ const handleGenerateStoryboards = async () => {
};
const handleToggleSetting = async (
- setting: keyof Pick<CategoryResource, 'is_private' | 'downloads_enabled' | 'downloads_require_auth' | 'storyboard_enabled'>,
+ setting: keyof Pick<CategoryResource, 'is_private' | 'downloads_enabled' | 'downloads_require_auth' | 'storyboard_enabled' | 'fonts_enabled'>,
currentValue: boolean,
successMessage: (newValue: boolean) => string,
) => {
diff --git a/resources/js/components/menus/LibraryCardMenu.vue b/resources/js/components/menus/LibraryCardMenu.vue
index 4b094e3d..7213453b 100644
--- a/resources/js/components/menus/LibraryCardMenu.vue
+++ b/resources/js/components/menus/LibraryCardMenu.vue
@@ -14,6 +14,8 @@ import TablerDownload from '@/components/icons/TablerDownload.vue';
import ProIconsPhoto from '@/components/icons/ProIconsPhoto.vue';
import SectionLabel from '@/components/labels/SectionLabel.vue';
+import ProIconsTextHighlightColorOff from '@/components/icons/ProIconsTextHighlightColorOff.vue';
+import ProiconsTextHighlightColor from '~icons/proicons/text-highlight-color';
import ProiconsArrowSync from '~icons/proicons/arrow-sync';
import ProiconsLockOpen from '~icons/proicons/lock-open';
import ProiconsDelete from '~icons/proicons/delete';
@@ -29,7 +31,7 @@ const props = withDefaults(
handleStartScan: (verifyOnly?: boolean) => Promise<void>;
handleStartGenerateStoryboards: () => Promise<void>;
handleToggleSetting: (
- setting: keyof Pick<CategoryResource, 'is_private' | 'downloads_enabled' | 'downloads_require_auth' | 'storyboard_enabled'>,
+ setting: keyof Pick<CategoryResource, 'is_private' | 'downloads_enabled' | 'downloads_require_auth' | 'storyboard_enabled' | 'fonts_enabled'>,
currentValue: boolean,
successMessage: (newValue: boolean) => string,
) => Promise<void>;
@@ -105,6 +107,15 @@ const { isAdmin } = useAuth();
<template #icon> <ProIconsPhotoOff v-if="!data.storyboard_enabled" class="size-4" /> <ProIconsPhoto v-else class="size-4" /></template>
</ButtonText>
+ <ButtonText
+ :title="'Toggle Fonts'"
+ @click="handleToggleSetting('fonts_enabled', data.fonts_enabled, (v) => `${v ? 'Enabled' : 'Disabled'} Automatic Font Generation`)"
+ :disabled="processing"
+ >
+ <p class="flex-1 text-start">{{ data.fonts_enabled ? 'Disable Fonts' : 'Enable Fonts' }}</p>
+ <template #icon> <ProIconsTextHighlightColorOff v-if="!data.fonts_enabled" class="size-4" /> <ProiconsTextHighlightColor v-else class="size-4" /></template>
+ </ButtonText>
+
<ButtonText
:title="'Toggle Downloads'"
@click="handleToggleSetting('downloads_enabled', data.downloads_enabled, (v) => `${v ? 'Enabled' : 'Disabled'} Library Downloads`)"
diff --git a/resources/js/contracts/media.ts b/resources/js/contracts/media.ts
index 7424e56c..bfc92e94 100644
--- a/resources/js/contracts/media.ts
+++ b/resources/js/contracts/media.ts
@@ -16,6 +16,7 @@ export interface CategoryResource {
downloads_enabled: boolean;
downloads_require_auth: boolean;
storyboard_enabled: boolean;
+ fonts_enabled: boolean;
}
//#region Folders