Fix missing font (#1404)

Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
JoanFo 2025-06-08 09:11:56 +02:00 committed by GitHub
parent bd2a00760d
commit af609994b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 17 deletions

View File

@ -32,6 +32,7 @@ use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ToggleButtons; use Filament\Forms\Components\ToggleButtons;
use Filament\Forms\Get; use Filament\Forms\Get;
use Filament\Forms\Set;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Pages\Auth\EditProfile as BaseEditProfile; use Filament\Pages\Auth\EditProfile as BaseEditProfile;
use Filament\Support\Colors\Color; use Filament\Support\Colors\Color;
@ -402,27 +403,35 @@ class EditProfile extends BaseEditProfile
}) })
->reactive() ->reactive()
->default('monospace') ->default('monospace')
->afterStateUpdated(fn ($state, callable $set) => $set('font_preview', $state)), ->afterStateUpdated(fn ($state, Set $set) => $set('font_preview', $state)),
Placeholder::make('font_preview') Placeholder::make('font_preview')
->label(trans('profile.font_preview')) ->label(trans('profile.font_preview'))
->columnSpan(2) ->columnSpan(2)
->content(function (Get $get) { ->content(function (Get $get) {
$fontName = $get('console_font') ?? 'monospace'; $fontName = $get('console_font') ?? 'monospace';
$fontSize = $get('console_font_size') . 'px'; $fontSize = $get('console_font_size') . 'px';
$fontUrl = asset("storage/fonts/{$fontName}.ttf"); $style = <<<CSS
return new HtmlString(<<<HTML
<style>
@font-face {
font-family: "CustomPreviewFont";
src: url("$fontUrl");
}
.preview-text { .preview-text {
font-family: "CustomPreviewFont"; font-family: $fontName;
font-size: $fontSize; font-size: $fontSize;
margin-top: 10px; margin-top: 10px;
display: block; display: block;
} }
CSS;
if ($fontName !== 'monospace') {
$fontUrl = asset("storage/fonts/$fontName.ttf");
$style = <<<CSS
@font-face {
font-family: $fontName;
src: url("$fontUrl");
}
$style
CSS;
}
return new HtmlString(<<<HTML
<style>
{$style}
</style> </style>
<span class="preview-text">The quick blue pelican jumps over the lazy pterodactyl. :)</span> <span class="preview-text">The quick blue pelican jumps over the lazy pterodactyl. :)</span>
HTML); HTML);

View File

@ -5,7 +5,7 @@
$userFontSize = auth()->user()->getCustomization()['console_font_size'] ?? 14; $userFontSize = auth()->user()->getCustomization()['console_font_size'] ?? 14;
$userRows = auth()->user()->getCustomization()['console_rows'] ?? 30; $userRows = auth()->user()->getCustomization()['console_rows'] ?? 30;
@endphp @endphp
@if($userFont) @if($userFont !== "monospace")
<link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin> <link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin>
<style> <style>
@font-face { @font-face {