diff --git a/backend/src/main/java/org/booklore/mapper/custom/BookLoreUserTransformer.java b/backend/src/main/java/org/booklore/mapper/custom/BookLoreUserTransformer.java index df2db5c40..e5437409f 100644 --- a/backend/src/main/java/org/booklore/mapper/custom/BookLoreUserTransformer.java +++ b/backend/src/main/java/org/booklore/mapper/custom/BookLoreUserTransformer.java @@ -36,6 +36,7 @@ public class BookLoreUserTransformer { bookLoreUser.setTheme(userEntity.getTheme()); bookLoreUser.setThemeAccent(userEntity.getThemeAccent()); bookLoreUser.setThemeSyncEnabled(userEntity.isThemeSyncEnabled()); + bookLoreUser.setUiFont(userEntity.getUiFont()); bookLoreUser.setDefaultPassword(userEntity.isDefaultPassword()); bookLoreUser.setPermissions(permissions); diff --git a/backend/src/main/java/org/booklore/model/dto/BookLoreUser.java b/backend/src/main/java/org/booklore/model/dto/BookLoreUser.java index 7508d6d44..efda0a8e8 100644 --- a/backend/src/main/java/org/booklore/model/dto/BookLoreUser.java +++ b/backend/src/main/java/org/booklore/model/dto/BookLoreUser.java @@ -25,6 +25,7 @@ public class BookLoreUser { private String theme; private String themeAccent; private boolean themeSyncEnabled; + private String uiFont; private ProvisioningMethod provisioningMethod; private List assignedLibraries; private UserPermissions permissions; diff --git a/backend/src/main/java/org/booklore/model/dto/request/UserProfileUpdateRequest.java b/backend/src/main/java/org/booklore/model/dto/request/UserProfileUpdateRequest.java index 632e6ec01..554b2264a 100644 --- a/backend/src/main/java/org/booklore/model/dto/request/UserProfileUpdateRequest.java +++ b/backend/src/main/java/org/booklore/model/dto/request/UserProfileUpdateRequest.java @@ -10,4 +10,5 @@ public class UserProfileUpdateRequest { private String theme; private String themeAccent; private Boolean themeSyncEnabled; + private String uiFont; } diff --git a/backend/src/main/java/org/booklore/model/entity/BookLoreUserEntity.java b/backend/src/main/java/org/booklore/model/entity/BookLoreUserEntity.java index 7241f2f11..91820bf0f 100644 --- a/backend/src/main/java/org/booklore/model/entity/BookLoreUserEntity.java +++ b/backend/src/main/java/org/booklore/model/entity/BookLoreUserEntity.java @@ -54,6 +54,10 @@ public class BookLoreUserEntity { @Column(name = "theme_sync_enabled", nullable = false) private boolean themeSyncEnabled = true; + @Builder.Default + @Column(name = "ui_font", nullable = false, length = 32) + private String uiFont = "default"; + @Column(name = "provisioning_method") @Enumerated(EnumType.STRING) private ProvisioningMethod provisioningMethod; diff --git a/backend/src/main/java/org/booklore/service/user/UserService.java b/backend/src/main/java/org/booklore/service/user/UserService.java index a5bcfbc33..12bbcfdc4 100644 --- a/backend/src/main/java/org/booklore/service/user/UserService.java +++ b/backend/src/main/java/org/booklore/service/user/UserService.java @@ -43,6 +43,7 @@ public class UserService { "red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose" ); + private static final Set SUPPORTED_UI_FONTS = Set.of("default", "atkinson"); private final UserRepository userRepository; private final LibraryRepository libraryRepository; @@ -124,6 +125,11 @@ public class UserService { user.setThemeSyncEnabled(updateRequest.getThemeSyncEnabled()); } + if (updateRequest.getUiFont() != null) { + validateUiFont(updateRequest.getUiFont()); + user.setUiFont(updateRequest.getUiFont()); + } + userRepository.save(user); auditService.log(AuditAction.USER_UPDATED, "User", id, "Updated user profile: " + user.getUsername()); return bookLoreUserTransformer.toDTO(user); @@ -282,4 +288,10 @@ public class UserService { throw ApiError.INVALID_INPUT.createException("Unsupported theme accent: " + themeAccent); } } + + private void validateUiFont(String uiFont) { + if (!SUPPORTED_UI_FONTS.contains(uiFont)) { + throw ApiError.INVALID_INPUT.createException("Unsupported UI font: " + uiFont); + } + } } diff --git a/backend/src/main/resources/db/migration/V143__Add_user_ui_font.sql b/backend/src/main/resources/db/migration/V143__Add_user_ui_font.sql new file mode 100644 index 000000000..9452de8bc --- /dev/null +++ b/backend/src/main/resources/db/migration/V143__Add_user_ui_font.sql @@ -0,0 +1,2 @@ +ALTER TABLE users + ADD COLUMN ui_font VARCHAR(32) NOT NULL DEFAULT 'default'; diff --git a/backend/src/test/java/org/booklore/service/user/UserServiceTest.java b/backend/src/test/java/org/booklore/service/user/UserServiceTest.java index 7879f53d5..dee213fc2 100644 --- a/backend/src/test/java/org/booklore/service/user/UserServiceTest.java +++ b/backend/src/test/java/org/booklore/service/user/UserServiceTest.java @@ -114,6 +114,23 @@ class UserServiceTest { verify(userRepository).save(user); } + @Test + void updateUserProfile_updatesUiFont() { + BookLoreUserEntity user = userEntity(1L); + UserProfileUpdateRequest request = new UserProfileUpdateRequest(); + request.setUiFont("atkinson"); + + when(userRepository.findByIdWithDetails(1L)).thenReturn(Optional.of(user)); + when(authenticationService.getAuthenticatedUser()).thenReturn(currentUser(1L, false)); + when(userRepository.save(user)).thenReturn(user); + when(bookLoreUserTransformer.toDTO(user)).thenAnswer(invocation -> currentUser(1L, false)); + + userService.updateUserProfile(1L, request); + + assertThat(user.getUiFont()).isEqualTo("atkinson"); + verify(userRepository).save(user); + } + @Test void updateUserProfile_rejectsUnsupportedLocale() { BookLoreUserEntity user = userEntity(1L); @@ -130,6 +147,22 @@ class UserServiceTest { verify(userRepository, never()).save(any()); } + @Test + void updateUserProfile_rejectsUnsupportedUiFont() { + BookLoreUserEntity user = userEntity(1L); + UserProfileUpdateRequest request = new UserProfileUpdateRequest(); + request.setUiFont("papyrus"); + + when(userRepository.findByIdWithDetails(1L)).thenReturn(Optional.of(user)); + when(authenticationService.getAuthenticatedUser()).thenReturn(currentUser(1L, false)); + + assertThatThrownBy(() -> userService.updateUserProfile(1L, request)) + .isInstanceOf(APIException.class) + .hasMessageContaining("Unsupported UI font"); + + verify(userRepository, never()).save(any()); + } + @Test void updateUserProfile_rejectsUnsupportedTheme() { BookLoreUserEntity user = userEntity(1L); diff --git a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.scss b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.scss index a613e517e..941bb1dea 100644 --- a/frontend/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.scss +++ b/frontend/src/app/features/metadata/component/book-metadata-center/metadata-viewer/metadata-viewer.component.scss @@ -347,6 +347,7 @@ .rating-value { font-weight: 600; font-size: var(--app-text-sm); + font-variant-numeric: tabular-nums; color: var(--color-text); } @@ -440,6 +441,7 @@ .metadata-value { color: var(--color-text-secondary); + font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; } @@ -773,6 +775,7 @@ .navigation-position { font-size: var(--app-text-sm); + font-variant-numeric: tabular-nums; color: var(--color-text-secondary); } @@ -830,6 +833,7 @@ font-size: 0.8313rem; color: var(--color-text); font-weight: 500; + font-variant-numeric: tabular-nums; } .comic-volume-number, diff --git a/frontend/src/app/features/settings/user-management/user.service.spec.ts b/frontend/src/app/features/settings/user-management/user.service.spec.ts index bad351ce5..c0a600ccd 100644 --- a/frontend/src/app/features/settings/user-management/user.service.spec.ts +++ b/frontend/src/app/features/settings/user-management/user.service.spec.ts @@ -242,12 +242,12 @@ describe('UserService', () => { httpTestingController.expectOne(req => req.url.endsWith('/api/v1/users/me')).flush(buildUser()); await flushCurrentUserQuery(); - service.updateUserProfile(7, {locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}).subscribe(); + service.updateUserProfile(7, {locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}).subscribe(); const request = httpTestingController.expectOne(req => req.url.endsWith('/api/v1/users/7/profile')); expect(request.request.method).toBe('PUT'); - expect(request.request.body).toEqual({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}); - request.flush(buildUser({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true})); + expect(request.request.body).toEqual({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}); + request.flush(buildUser({locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'})); await flushCurrentUserQuery(); expect(service.currentUser()).toEqual(expect.objectContaining({ @@ -255,6 +255,7 @@ describe('UserService', () => { theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, + uiFont: 'atkinson', })); }); }); diff --git a/frontend/src/app/features/settings/user-management/user.service.ts b/frontend/src/app/features/settings/user-management/user.service.ts index 19b5b18f3..2fd5f4869 100644 --- a/frontend/src/app/features/settings/user-management/user.service.ts +++ b/frontend/src/app/features/settings/user-management/user.service.ts @@ -9,6 +9,7 @@ import { DashboardConfig } from '../../dashboard/models/dashboard-config.model'; import { injectQuery, queryOptions, QueryClient } from '@tanstack/angular-query-experimental'; import { CURRENT_USER_QUERY_KEY } from './user-query-keys'; import { AppTheme, CustomPrimary } from '../../../shared/model/app-state.model'; +import {DEFAULT_UI_FONT, normalizeUiFont, type UiFontPreference} from '../../../shared/model/ui-font.model'; export interface EntityViewPreferences { global: EntityViewPreference; @@ -324,6 +325,7 @@ export interface User { theme: AppTheme; themeAccent: CustomPrimary | null; themeSyncEnabled: boolean; + uiFont?: UiFontPreference; assignedLibraries: Library[]; permissions: { admin: boolean; @@ -382,6 +384,7 @@ export interface UserProfileUpdateRequest { theme?: AppTheme; themeAccent?: CustomPrimary | null; themeSyncEnabled?: boolean; + uiFont?: UiFontPreference; } @Injectable({ @@ -535,6 +538,7 @@ export class UserService { theme, themeAccent: theme === 'custom' ? user.themeAccent ?? 'orange' : null, themeSyncEnabled: user.themeSyncEnabled ?? true, + uiFont: normalizeUiFont(user.uiFont ?? DEFAULT_UI_FONT), permissions: { ...permissions, canBulkResetGrimmoryReadProgress: permissions.canBulkResetGrimmoryReadProgress ?? permissions.canBulkResetBookloreReadProgress, diff --git a/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.html b/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.html index d9f1f4ae7..92d7dcf6c 100644 --- a/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.html +++ b/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.html @@ -108,6 +108,20 @@ +
+
+ {{ t('uiFont.label') }} +
+
+ + + +
+
+
diff --git a/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.ts b/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.ts index 018fe214c..b5c5208ff 100644 --- a/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.ts +++ b/frontend/src/app/features/settings/view-preferences-parent/display-preferences/display-preferences.component.ts @@ -17,6 +17,8 @@ import type {AppearancePreference, AppTheme, CustomPrimary} from '../../../../sh import {APPEARANCE_OPTIONS} from '../../../../shared/layout/theme/appearance-options'; import {UserService} from '../../user-management/user.service'; import type {User, UserProfileUpdateRequest} from '../../user-management/user.service'; +import {AppUiFontService} from '../../../../shared/service/app-ui-font.service'; +import {ACCESSIBLE_UI_FONT, DEFAULT_UI_FONT} from '../../../../shared/model/ui-font.model'; @Component({ selector: 'app-display-preferences', @@ -34,6 +36,7 @@ import type {User, UserProfileUpdateRequest} from '../../user-management/user.se export class DisplayPreferencesComponent { private readonly themeService = inject(AppThemeService); private readonly localeService = inject(AppLocaleService); + private readonly uiFontService = inject(AppUiFontService); private readonly userService = inject(UserService); private readonly messageService = inject(MessageService); private readonly t = inject(TranslocoService); @@ -51,6 +54,8 @@ export class DisplayPreferencesComponent { label: LANG_LABELS[value] ?? value, })); protected readonly selectedAppearancePreference = this.themeService.appearancePreference; + protected readonly selectedUiFont = this.uiFontService.uiFont; + protected readonly useAccessibleUiFont = computed(() => this.selectedUiFont() === ACCESSIBLE_UI_FONT); protected readonly selectedThemePreference = this.themeService.themePreference; protected readonly oledDarkMode = this.themeService.oledDarkMode; protected readonly showOledDarkModeToggle = computed(() => this.themeService.effectiveAppearance() === 'dark'); @@ -84,6 +89,21 @@ export class DisplayPreferencesComponent { this.showSavedToast('settingsView.language.savedDetail'); } + protected async updateAccessibleUiFont(useAccessibleFont: boolean): Promise { + const uiFont = useAccessibleFont ? ACCESSIBLE_UI_FONT : DEFAULT_UI_FONT; + if (uiFont === this.selectedUiFont()) return; + + const previousUiFont = this.selectedUiFont(); + this.uiFontService.applyUiFont(uiFont); + + if (!await this.updateCurrentUserProfile({uiFont})) { + this.uiFontService.applyUiFont(previousUiFont); + return; + } + + this.showSavedToast('settingsView.uiFont.savedDetail'); + } + protected async updateThemePreference(themePreference: AppTheme): Promise { if (!this.selectedThemeSyncEnabled()) { this.themeService.applyDeviceTheme(themePreference, this.selectedCustomPrimary()); diff --git a/frontend/src/app/shared/model/ui-font.model.ts b/frontend/src/app/shared/model/ui-font.model.ts new file mode 100644 index 000000000..14d80ecac --- /dev/null +++ b/frontend/src/app/shared/model/ui-font.model.ts @@ -0,0 +1,10 @@ +export const UI_FONT_VALUES = ['default', 'atkinson'] as const; + +export type UiFontPreference = (typeof UI_FONT_VALUES)[number]; + +export const DEFAULT_UI_FONT: UiFontPreference = 'default'; +export const ACCESSIBLE_UI_FONT: UiFontPreference = 'atkinson'; + +export function normalizeUiFont(value: string | null | undefined): UiFontPreference { + return UI_FONT_VALUES.includes(value as UiFontPreference) ? value as UiFontPreference : DEFAULT_UI_FONT; +} diff --git a/frontend/src/app/shared/service/app-ui-font.service.spec.ts b/frontend/src/app/shared/service/app-ui-font.service.spec.ts new file mode 100644 index 000000000..4a2ba110f --- /dev/null +++ b/frontend/src/app/shared/service/app-ui-font.service.spec.ts @@ -0,0 +1,62 @@ +import {DOCUMENT} from '@angular/common'; +import {TestBed} from '@angular/core/testing'; +import {afterEach, beforeEach, describe, expect, it} from 'vitest'; + +import {AppUiFontService} from './app-ui-font.service'; + +describe('AppUiFontService', () => { + let service: AppUiFontService; + let document: Document; + + beforeEach(() => { + localStorage.clear(); + TestBed.configureTestingModule({}); + document = TestBed.inject(DOCUMENT); + }); + + afterEach(() => { + delete document.documentElement.dataset['uiFont']; + localStorage.clear(); + TestBed.resetTestingModule(); + }); + + it('applies an accessible UI font to the document root', () => { + service = TestBed.inject(AppUiFontService); + + service.applyUiFont('atkinson'); + + expect(service.uiFont()).toBe('atkinson'); + expect(document.documentElement.dataset['uiFont']).toBe('atkinson'); + expect(localStorage.getItem('appUiFont')).toBe('atkinson'); + }); + + it('falls back to the default UI font for unsupported values', () => { + service = TestBed.inject(AppUiFontService); + + service.applyUiFont('unsupported'); + + expect(service.uiFont()).toBe('default'); + expect(document.documentElement.dataset['uiFont']).toBeUndefined(); + expect(localStorage.getItem('appUiFont')).toBe('default'); + }); + + it('loads a stored accessible UI font on creation', () => { + localStorage.setItem('appUiFont', 'atkinson'); + + service = TestBed.inject(AppUiFontService); + + expect(service.uiFont()).toBe('atkinson'); + expect(document.documentElement.dataset['uiFont']).toBe('atkinson'); + expect(localStorage.getItem('appUiFont')).toBe('atkinson'); + }); + + it('normalizes an unsupported stored UI font on creation', () => { + localStorage.setItem('appUiFont', 'unsupported'); + + service = TestBed.inject(AppUiFontService); + + expect(service.uiFont()).toBe('default'); + expect(document.documentElement.dataset['uiFont']).toBeUndefined(); + expect(localStorage.getItem('appUiFont')).toBe('default'); + }); +}); diff --git a/frontend/src/app/shared/service/app-ui-font.service.ts b/frontend/src/app/shared/service/app-ui-font.service.ts new file mode 100644 index 000000000..03d1be77d --- /dev/null +++ b/frontend/src/app/shared/service/app-ui-font.service.ts @@ -0,0 +1,47 @@ +import {DOCUMENT, isPlatformBrowser} from '@angular/common'; +import {inject, Injectable, PLATFORM_ID, signal} from '@angular/core'; + +import {DEFAULT_UI_FONT, normalizeUiFont, type UiFontPreference} from '../model/ui-font.model'; + +const STORAGE_KEY = 'appUiFont'; + +@Injectable({providedIn: 'root'}) +export class AppUiFontService { + private readonly document = inject(DOCUMENT); + private readonly platformId = inject(PLATFORM_ID); + private readonly uiFontSignal = signal(DEFAULT_UI_FONT); + + readonly uiFont = this.uiFontSignal.asReadonly(); + + constructor() { + this.applyUiFont(this.getStoredUiFont()); + } + + private getStoredUiFont(): UiFontPreference { + if (!isPlatformBrowser(this.platformId)) { + return DEFAULT_UI_FONT; + } + + return normalizeUiFont(localStorage.getItem(STORAGE_KEY)); + } + + applyUiFont(uiFont: string | null | undefined): void { + const nextUiFont = normalizeUiFont(uiFont); + this.uiFontSignal.set(nextUiFont); + this.applyRootAttribute(nextUiFont); + + if (isPlatformBrowser(this.platformId)) { + localStorage.setItem(STORAGE_KEY, nextUiFont); + } + } + + private applyRootAttribute(uiFont: UiFontPreference): void { + const root = this.document.documentElement; + if (uiFont === DEFAULT_UI_FONT) { + delete root.dataset['uiFont']; + return; + } + + root.dataset['uiFont'] = uiFont; + } +} diff --git a/frontend/src/app/shared/service/startup.service.spec.ts b/frontend/src/app/shared/service/startup.service.spec.ts index d35560340..382cd80b6 100644 --- a/frontend/src/app/shared/service/startup.service.spec.ts +++ b/frontend/src/app/shared/service/startup.service.spec.ts @@ -9,6 +9,7 @@ import {StartupService} from './startup.service'; import {UserService} from '../../features/settings/user-management/user.service'; import {AppThemeService} from './app-theme.service'; import {AppLocaleService} from './app-locale.service'; +import {AppUiFontService} from './app-ui-font.service'; describe('StartupService', () => { beforeEach(() => { @@ -62,6 +63,7 @@ describe('StartupService', () => { const applySyncedTheme = vi.fn(); const applyLocale = vi.fn().mockResolvedValue(undefined); const getDisplayLocale = vi.fn().mockReturnValue('de'); + const applyUiFont = vi.fn(); TestBed.configureTestingModule({ providers: [ @@ -79,6 +81,7 @@ describe('StartupService', () => { {provide: QueryClient, useValue: {fetchQuery}}, {provide: AppThemeService, useValue: {applySyncedTheme, appState: () => ({themeSyncEnabled: true})}}, {provide: AppLocaleService, useValue: {applyLocale, getDisplayLocale}}, + {provide: AppUiFontService, useValue: {applyUiFont}}, ] }); @@ -86,16 +89,18 @@ describe('StartupService', () => { await expect(service.load()).resolves.toBeUndefined(); expect(fetchQuery).not.toHaveBeenCalled(); + expect(applyUiFont).not.toHaveBeenCalled(); expect(getDisplayLocale).toHaveBeenCalledOnce(); expect(applyLocale).toHaveBeenCalledWith('de'); }); it('uses the backend locale for authenticated users', async () => { - const fetchQuery = vi.fn().mockResolvedValue({id: 1, username: 'admin', locale: 'en', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}); + const fetchQuery = vi.fn().mockResolvedValue({id: 1, username: 'admin', locale: 'en', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}); const updateUserProfile = vi.fn().mockReturnValue(of({id: 1, username: 'admin', locale: 'de', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true})); const applySyncedTheme = vi.fn(); const applyLocale = vi.fn().mockResolvedValue(undefined); const getDisplayLocale = vi.fn().mockReturnValue('de'); + const applyUiFont = vi.fn(); TestBed.configureTestingModule({ providers: [ @@ -106,7 +111,7 @@ describe('StartupService', () => { useValue: { getUserQueryOptions: () => queryOptions({ queryKey: ['user'], - queryFn: async () => ({id: 1, username: 'admin', locale: 'en', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true}), + queryFn: async () => ({id: 1, username: 'admin', locale: 'en', theme: 'custom', themeAccent: 'teal', themeSyncEnabled: true, uiFont: 'atkinson'}), }), updateUserProfile, }, @@ -114,6 +119,7 @@ describe('StartupService', () => { {provide: QueryClient, useValue: {fetchQuery}}, {provide: AppThemeService, useValue: {applySyncedTheme, appState: () => ({themeSyncEnabled: true})}}, {provide: AppLocaleService, useValue: {applyLocale, getDisplayLocale}}, + {provide: AppUiFontService, useValue: {applyUiFont}}, ] }); @@ -123,6 +129,7 @@ describe('StartupService', () => { expect(updateUserProfile).not.toHaveBeenCalled(); expect(applySyncedTheme).toHaveBeenCalledWith('custom', 'teal'); + expect(applyUiFont).toHaveBeenCalledWith('atkinson'); expect(applyLocale).toHaveBeenCalledWith('en'); }); diff --git a/frontend/src/app/shared/service/startup.service.ts b/frontend/src/app/shared/service/startup.service.ts index 03dafb533..59f3b80aa 100644 --- a/frontend/src/app/shared/service/startup.service.ts +++ b/frontend/src/app/shared/service/startup.service.ts @@ -5,6 +5,7 @@ import {QueryClient} from '@tanstack/angular-query-experimental'; import {AppThemeService} from './app-theme.service'; import {DEFAULT_CUSTOM_PRIMARY} from '../model/app-state.model'; import {AppLocaleService} from './app-locale.service'; +import {AppUiFontService} from './app-ui-font.service'; @Injectable({providedIn: 'root'}) export class StartupService { @@ -13,6 +14,7 @@ export class StartupService { private queryClient = inject(QueryClient); private appThemeService = inject(AppThemeService); private appLocaleService = inject(AppLocaleService); + private appUiFontService = inject(AppUiFontService); async load(): Promise { if (this.authService.token()) { @@ -26,6 +28,7 @@ export class StartupService { private async applyUserPreferences(user: User): Promise { this.applyTheme(user); + this.appUiFontService.applyUiFont(user.uiFont); await this.appLocaleService.applyLocale(user.locale); } diff --git a/frontend/src/assets/fonts/AtkinsonHyperlegibleNext-Italic[wght].woff2 b/frontend/src/assets/fonts/AtkinsonHyperlegibleNext-Italic[wght].woff2 new file mode 100644 index 000000000..333b04287 Binary files /dev/null and b/frontend/src/assets/fonts/AtkinsonHyperlegibleNext-Italic[wght].woff2 differ diff --git a/frontend/src/assets/fonts/AtkinsonHyperlegibleNext[wght].woff2 b/frontend/src/assets/fonts/AtkinsonHyperlegibleNext[wght].woff2 new file mode 100644 index 000000000..626791adc Binary files /dev/null and b/frontend/src/assets/fonts/AtkinsonHyperlegibleNext[wght].woff2 differ diff --git a/frontend/src/assets/fonts/Inter-latin-ext[wght].woff2 b/frontend/src/assets/fonts/Inter-latin-ext[wght].woff2 new file mode 100644 index 000000000..a0125fa05 Binary files /dev/null and b/frontend/src/assets/fonts/Inter-latin-ext[wght].woff2 differ diff --git a/frontend/src/assets/fonts/Inter-latin[wght].woff2 b/frontend/src/assets/fonts/Inter-latin[wght].woff2 new file mode 100644 index 000000000..b0d0e2e5c Binary files /dev/null and b/frontend/src/assets/fonts/Inter-latin[wght].woff2 differ diff --git a/frontend/src/assets/fonts/OFL-Atkinson-Hyperlegible-Next.txt b/frontend/src/assets/fonts/OFL-Atkinson-Hyperlegible-Next.txt new file mode 100644 index 000000000..79be4ff67 --- /dev/null +++ b/frontend/src/assets/fonts/OFL-Atkinson-Hyperlegible-Next.txt @@ -0,0 +1,93 @@ +Copyright 2020-2024 The Atkinson Hyperlegible Next Project Authors (https://github.com/googlefonts/atkinson-hyperlegible-next) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/frontend/src/assets/fonts/OFL-Inter.txt b/frontend/src/assets/fonts/OFL-Inter.txt new file mode 100644 index 000000000..9b2ca37b3 --- /dev/null +++ b/frontend/src/assets/fonts/OFL-Inter.txt @@ -0,0 +1,92 @@ +Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION AND CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/frontend/src/assets/styles/base.scss b/frontend/src/assets/styles/base.scss index f34122c3b..4c0553d69 100644 --- a/frontend/src/assets/styles/base.scss +++ b/frontend/src/assets/styles/base.scss @@ -12,17 +12,17 @@ html { --mobile-shell-active: 0; - font-family: var(--font-family), "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif; + font-family: var(--font-family); font-size: var(--font-size-root); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } body { background-color: var(--color-app); color: var(--color-text); - font-family: var(--font-family), serif; + font-family: var(--font-family); font-size: var(--app-text-base); - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; } picture, @@ -67,6 +67,7 @@ h6 { color: var(--color-text-strong); font-weight: 500; line-height: 1.2; + text-wrap: balance; overflow-wrap: break-word; &:first-child { @@ -102,6 +103,7 @@ p { margin: 0 0 0.875rem; color: var(--color-text); line-height: 1.5; + text-wrap: pretty; overflow-wrap: break-word; &:last-child { @@ -113,6 +115,12 @@ p.p-secondary { color: var(--color-text-secondary); } +li, +figcaption, +blockquote { + text-wrap: pretty; +} + mark { padding: 0.2188rem 0.35rem; border-radius: var(--radius-lg); diff --git a/frontend/src/assets/styles/tailwind.css b/frontend/src/assets/styles/tailwind.css index 819802264..1d69b52a0 100644 --- a/frontend/src/assets/styles/tailwind.css +++ b/frontend/src/assets/styles/tailwind.css @@ -29,8 +29,42 @@ --tw-enter-translate-y: 0.25rem; } +@font-face { + font-family: "Inter"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("../fonts/Inter-latin[wght].woff2") format("woff2"); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} + +@font-face { + font-family: "Inter"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("../fonts/Inter-latin-ext[wght].woff2") format("woff2"); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; +} + +@font-face { + font-family: "Atkinson Hyperlegible Next"; + font-style: normal; + font-weight: 200 800; + font-display: swap; + src: url("../fonts/AtkinsonHyperlegibleNext[wght].woff2") format("woff2"); +} + +@font-face { + font-family: "Atkinson Hyperlegible Next"; + font-style: italic; + font-weight: 200 800; + font-display: swap; + src: url("../fonts/AtkinsonHyperlegibleNext-Italic[wght].woff2") format("woff2"); +} + @theme static { - --font-sans: -apple-system, "BlinkMacSystemFont", "Segoe UI", "Roboto", "Helvetica", "Arial", sans-serif; + --font-sans: var(--font-ui, "Inter", sans-serif); --text-app-xs: 0.6563rem; --text-app-sm: 0.7656rem; @@ -91,6 +125,7 @@ } :root { + --font-ui: "Inter", sans-serif; --font-size-root: 16px; --app-text-xs: var(--text-app-xs); --app-text-sm: var(--text-app-sm); @@ -98,6 +133,10 @@ --app-text-lg: var(--text-app-lg); } +[data-ui-font="atkinson"] { + --font-ui: "Atkinson Hyperlegible Next", sans-serif; +} + [data-app-theme] { --color-surface-150: color-mix(in srgb, var(--color-surface-100) 70%, var(--color-surface-200)); --color-app: color-mix(in srgb, var(--color-surface-150), var(--color-primary-200) var(--app-primary-tint, 0%)); diff --git a/frontend/src/i18n/en/settings-view.json b/frontend/src/i18n/en/settings-view.json index e4e2d5d7b..4ddf28e6f 100644 --- a/frontend/src/i18n/en/settings-view.json +++ b/frontend/src/i18n/en/settings-view.json @@ -6,9 +6,14 @@ "label": "Language", "savedDetail": "Your language preference has been saved." }, + "uiFont": { + "label": "Interface Font", + "accessibleLabel": "Use accessible font", + "savedDetail": "Your interface font preference has been saved." + }, "theme": { "sectionTitle": "Display", - "sectionDesc": "Configure the language, appearance, and theme for your account.", + "sectionDesc": "Configure the language, interface font, appearance, and theme for your account.", "oledDarkMode": "OLED dark mode", "savedDetail": "Your display preferences have been saved.", "syncSavedDetail": "Your theme sync preference has been saved.",