From fc02ec67d91fb3aae48309174de051f80967c217 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 14 May 2026 23:00:15 +0200 Subject: [PATCH 1/7] Add independent default font for text files --- lib/I18n/translations/belarusian.yaml | 2 ++ lib/I18n/translations/catalan.yaml | 2 ++ lib/I18n/translations/czech.yaml | 2 ++ lib/I18n/translations/danish.yaml | 2 ++ lib/I18n/translations/dutch.yaml | 3 +++ lib/I18n/translations/english.yaml | 9 ++++--- lib/I18n/translations/finnish.yaml | 2 ++ lib/I18n/translations/french.yaml | 3 +++ lib/I18n/translations/german.yaml | 3 +++ lib/I18n/translations/hungarian.yaml | 2 ++ lib/I18n/translations/italian.yaml | 3 +++ lib/I18n/translations/kazakh.yaml | 2 ++ lib/I18n/translations/lithuanian.yaml | 2 ++ lib/I18n/translations/polish.yaml | 3 +++ lib/I18n/translations/portuguese_br.yaml | 3 +++ lib/I18n/translations/portuguese_pt.yaml | 3 +++ lib/I18n/translations/romanian.yaml | 2 ++ lib/I18n/translations/russian.yaml | 3 +++ lib/I18n/translations/slovenian.yaml | 3 +++ lib/I18n/translations/spanish.yaml | 3 +++ lib/I18n/translations/swedish.yaml | 3 +++ lib/I18n/translations/turkish.yaml | 3 +++ lib/I18n/translations/ukrainian.yaml | 3 +++ lib/I18n/translations/vietnamese.yaml | 3 +++ src/CrossPointSettings.cpp | 8 ++++++ src/CrossPointSettings.h | 7 +++++- src/SdCardFontGlobals.h | 4 +++ src/SdCardFontSystem.cpp | 27 +++++++++++++++++++++ src/SettingsList.h | 11 ++++++++- src/activities/reader/MdReaderActivity.cpp | 2 +- src/activities/reader/TxtReaderActivity.cpp | 4 +-- 31 files changed, 124 insertions(+), 8 deletions(-) diff --git a/lib/I18n/translations/belarusian.yaml b/lib/I18n/translations/belarusian.yaml index d21e6c24..df105a59 100644 --- a/lib/I18n/translations/belarusian.yaml +++ b/lib/I18n/translations/belarusian.yaml @@ -70,6 +70,8 @@ STR_ORIENTATION: "Арыентацыя чытання" STR_LONG_PRESS_SKIP: "Доўгае націсканне - змена раздзела" STR_FONT_FAMILY: "Шрыфт чытання" STR_FONT_SIZE: "Памер шрыфту інтэрфейсу" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Міжрадковы інтэрвал" STR_SCREEN_MARGIN: "Палі экрана" STR_PARA_ALIGNMENT: "Выраўноўванне абзаца" diff --git a/lib/I18n/translations/catalan.yaml b/lib/I18n/translations/catalan.yaml index ef17dc7d..ace37a4f 100644 --- a/lib/I18n/translations/catalan.yaml +++ b/lib/I18n/translations/catalan.yaml @@ -74,6 +74,8 @@ STR_ORIENTATION: "Orientació de lectura" STR_LONG_PRESS_SKIP: "Pressió llarga omet el capítol" STR_FONT_FAMILY: "Tipus de lletra" STR_FONT_SIZE: "Mida de la lletra (UI)" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Interlineat del lector" STR_SCREEN_MARGIN: "Marge de pantalla del lector" STR_PARA_ALIGNMENT: "Alineació de paràgrafs del lector" diff --git a/lib/I18n/translations/czech.yaml b/lib/I18n/translations/czech.yaml index a7d6833c..71330b6b 100644 --- a/lib/I18n/translations/czech.yaml +++ b/lib/I18n/translations/czech.yaml @@ -70,6 +70,8 @@ STR_ORIENTATION: "Orientace čtení" STR_LONG_PRESS_SKIP: "Dlouhé stisknutí Přeskočit kapitolu" STR_FONT_FAMILY: "Rodina písem čtečky" STR_FONT_SIZE: "Velikost písma rozhraní" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Řádkování čtečky" STR_SCREEN_MARGIN: "Okraj obrazovky čtečky" STR_PARA_ALIGNMENT: "Zarovnání odstavců čtečky" diff --git a/lib/I18n/translations/danish.yaml b/lib/I18n/translations/danish.yaml index c87dfb3f..961fadb2 100644 --- a/lib/I18n/translations/danish.yaml +++ b/lib/I18n/translations/danish.yaml @@ -74,6 +74,8 @@ STR_ORIENTATION: "Læseretning" STR_LONG_PRESS_SKIP: "Langt tryk spring kapitel over" STR_FONT_FAMILY: "Læser skrifttype" STR_FONT_SIZE: "Læser skriftstørrelse" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Linjeafstand" STR_SCREEN_MARGIN: "Skærmmargen" STR_PARA_ALIGNMENT: "Afsnitsjustering" diff --git a/lib/I18n/translations/dutch.yaml b/lib/I18n/translations/dutch.yaml index 2674c235..d40cb49e 100644 --- a/lib/I18n/translations/dutch.yaml +++ b/lib/I18n/translations/dutch.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Leesstand" STR_LONG_PRESS_SKIP: "Hoofdstuk overslaan (lang indrukken)" STR_FONT_FAMILY: "Lettertype lezer" STR_FONT_SIZE: "Lettergrootte lezer" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Lettertypelijst laden..." STR_FONT_DOWNLOAD: "Lettertype downloaden" STR_FONT_INSTALLED: "Lettertype geïnstalleerd!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Slaap scherm" STR_MENU_DISP_BATTERY: "Batterijsymbool" STR_MENU_DISP_REFRESH: "Scherm verversen" STR_MENU_READER_FONT: "Leeslettertype" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Lettertype-instellingen" STR_MENU_READER_LAYOUT: "Lay-outinstellingen" STR_MENU_READER_TWEAKS: "Reader-instellingen" diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 51eca17f..78ff9fd0 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -109,12 +109,14 @@ STR_IMAGE_DITHER_DIFFUSED_BAYER: "Diffused Bayer" STR_CREATE_FALLBACK_FOR_INVALID_TOC: "Create fallback for invalid TOC" STR_ORIENTATION: "Reading Orientation" STR_LONG_PRESS_SKIP: "Long-press Chapter Skip" -STR_FONT_FAMILY: "Reader Font Family" +STR_FONT_FAMILY: "EPUB Font Family" STR_FONT_MANAGER: "Font Manager" STR_FONT_DOWNLOAD: "Font Download" STR_FONT_INSTALLED: "Font installed!" STR_FONT_INSTALL_FAILED: "Font installation failed" -STR_FONT_SIZE: "Reader Font Size" +STR_FONT_SIZE: "EPUB Font Size" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Reader Line Spacing" STR_SCREEN_MARGIN: "Reader Screen Margin" STR_PARA_ALIGNMENT: "Reader Paragraph Alignment" @@ -567,7 +569,8 @@ STR_MENU_SYS_TOOLS: "Tools" STR_MENU_DISP_SLEEP: "Sleep Screen" STR_MENU_DISP_BATTERY: "Battery symbol" STR_MENU_DISP_REFRESH: "Screen refresh" -STR_MENU_READER_FONT: "Reader Font" +STR_MENU_READER_FONT: "EPUB Font" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Font Settings" STR_MENU_READER_LAYOUT: "Layout Settings" STR_MENU_READER_TWEAKS: "Reader Tweaks" diff --git a/lib/I18n/translations/finnish.yaml b/lib/I18n/translations/finnish.yaml index 3acbc0ec..c355261c 100644 --- a/lib/I18n/translations/finnish.yaml +++ b/lib/I18n/translations/finnish.yaml @@ -70,6 +70,8 @@ STR_ORIENTATION: "Lukusuunta" STR_LONG_PRESS_SKIP: "Pitkä painallus: lukuhyppy" STR_FONT_FAMILY: "Lukijan fonttiperhe" STR_FONT_SIZE: "Käyttöliittymän fonttikoko" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Lukijan riviväli" STR_SCREEN_MARGIN: "Lukijan näyttömarginaali" STR_PARA_ALIGNMENT: "Lukijan kappaletasaus" diff --git a/lib/I18n/translations/french.yaml b/lib/I18n/translations/french.yaml index 8c8766c6..729e68d0 100644 --- a/lib/I18n/translations/french.yaml +++ b/lib/I18n/translations/french.yaml @@ -94,6 +94,8 @@ STR_ORIENTATION: "Orientation de lecture" STR_LONG_PRESS_SKIP: "Appui long saut de chapitre" STR_FONT_FAMILY: "Police de caractères du lecteur" STR_FONT_SIZE: "Taille texte interface" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Interligne" STR_SCREEN_MARGIN: "Marges du lecteur" STR_PARA_ALIGNMENT: "Alignement du texte" @@ -563,6 +565,7 @@ STR_MENU_DISP_SLEEP: "Écran de veille" STR_MENU_DISP_BATTERY: "Symbole batterie" STR_MENU_DISP_REFRESH: "Actualisation" STR_MENU_READER_FONT: "Police du lecteur" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Paramètres police" STR_MENU_READER_LAYOUT: "Paramètres mise en page" STR_MENU_READER_TWEAKS: "Ajustements lecteur" diff --git a/lib/I18n/translations/german.yaml b/lib/I18n/translations/german.yaml index cd3aa3a5..d7b84f3f 100644 --- a/lib/I18n/translations/german.yaml +++ b/lib/I18n/translations/german.yaml @@ -82,6 +82,8 @@ STR_ORIENTATION: "Leseausrichtung" STR_LONG_PRESS_SKIP: "Langes Drücken springt Kap." STR_FONT_FAMILY: "Lese-Schriftfamilie" STR_FONT_SIZE: "Schriftgröße" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Lese-Zeilenabstand" STR_SCREEN_MARGIN: "Lese-Seitenränder" STR_PARA_ALIGNMENT: "Lese-Absatzausrichtung" @@ -410,6 +412,7 @@ STR_MENU_DISP_SLEEP: "Standby-Bildschirm" STR_MENU_DISP_BATTERY: "Batteriesymbol" STR_MENU_DISP_REFRESH: "Bildschirmaktualisierung" STR_MENU_READER_FONT: "Leserschrift" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Schrifteinstellungen" STR_MENU_READER_LAYOUT: "Layout-Einstellungen" STR_MENU_READER_TWEAKS: "Lese-Tweaks" diff --git a/lib/I18n/translations/hungarian.yaml b/lib/I18n/translations/hungarian.yaml index a65c6270..7de4a4a9 100644 --- a/lib/I18n/translations/hungarian.yaml +++ b/lib/I18n/translations/hungarian.yaml @@ -74,6 +74,8 @@ STR_ORIENTATION: "Olvasási irány" STR_LONG_PRESS_SKIP: "Hosszú nyomás - fejezet ugrás" STR_FONT_FAMILY: "Olvasó betűkészlet" STR_FONT_SIZE: "Olvasó betűméret" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Olvasó sorköz" STR_SCREEN_MARGIN: "Olvasó margó" STR_PARA_ALIGNMENT: "Olvasó szövegigazítás" diff --git a/lib/I18n/translations/italian.yaml b/lib/I18n/translations/italian.yaml index bfe3a412..7a38859f 100644 --- a/lib/I18n/translations/italian.yaml +++ b/lib/I18n/translations/italian.yaml @@ -94,6 +94,8 @@ STR_ORIENTATION: "Orientamento lettura" STR_LONG_PRESS_SKIP: "Pressione lunga: salta capitolo" STR_FONT_FAMILY: "Font lettore" STR_FONT_SIZE: "Dimensione font lettore" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Interlinea lettore" STR_SCREEN_MARGIN: "Margine schermo lettore" STR_PARA_ALIGNMENT: "Allineamento paragrafo" @@ -563,6 +565,7 @@ STR_MENU_DISP_SLEEP: "Schermo standby" STR_MENU_DISP_BATTERY: "Icona batteria" STR_MENU_DISP_REFRESH: "Aggiorna schermo" STR_MENU_READER_FONT: "Carattere lettore" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Impostazioni carattere" STR_MENU_READER_LAYOUT: "Impostazioni layout" STR_MENU_READER_TWEAKS: "Personalizzazioni lettore" diff --git a/lib/I18n/translations/kazakh.yaml b/lib/I18n/translations/kazakh.yaml index 4257680b..d074b15c 100644 --- a/lib/I18n/translations/kazakh.yaml +++ b/lib/I18n/translations/kazakh.yaml @@ -69,6 +69,8 @@ STR_ORIENTATION: "Оқу бағдары" STR_LONG_PRESS_SKIP: "Ұзақ басу арқылы тарау өткізу" STR_FONT_FAMILY: "Оқырман қаріп тобы" STR_FONT_SIZE: "Интерфейс қаріп өлшемі" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Оқырман жол аралығы" STR_SCREEN_MARGIN: "Оқырман экран жиегі" STR_PARA_ALIGNMENT: "Оқырман абзац туралануы" diff --git a/lib/I18n/translations/lithuanian.yaml b/lib/I18n/translations/lithuanian.yaml index 02199537..b2952993 100644 --- a/lib/I18n/translations/lithuanian.yaml +++ b/lib/I18n/translations/lithuanian.yaml @@ -74,6 +74,8 @@ STR_ORIENTATION: "Orientacija" STR_LONG_PRESS_SKIP: "Praleisti skyrių (ilgai)" STR_FONT_FAMILY: "Šriftas" STR_FONT_SIZE: "Šrifto dydis" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Tarpai tarp eilučių" STR_SCREEN_MARGIN: "Ekrano paraštės" STR_PARA_ALIGNMENT: "Lygiavimas" diff --git a/lib/I18n/translations/polish.yaml b/lib/I18n/translations/polish.yaml index 69be6d02..0057ce63 100644 --- a/lib/I18n/translations/polish.yaml +++ b/lib/I18n/translations/polish.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Układ czytania" STR_LONG_PRESS_SKIP: "Przytrzymaj aby przeskoczyć rozdział" STR_FONT_FAMILY: "Czcionka" STR_FONT_SIZE: "Rozmiar czcionki" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Odstępy między wierszami" STR_SCREEN_MARGIN: "Marginesy ekranu" STR_PARA_ALIGNMENT: "Wyjustowanie paragrafów" @@ -578,6 +580,7 @@ STR_MENU_DISP_SLEEP: "Ekran uśpienia" STR_MENU_DISP_BATTERY: "Symbol baterii" STR_MENU_DISP_REFRESH: "Odświeżanie ekranu" STR_MENU_READER_FONT: "Czcionka czytnika" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Ustawienia czcionki" STR_MENU_READER_LAYOUT: "Ustawienia układu" STR_MENU_READER_TWEAKS: "Ustawienia czytnika" diff --git a/lib/I18n/translations/portuguese_br.yaml b/lib/I18n/translations/portuguese_br.yaml index dd442710..bdea113b 100644 --- a/lib/I18n/translations/portuguese_br.yaml +++ b/lib/I18n/translations/portuguese_br.yaml @@ -98,6 +98,8 @@ STR_ORIENTATION: "Orientação de leitura" STR_LONG_PRESS_SKIP: "Pular capítulo com pressão longa" STR_FONT_FAMILY: "Fonte do leitor" STR_FONT_SIZE: "Tam. da fonte da UI" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Espaçamento entre linhas" STR_SCREEN_MARGIN: "Margens da tela" STR_PARA_ALIGNMENT: "Alinhamento do parágrafo" @@ -514,6 +516,7 @@ STR_MENU_DISP_SLEEP: "Tela de repouso" STR_MENU_DISP_BATTERY: "Ícone de bateria" STR_MENU_DISP_REFRESH: "Atualizar tela" STR_MENU_READER_FONT: "Fonte do leitor" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Configurações de fonte" STR_MENU_READER_LAYOUT: "Configurações de layout" STR_MENU_READER_TWEAKS: "Ajustes de leitura" diff --git a/lib/I18n/translations/portuguese_pt.yaml b/lib/I18n/translations/portuguese_pt.yaml index 243f119e..3bcfc33c 100644 --- a/lib/I18n/translations/portuguese_pt.yaml +++ b/lib/I18n/translations/portuguese_pt.yaml @@ -90,6 +90,8 @@ STR_ORIENTATION: "Orientação de leitura" STR_LONG_PRESS_SKIP: "Saltar capítulo com pressão longa" STR_FONT_FAMILY: "Tipo de letra do leitor" STR_FONT_SIZE: "Tamanho da letra do leitor" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Espaçamento entre linhas" STR_SCREEN_MARGIN: "Margens do ecrã" STR_PARA_ALIGNMENT: "Alinhamento do parágrafo" @@ -551,6 +553,7 @@ STR_MENU_DISP_SLEEP: "Ecrã de repouso" STR_MENU_DISP_BATTERY: "Símbolo de bateria" STR_MENU_DISP_REFRESH: "Atualização do ecrã" STR_MENU_READER_FONT: "Fonte do leitor" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Definições da fonte" STR_MENU_READER_LAYOUT: "Definições de layout" STR_MENU_READER_TWEAKS: "Ajustes do leitor" diff --git a/lib/I18n/translations/romanian.yaml b/lib/I18n/translations/romanian.yaml index e411b0a4..43915d1b 100644 --- a/lib/I18n/translations/romanian.yaml +++ b/lib/I18n/translations/romanian.yaml @@ -74,6 +74,8 @@ STR_ORIENTATION: "Orientare lectură" STR_LONG_PRESS_SKIP: "Sărire capitol la apăsare lungă" STR_FONT_FAMILY: "Familie font lectură" STR_FONT_SIZE: "Dimensiune font" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Spaţiere între rânduri" STR_SCREEN_MARGIN: "Margine ecran lectură" STR_PARA_ALIGNMENT: "Aliniere paragrafe reader" diff --git a/lib/I18n/translations/russian.yaml b/lib/I18n/translations/russian.yaml index f36a8814..2be803cd 100644 --- a/lib/I18n/translations/russian.yaml +++ b/lib/I18n/translations/russian.yaml @@ -91,6 +91,8 @@ STR_ORIENTATION: "Ориентация чтения" STR_LONG_PRESS_SKIP: "Долгое нажатие - смена главы" STR_FONT_FAMILY: "Шрифт чтения" STR_FONT_SIZE: "Размер шрифта интерфейса" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Межстрочный интервал" STR_SCREEN_MARGIN: "Поля экрана" STR_PARA_ALIGNMENT: "Выравнивание абзаца" @@ -562,6 +564,7 @@ STR_MENU_DISP_SLEEP: "Экран сна" STR_MENU_DISP_BATTERY: "Значок батареи" STR_MENU_DISP_REFRESH: "Обновление экрана" STR_MENU_READER_FONT: "Шрифт чтения" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Настройки шрифта" STR_MENU_READER_LAYOUT: "Макет" STR_MENU_READER_TWEAKS: "Параметры чтения" diff --git a/lib/I18n/translations/slovenian.yaml b/lib/I18n/translations/slovenian.yaml index 1454a0e8..51e68453 100644 --- a/lib/I18n/translations/slovenian.yaml +++ b/lib/I18n/translations/slovenian.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Orientacija branja" STR_LONG_PRESS_SKIP: "Dolgi pritisk za preskok poglavja" STR_FONT_FAMILY: "Pisava bralnika" STR_FONT_SIZE: "Velikost pisave" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Nalagam seznam pisav..." STR_FONT_DOWNLOAD: "Prenos pisave" STR_FONT_INSTALLED: "Pisava nameščena!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Zaslon za spanje" STR_MENU_DISP_BATTERY: "Simbol baterije" STR_MENU_DISP_REFRESH: "Osveževanje zaslona" STR_MENU_READER_FONT: "Pisava bralnika" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Nastavitve pisave" STR_MENU_READER_LAYOUT: "Nastavitve postavitve" STR_MENU_READER_TWEAKS: "Popravki bralnika" diff --git a/lib/I18n/translations/spanish.yaml b/lib/I18n/translations/spanish.yaml index 436f6e30..425782db 100644 --- a/lib/I18n/translations/spanish.yaml +++ b/lib/I18n/translations/spanish.yaml @@ -88,6 +88,8 @@ STR_ORIENTATION: "Orientación" STR_LONG_PRESS_SKIP: "Saltar capítulo (pulsación larga)" STR_FONT_FAMILY: "Tipografía" STR_FONT_SIZE: "Tamaño" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LINE_SPACING: "Interlineado" STR_SCREEN_MARGIN: "Margen de lectura" STR_PARA_ALIGNMENT: "Ajuste de párrafo" @@ -562,6 +564,7 @@ STR_MENU_DISP_SLEEP: "Pantalla de suspensión" STR_MENU_DISP_BATTERY: "Icono de batería" STR_MENU_DISP_REFRESH: "Refrescar pantalla" STR_MENU_READER_FONT: "Fuente lector" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Ajustes de fuente" STR_MENU_READER_LAYOUT: "Ajustes de diseño" STR_MENU_READER_TWEAKS: "Ajustes de lectura" diff --git a/lib/I18n/translations/swedish.yaml b/lib/I18n/translations/swedish.yaml index 4c7be7ad..2a263f1b 100644 --- a/lib/I18n/translations/swedish.yaml +++ b/lib/I18n/translations/swedish.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Läsrikting" STR_LONG_PRESS_SKIP: "Lång-tryck Kapitelskippning" STR_FONT_FAMILY: "Eboksläsarens typsnittsfamilj" STR_FONT_SIZE: "Eboksläsarens typsnittsstorlek" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Läser in teckensnittslista..." STR_FONT_DOWNLOAD: "Ladda ner teckensnitt" STR_FONT_INSTALLED: "Teckensnitt installerat!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Viloskärm" STR_MENU_DISP_BATTERY: "Batterisymbol" STR_MENU_DISP_REFRESH: "Skärmaruppdatering" STR_MENU_READER_FONT: "Läsläge teckensnitt" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Teckensnittsinställningar" STR_MENU_READER_LAYOUT: "Layoutinställningar" STR_MENU_READER_TWEAKS: "Läsoptimeringar" diff --git a/lib/I18n/translations/turkish.yaml b/lib/I18n/translations/turkish.yaml index d81b35eb..5fb18bf6 100644 --- a/lib/I18n/translations/turkish.yaml +++ b/lib/I18n/translations/turkish.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Okuma Yönü" STR_LONG_PRESS_SKIP: "Uzun Basışla Bölüm Atla" STR_FONT_FAMILY: "Okuyucu Yazı Tipi Ailesi" STR_FONT_SIZE: "Arayüz Yazı Boyutu" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Yazı tipi listesi yükleniyor..." STR_FONT_DOWNLOAD: "Yazı tipi indir" STR_FONT_INSTALLED: "Yazı tipi yüklendi!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Uyku Ekranı" STR_MENU_DISP_BATTERY: "Pil simgesi" STR_MENU_DISP_REFRESH: "Ekran yenileme" STR_MENU_READER_FONT: "Okuyucu Yazı Tipi" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Okuyucu Yazı Tipi Ayarları" STR_MENU_READER_LAYOUT: "Okuyucu Düzeni" STR_MENU_READER_TWEAKS: "Okuyucu Ayarları" diff --git a/lib/I18n/translations/ukrainian.yaml b/lib/I18n/translations/ukrainian.yaml index b36ade30..44a1d457 100644 --- a/lib/I18n/translations/ukrainian.yaml +++ b/lib/I18n/translations/ukrainian.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Орієнтація читання" STR_LONG_PRESS_SKIP: "Пропуск розділу при довгому натисканні" STR_FONT_FAMILY: "Сімейство шрифтів" STR_FONT_SIZE: "Розмір шрифту інтерфейсу" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Завантаження списку шрифтів..." STR_FONT_DOWNLOAD: "Завантажити шрифт" STR_FONT_INSTALLED: "Шрифт встановлено!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Екран сну" STR_MENU_DISP_BATTERY: "Індикатор батареї" STR_MENU_DISP_REFRESH: "Оновлення екрану" STR_MENU_READER_FONT: "Шрифт читача" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Налаштування шрифту" STR_MENU_READER_LAYOUT: "Налаштування макета" STR_MENU_READER_TWEAKS: "Налаштування читача" diff --git a/lib/I18n/translations/vietnamese.yaml b/lib/I18n/translations/vietnamese.yaml index d109175d..72d5be09 100644 --- a/lib/I18n/translations/vietnamese.yaml +++ b/lib/I18n/translations/vietnamese.yaml @@ -99,6 +99,8 @@ STR_ORIENTATION: "Hướng đọc" STR_LONG_PRESS_SKIP: "Giữ lâu bỏ qua chương" STR_FONT_FAMILY: "Bộ phông đọc sách" STR_FONT_SIZE: "Cỡ chữ đọc sách" +STR_TXT_FONT_FAMILY: "TXT/MD Font Family" +STR_TXT_FONT_SIZE: "TXT/MD Font Size" STR_LOADING_FONT_LIST: "Đang tải danh sách phông chữ..." STR_FONT_DOWNLOAD: "Tải phông chữ" STR_FONT_INSTALLED: "Đã cài đặt phông chữ!" @@ -565,6 +567,7 @@ STR_MENU_DISP_SLEEP: "Màn hình ngủ" STR_MENU_DISP_BATTERY: "Biểu tượng pin" STR_MENU_DISP_REFRESH: "Làm mới màn hình" STR_MENU_READER_FONT: "Phông đọc sách" +STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Cài đặt phông" STR_MENU_READER_LAYOUT: "Cài đặt bố cục" STR_MENU_READER_TWEAKS: "Tinh chỉnh đọc sách" diff --git a/src/CrossPointSettings.cpp b/src/CrossPointSettings.cpp index d4376010..236ab434 100644 --- a/src/CrossPointSettings.cpp +++ b/src/CrossPointSettings.cpp @@ -387,3 +387,11 @@ int CrossPointSettings::getReaderFontId() const { } return getBuiltinReaderFontId(fontFamily, fontSize); } + +int CrossPointSettings::getTxtReaderFontId() const { + if (txtSdFontFamilyName[0] != '\0') { + int id = resolveSdCardFontId(txtSdFontFamilyName, txtFontSize); + if (id != 0) return id; + } + return getBuiltinReaderFontId(txtFontFamily, txtFontSize); +} diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index 01ca6454..c9b74dae 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -228,11 +228,15 @@ class CrossPointSettings { uint8_t frontButtonConfirm = FRONT_HW_CONFIRM; uint8_t frontButtonLeft = FRONT_HW_LEFT; uint8_t frontButtonRight = FRONT_HW_RIGHT; - // Reader font settings + // Reader font settings (EPUB) uint8_t fontFamily = BOOKERLY; // SD card font family name (empty = use built-in fontFamily) char sdFontFamilyName[32] = ""; uint8_t fontSize = MEDIUM; + // Reader font settings (TXT / MD) — defaults to EPUB settings when not explicitly set + uint8_t txtFontFamily = NOTOSANS; + char txtSdFontFamilyName[32] = ""; + uint8_t txtFontSize = MEDIUM; uint8_t lineSpacing = NORMAL; uint8_t paragraphAlignment = JUSTIFIED; // Auto-sleep timeout setting (default 10 minutes) @@ -358,6 +362,7 @@ class CrossPointSettings { static constexpr uint16_t getPowerButtonDuration() { return 400; } int getReaderFontId() const; + int getTxtReaderFontId() const; // Pure built-in lookup (size enum + family enum -> font ID). Independent of // SD-card font selection. Used by the per-book fontFamilyOverride path so // an override forces back to a known built-in even when an SD font is the diff --git a/src/SdCardFontGlobals.h b/src/SdCardFontGlobals.h index f10e2cd2..ad084d12 100644 --- a/src/SdCardFontGlobals.h +++ b/src/SdCardFontGlobals.h @@ -26,6 +26,10 @@ int resolveSdCardFontId(const char* familyName, uint8_t fontSizeEnum); uint8_t fontFamilyDynamicGetter(const void* ctx); void fontFamilyDynamicSetter(void* ctx, uint8_t value); +// Same as above but for the TXT/MD reader font family setting. +uint8_t txtFontFamilyDynamicGetter(const void* ctx); +void txtFontFamilyDynamicSetter(void* ctx, uint8_t value); + // Returns the total number of font-family options currently available // (BUILTIN_FONT_COUNT + number of discovered SD families). Used by the // settings UI / web layer to enrich enumLabels and to bound cycling. diff --git a/src/SdCardFontSystem.cpp b/src/SdCardFontSystem.cpp index ca9e7df3..965ee8d0 100644 --- a/src/SdCardFontSystem.cpp +++ b/src/SdCardFontSystem.cpp @@ -54,6 +54,33 @@ void fontFamilyDynamicSetter(void* /*ctx*/, uint8_t value) { } } +uint8_t txtFontFamilyDynamicGetter(const void* /*ctx*/) { + if (SETTINGS.txtSdFontFamilyName[0] != '\0') { + const auto& families = sdFontSystem.registry().getFamilies(); + for (size_t i = 0; i < families.size(); i++) { + if (families[i].name == SETTINGS.txtSdFontFamilyName) { + return static_cast(CrossPointSettings::BUILTIN_FONT_COUNT + i); + } + } + } + return SETTINGS.txtFontFamily < CrossPointSettings::BUILTIN_FONT_COUNT ? SETTINGS.txtFontFamily + : CrossPointSettings::NOTOSANS; +} + +void txtFontFamilyDynamicSetter(void* /*ctx*/, uint8_t value) { + if (value < CrossPointSettings::BUILTIN_FONT_COUNT) { + SETTINGS.txtFontFamily = value; + SETTINGS.txtSdFontFamilyName[0] = '\0'; + return; + } + const auto& families = sdFontSystem.registry().getFamilies(); + uint8_t sdIdx = value - CrossPointSettings::BUILTIN_FONT_COUNT; + if (sdIdx < families.size()) { + strncpy(SETTINGS.txtSdFontFamilyName, families[sdIdx].name.c_str(), sizeof(SETTINGS.txtSdFontFamilyName) - 1); + SETTINGS.txtSdFontFamilyName[sizeof(SETTINGS.txtSdFontFamilyName) - 1] = '\0'; + } +} + uint8_t fontFamilyOptionCount() { return static_cast(CrossPointSettings::BUILTIN_FONT_COUNT + sdFontSystem.registry().getFamilies().size()); } diff --git a/src/SettingsList.h b/src/SettingsList.h index bf827243..f92460ce 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -92,7 +92,7 @@ inline const std::vector list = { SettingInfo::Enum(StrId::STR_ORIENTATION, &CrossPointSettings::orientation, {StrId::STR_PORTRAIT, StrId::STR_LANDSCAPE_CW, StrId::STR_INVERTED, StrId::STR_LANDSCAPE_CCW}, "orientation", StrId::STR_CAT_READER), - // Font — DynamicEnum so SD card font families can be appended at the consumer + // EPUB font — DynamicEnum so SD card font families can be appended at the consumer // side (SettingsActivity / CrossPointWebServer enrich enumLabels before // iterating). The built-in StrIds are kept as a fallback for code paths that // don't enrich enumLabels. @@ -103,6 +103,15 @@ inline const std::vector list = { {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, "fontSize", StrId::STR_CAT_READER) .withSubmenu(StrId::STR_MENU_READER_FONT_SETTINGS), + // TXT/MD font — same dynamic structure as the EPUB font entry above. + SettingInfo::DynamicEnum(StrId::STR_TXT_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, + txtFontFamilyDynamicGetter, txtFontFamilyDynamicSetter, "txtFontFamily", + StrId::STR_CAT_READER) + .withSubcategory(StrId::STR_MENU_TXT_FONT), + SettingInfo::Enum(StrId::STR_TXT_FONT_SIZE, &CrossPointSettings::txtFontSize, + {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, + "txtFontSize", StrId::STR_CAT_READER) + .withSubcategory(StrId::STR_MENU_TXT_FONT), SettingInfo::Toggle(StrId::STR_TEXT_AA, &CrossPointSettings::textAntiAliasing, "textAntiAliasing", StrId::STR_CAT_READER) .withSubmenu(StrId::STR_MENU_READER_FONT_SETTINGS), diff --git a/src/activities/reader/MdReaderActivity.cpp b/src/activities/reader/MdReaderActivity.cpp index b2e7c8bc..ed7b9267 100644 --- a/src/activities/reader/MdReaderActivity.cpp +++ b/src/activities/reader/MdReaderActivity.cpp @@ -325,7 +325,7 @@ void MdReaderActivity::initializeReader() { return; } - cachedFontId = SETTINGS.getReaderFontId(); + cachedFontId = SETTINGS.getTxtReaderFontId(); cachedScreenMargin = SETTINGS.screenMargin; cachedParagraphAlignment = SETTINGS.paragraphAlignment; diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index df42479a..dbc2a912 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -273,7 +273,7 @@ void TxtReaderActivity::initializeReader() { } // Store current settings for cache validation - cachedFontId = SETTINGS.getReaderFontId(); + cachedFontId = SETTINGS.getTxtReaderFontId(); cachedScreenMargin = SETTINGS.screenMargin; cachedParagraphAlignment = SETTINGS.paragraphAlignment; @@ -710,7 +710,7 @@ bool TxtReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gfx } // Compute layout values that match what initializeReader() produces - const int fontId = SETTINGS.getReaderFontId(); + const int fontId = SETTINGS.getTxtReaderFontId(); const uint8_t screenMargin = SETTINGS.screenMargin; const uint8_t paragraphAlignment = SETTINGS.paragraphAlignment; From 3dfcdd002f97669d085d612dff54922fb5591c27 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 14 May 2026 23:44:30 +0200 Subject: [PATCH 2/7] Rearrange menus + fixes --- src/SettingsList.h | 30 +++++++++-------- .../settings/FontSelectionActivity.cpp | 32 +++++++------------ .../settings/FontSelectionActivity.h | 7 ++-- src/activities/settings/SettingsActivity.cpp | 29 +++++++++++------ src/network/CrossPointWebServer.cpp | 10 +++--- 5 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/SettingsList.h b/src/SettingsList.h index f92460ce..c9a5c147 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -92,33 +92,35 @@ inline const std::vector list = { SettingInfo::Enum(StrId::STR_ORIENTATION, &CrossPointSettings::orientation, {StrId::STR_PORTRAIT, StrId::STR_LANDSCAPE_CW, StrId::STR_INVERTED, StrId::STR_LANDSCAPE_CCW}, "orientation", StrId::STR_CAT_READER), - // EPUB font — DynamicEnum so SD card font families can be appended at the consumer + // EPUB font submenu — family first, then size/AA/darkness. + // DynamicEnum so SD card font families can be appended at the consumer // side (SettingsActivity / CrossPointWebServer enrich enumLabels before // iterating). The built-in StrIds are kept as a fallback for code paths that // don't enrich enumLabels. SettingInfo::DynamicEnum(StrId::STR_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, fontFamilyDynamicGetter, fontFamilyDynamicSetter, "fontFamily", StrId::STR_CAT_READER) - .withSubcategory(StrId::STR_MENU_READER_FONT), + .withSubcategory(StrId::STR_MENU_READER_FONT) + .withSubmenu(StrId::STR_MENU_READER_FONT), SettingInfo::Enum(StrId::STR_FONT_SIZE, &CrossPointSettings::fontSize, {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, "fontSize", StrId::STR_CAT_READER) - .withSubmenu(StrId::STR_MENU_READER_FONT_SETTINGS), - // TXT/MD font — same dynamic structure as the EPUB font entry above. - SettingInfo::DynamicEnum(StrId::STR_TXT_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, - txtFontFamilyDynamicGetter, txtFontFamilyDynamicSetter, "txtFontFamily", - StrId::STR_CAT_READER) - .withSubcategory(StrId::STR_MENU_TXT_FONT), - SettingInfo::Enum(StrId::STR_TXT_FONT_SIZE, &CrossPointSettings::txtFontSize, - {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, - "txtFontSize", StrId::STR_CAT_READER) - .withSubcategory(StrId::STR_MENU_TXT_FONT), + .withSubmenu(StrId::STR_MENU_READER_FONT), SettingInfo::Toggle(StrId::STR_TEXT_AA, &CrossPointSettings::textAntiAliasing, "textAntiAliasing", StrId::STR_CAT_READER) - .withSubmenu(StrId::STR_MENU_READER_FONT_SETTINGS), + .withSubmenu(StrId::STR_MENU_READER_FONT), SettingInfo::Enum(StrId::STR_TEXT_DARKNESS, &CrossPointSettings::textDarkness, {StrId::STR_NORMAL, StrId::STR_DARK, StrId::STR_EXTRA_DARK, StrId::STR_MAX_DARK}, "textDarkness", StrId::STR_CAT_READER) - .withSubmenu(StrId::STR_MENU_READER_FONT_SETTINGS), + .withSubmenu(StrId::STR_MENU_READER_FONT), + // TXT/MD font submenu — same dynamic structure as EPUB, includes SD card fonts. + SettingInfo::DynamicEnum(StrId::STR_TXT_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, + txtFontFamilyDynamicGetter, txtFontFamilyDynamicSetter, "txtFontFamily", + StrId::STR_CAT_READER) + .withSubmenu(StrId::STR_MENU_TXT_FONT), + SettingInfo::Enum(StrId::STR_TXT_FONT_SIZE, &CrossPointSettings::txtFontSize, + {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, + "txtFontSize", StrId::STR_CAT_READER) + .withSubmenu(StrId::STR_MENU_TXT_FONT), // Formatting settings SettingInfo::Enum( diff --git a/src/activities/settings/FontSelectionActivity.cpp b/src/activities/settings/FontSelectionActivity.cpp index bd609b6d..c3b1f583 100644 --- a/src/activities/settings/FontSelectionActivity.cpp +++ b/src/activities/settings/FontSelectionActivity.cpp @@ -6,28 +6,12 @@ #include "MappedInputManager.h" #include "SdCardFontGlobals.h" #include "components/UITheme.h" -#include "fontIds.h" - -namespace { - -uint8_t currentFontIndex() { - if (SETTINGS.sdFontFamilyName[0] != '\0') { - const auto& families = sdFontSystem.registry().getFamilies(); - for (int i = 0; i < static_cast(families.size()); i++) { - if (families[i].name == SETTINGS.sdFontFamilyName) { - return static_cast(CrossPointSettings::BUILTIN_FONT_COUNT + i); - } - } - } - return SETTINGS.fontFamily < CrossPointSettings::BUILTIN_FONT_COUNT ? SETTINGS.fontFamily : 0; -} - -} // namespace void FontSelectionActivity::onEnter() { Activity::onEnter(); fontCount = fontFamilyOptionCount(); - selectedIndex = currentFontIndex(); + selectedIndex = + static_cast(target == Target::TXT ? txtFontFamilyDynamicGetter(nullptr) : fontFamilyDynamicGetter(nullptr)); if (selectedIndex >= fontCount) selectedIndex = 0; requestUpdate(); } @@ -50,7 +34,11 @@ void FontSelectionActivity::loop() { } void FontSelectionActivity::handleSelection() { - fontFamilyDynamicSetter(nullptr, static_cast(selectedIndex)); + if (target == Target::TXT) { + txtFontFamilyDynamicSetter(nullptr, static_cast(selectedIndex)); + } else { + fontFamilyDynamicSetter(nullptr, static_cast(selectedIndex)); + } finish(); } @@ -60,13 +48,15 @@ void FontSelectionActivity::render(RenderLock&&) { const auto& metrics = UITheme::getInstance().getMetrics(); const Rect contentRect = UITheme::getContentRect(renderer, true, false); + const StrId headerStr = target == Target::TXT ? StrId::STR_TXT_FONT_FAMILY : StrId::STR_FONT_FAMILY; GUI.drawHeader(renderer, Rect{contentRect.x, metrics.topPadding, contentRect.width, metrics.headerHeight}, - tr(STR_FONT_FAMILY)); + I18N.get(headerStr)); const int contentTop = metrics.topPadding + metrics.headerHeight + metrics.verticalSpacing; const int contentHeight = contentRect.height - contentTop - metrics.verticalSpacing; - const uint8_t activeIndex = currentFontIndex(); + const uint8_t activeIndex = static_cast(target == Target::TXT ? txtFontFamilyDynamicGetter(nullptr) + : fontFamilyDynamicGetter(nullptr)); GUI.drawList( renderer, Rect{contentRect.x, contentTop, contentRect.width, contentHeight}, fontCount, selectedIndex, [](int index) { return fontFamilyOptionLabel(static_cast(index)); }, nullptr, nullptr, diff --git a/src/activities/settings/FontSelectionActivity.h b/src/activities/settings/FontSelectionActivity.h index 4ab0cf14..01b98cb5 100644 --- a/src/activities/settings/FontSelectionActivity.h +++ b/src/activities/settings/FontSelectionActivity.h @@ -11,8 +11,10 @@ class MappedInputManager; /// Replaces in-place enum cycling for the Reader Font Family setting. class FontSelectionActivity final : public Activity { public: - explicit FontSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput) - : Activity("FontSelect", renderer, mappedInput) {} + enum class Target { EPUB, TXT }; + + explicit FontSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, Target target = Target::EPUB) + : Activity("FontSelect", renderer, mappedInput), target(target) {} void onEnter() override; void onExit() override; @@ -25,4 +27,5 @@ class FontSelectionActivity final : public Activity { ButtonNavigator buttonNavigator; int selectedIndex = 0; uint8_t fontCount = 0; + Target target; }; diff --git a/src/activities/settings/SettingsActivity.cpp b/src/activities/settings/SettingsActivity.cpp index dbac7bd2..85e6b8ae 100644 --- a/src/activities/settings/SettingsActivity.cpp +++ b/src/activities/settings/SettingsActivity.cpp @@ -81,10 +81,11 @@ void SettingsActivity::onEnter() { setting.nameId == StrId::STR_TIMEZONE)) { continue; } - // Enrich the font-family entry with SD card families discovered at boot. + // Enrich font-family entries with SD card families discovered at boot. // The list itself is a namespace-static; we only mutate our local copy here. SettingInfo enriched = setting; - if (setting.key && std::strcmp(setting.key, "fontFamily") == 0) { + if (setting.key && + (std::strcmp(setting.key, "fontFamily") == 0 || std::strcmp(setting.key, "txtFontFamily") == 0)) { const uint8_t n = fontFamilyOptionCount(); enriched.enumLabels.clear(); enriched.enumLabels.reserve(n); @@ -96,8 +97,7 @@ void SettingsActivity::onEnter() { continue; } const bool isReaderFontEntry = - enriched.category == StrId::STR_CAT_READER && (enriched.subcategory == StrId::STR_MENU_READER_FONT || - enriched.submenu == StrId::STR_MENU_READER_FONT_SETTINGS); + enriched.category == StrId::STR_CAT_READER && enriched.submenu == StrId::STR_MENU_READER_FONT; if (!insertedFontDownload && sawReaderFontSection && !isReaderFontEntry) { insertFontDownloadBelowFontSection(); @@ -278,11 +278,22 @@ void SettingsActivity::toggleCurrentSetting() { if (setting.isSeparator) return; if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) { - startActivityForResult(std::make_unique(renderer, mappedInput), - [this](const ActivityResult&) { - SETTINGS.saveToFile(); - needsHalfRefresh = true; - }); + startActivityForResult( + std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::EPUB), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + }); + return; + } + + if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) { + startActivityForResult( + std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::TXT), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + }); return; } diff --git a/src/network/CrossPointWebServer.cpp b/src/network/CrossPointWebServer.cpp index 15f3e9e9..9d63b9eb 100644 --- a/src/network/CrossPointWebServer.cpp +++ b/src/network/CrossPointWebServer.cpp @@ -1257,10 +1257,10 @@ void CrossPointWebServer::handleGetSettings() const { for (const auto& sBase : settings) { if (!sBase.key) continue; // Skip ACTION-only entries - // Enrich the font-family entry with current SD card families. + // Enrich font-family entries with current SD card families. SettingInfo sLocal; const SettingInfo* sPtr = &sBase; - if (std::strcmp(sBase.key, "fontFamily") == 0) { + if (sBase.key && (std::strcmp(sBase.key, "fontFamily") == 0 || std::strcmp(sBase.key, "txtFontFamily") == 0)) { sLocal = sBase; const uint8_t n = fontFamilyOptionCount(); sLocal.enumLabels.clear(); @@ -1380,9 +1380,11 @@ void CrossPointWebServer::handlePostSettings() { } case SettingType::ENUM: { const int val = doc[s.key].as(); - // For fontFamily the enumLabels in the static list are empty by design + // For font-family keys the enumLabels in the static list are empty by design // (built lazily by handleGetSettings); use the dynamic option count instead. - const int count = (std::strcmp(s.key, "fontFamily") == 0) + const bool isFontFamilyKey = + s.key && (std::strcmp(s.key, "fontFamily") == 0 || std::strcmp(s.key, "txtFontFamily") == 0); + const int count = isFontFamilyKey ? static_cast(fontFamilyOptionCount()) : static_cast(s.enumLabels.empty() ? s.enumValues.size() : s.enumLabels.size()); if (val >= 0 && val < count) { From 25e1a64eb84f05955795c3f15b89bb5dc050c6fc Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 00:02:16 +0200 Subject: [PATCH 3/7] More fixes --- src/SdCardFontGlobals.h | 5 ++++ src/SdCardFontSystem.cpp | 30 +++++++++++++++++++ src/SdCardFontSystem.h | 4 +++ src/activities/ActivityManager.cpp | 4 +-- src/activities/settings/SettingsActivity.cpp | 3 +- .../settings/SettingsSubmenuActivity.cpp | 21 +++++++++++++ src/main.cpp | 18 +++++++++++ 7 files changed, 82 insertions(+), 3 deletions(-) diff --git a/src/SdCardFontGlobals.h b/src/SdCardFontGlobals.h index ad084d12..4282bf71 100644 --- a/src/SdCardFontGlobals.h +++ b/src/SdCardFontGlobals.h @@ -11,6 +11,11 @@ extern SdCardFontSystem sdFontSystem; // Defined in main.cpp; call before entering the reader or after settings change. extern void ensureSdFontLoaded(); +// Ensure the correct SD card font family is loaded for the given book path. +// Selects EPUB or TXT/MD settings depending on the file extension. +// Defined in main.cpp. +extern void ensureSdFontLoadedForPath(const char* path); + // Resolve the SD card font ID for the given family name and font size enum. // Returns 0 if no SD font with that family name and size is currently loaded. // Free function (not stored as a callback in CrossPointSettings) so the linker diff --git a/src/SdCardFontSystem.cpp b/src/SdCardFontSystem.cpp index 965ee8d0..d2e880eb 100644 --- a/src/SdCardFontSystem.cpp +++ b/src/SdCardFontSystem.cpp @@ -179,6 +179,36 @@ static uint8_t targetPtSizeFromEnum(uint8_t fontSizeEnum) { return FONT_SIZE_TO_PT[fontSizeEnum]; } +void SdCardFontSystem::ensureLoaded(GfxRenderer& renderer, const char* wantedFamily, uint8_t fontSizeEnum) { + const std::string& currentFamily = manager_.currentFamilyName(); + const uint8_t targetPt = targetPtSizeFromEnum(fontSizeEnum); + + if (!wantedFamily || wantedFamily[0] == '\0') { + if (!currentFamily.empty()) manager_.unloadAll(renderer); + return; + } + + bool familyMatches = (currentFamily == wantedFamily); + if (familyMatches) { + const auto* family = registry_.findFamily(wantedFamily); + if (!family) { + manager_.unloadAll(renderer); + return; + } + const auto* best = family->pickClosestSize(targetPt); + if (best && best->pointSize == manager_.currentPointSize()) return; + } + + if (!currentFamily.empty()) manager_.unloadAll(renderer); + + const auto* family = registry_.findFamily(wantedFamily); + if (family) { + if (!manager_.loadFamily(*family, renderer, targetPt)) { + LOG_ERR("SDFS", "Failed to load SD font family: %s", wantedFamily); + } + } +} + int SdCardFontSystem::resolveFontId(const char* familyName, uint8_t fontSizeEnum) const { // The manager loads exactly one size for the active SD family. Resolve only // if the requested family matches the loaded family and the requested size diff --git a/src/SdCardFontSystem.h b/src/SdCardFontSystem.h index 11457539..ac3aee41 100644 --- a/src/SdCardFontSystem.h +++ b/src/SdCardFontSystem.h @@ -19,6 +19,10 @@ class SdCardFontSystem { /// Call before entering the reader or after settings change. void ensureLoaded(GfxRenderer& renderer); + /// Ensure the correct SD font family is loaded for an explicit family + size. + /// Used when the reader type determines which settings field to consult. + void ensureLoaded(GfxRenderer& renderer, const char* familyName, uint8_t fontSizeEnum); + /// Resolve an SD card font ID from family name + fontSize enum. /// Returns 0 if not found. Used by CrossPointSettings::getReaderFontId(). int resolveFontId(const char* familyName, uint8_t fontSizeEnum) const; diff --git a/src/activities/ActivityManager.cpp b/src/activities/ActivityManager.cpp index 593e9d45..a40826f8 100644 --- a/src/activities/ActivityManager.cpp +++ b/src/activities/ActivityManager.cpp @@ -286,7 +286,7 @@ void ActivityManager::goToBrowser() { void ActivityManager::goToReader(std::string path) { RenderLock lock; - ensureSdFontLoaded(); + ensureSdFontLoadedForPath(path.c_str()); replaceActivity(std::make_unique(renderer, mappedInput, std::move(path))); } @@ -307,7 +307,7 @@ void ActivityManager::replaceWithReader(std::string path, ReturnHint hint) { returnHint = std::move(hint); hasReturnHint = true; RenderLock lock; - ensureSdFontLoaded(); + ensureSdFontLoadedForPath(path.c_str()); replaceActivity(std::make_unique(renderer, mappedInput, std::move(path))); } diff --git a/src/activities/settings/SettingsActivity.cpp b/src/activities/settings/SettingsActivity.cpp index 85e6b8ae..13e6850f 100644 --- a/src/activities/settings/SettingsActivity.cpp +++ b/src/activities/settings/SettingsActivity.cpp @@ -97,7 +97,8 @@ void SettingsActivity::onEnter() { continue; } const bool isReaderFontEntry = - enriched.category == StrId::STR_CAT_READER && enriched.submenu == StrId::STR_MENU_READER_FONT; + enriched.category == StrId::STR_CAT_READER && + (enriched.submenu == StrId::STR_MENU_READER_FONT || enriched.submenu == StrId::STR_MENU_TXT_FONT); if (!insertedFontDownload && sawReaderFontSection && !isReaderFontEntry) { insertFontDownloadBelowFontSection(); diff --git a/src/activities/settings/SettingsSubmenuActivity.cpp b/src/activities/settings/SettingsSubmenuActivity.cpp index 1dc4c5e8..754bac00 100644 --- a/src/activities/settings/SettingsSubmenuActivity.cpp +++ b/src/activities/settings/SettingsSubmenuActivity.cpp @@ -6,6 +6,7 @@ #include #include "CrossPointSettings.h" +#include "FontSelectionActivity.h" #include "MappedInputManager.h" #include "SettingActionDispatch.h" #include "components/UITheme.h" @@ -22,6 +23,26 @@ void SettingsSubmenuActivity::onActionSelected(int index) { const auto& setting = menuItems[index]; if (setting.isSeparator) return; + if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) { + startActivityForResult( + std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::EPUB), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + }); + return; + } + + if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) { + startActivityForResult( + std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::TXT), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + }); + return; + } + if (setting.type == SettingType::ACTION) { MenuResult menuResult; if (setting.action != SettingAction::None) { diff --git a/src/main.cpp b/src/main.cpp index f46564eb..6d92e140 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -191,6 +191,24 @@ void setupDisplayAndFonts() { // activity-side callers out of SdCardFontSystem internals. void ensureSdFontLoaded() { sdFontSystem.ensureLoaded(renderer); } +void ensureSdFontLoadedForPath(const char* path) { + if (!path) { + ensureSdFontLoaded(); + return; + } + const size_t len = strlen(path); + auto endsWith = [&](const char* suffix) { + const size_t sl = strlen(suffix); + return len >= sl && strcasecmp(path + len - sl, suffix) == 0; + }; + const bool isTxtMd = endsWith(".txt") || endsWith(".md"); + if (isTxtMd) { + sdFontSystem.ensureLoaded(renderer, SETTINGS.txtSdFontFamilyName, SETTINGS.txtFontSize); + } else { + sdFontSystem.ensureLoaded(renderer, SETTINGS.sdFontFamilyName, SETTINGS.fontSize); + } +} + void setup() { { esp_ota_img_states_t otaState; From b11ba14af38f3777b92dc22923ecbc09385e30a8 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 00:14:27 +0200 Subject: [PATCH 4/7] Fix lost font selector --- src/SettingsList.h | 6 ++- src/activities/settings/SettingInfo.h | 9 ++++ src/activities/settings/SettingsActivity.cpp | 25 ++++------- .../settings/SettingsSubmenuActivity.cpp | 41 ++++++++++--------- .../settings/SettingsSubmenuActivity.h | 1 + 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/SettingsList.h b/src/SettingsList.h index c9a5c147..576b3853 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -100,7 +100,8 @@ inline const std::vector list = { SettingInfo::DynamicEnum(StrId::STR_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, fontFamilyDynamicGetter, fontFamilyDynamicSetter, "fontFamily", StrId::STR_CAT_READER) .withSubcategory(StrId::STR_MENU_READER_FONT) - .withSubmenu(StrId::STR_MENU_READER_FONT), + .withSubmenu(StrId::STR_MENU_READER_FONT) + .withSelectorActivity(), SettingInfo::Enum(StrId::STR_FONT_SIZE, &CrossPointSettings::fontSize, {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, "fontSize", StrId::STR_CAT_READER) @@ -116,7 +117,8 @@ inline const std::vector list = { SettingInfo::DynamicEnum(StrId::STR_TXT_FONT_FAMILY, {StrId::STR_BOOKERLY, StrId::STR_NOTO_SANS}, txtFontFamilyDynamicGetter, txtFontFamilyDynamicSetter, "txtFontFamily", StrId::STR_CAT_READER) - .withSubmenu(StrId::STR_MENU_TXT_FONT), + .withSubmenu(StrId::STR_MENU_TXT_FONT) + .withSelectorActivity(), SettingInfo::Enum(StrId::STR_TXT_FONT_SIZE, &CrossPointSettings::txtFontSize, {StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE, StrId::STR_TINY}, "txtFontSize", StrId::STR_CAT_READER) diff --git a/src/activities/settings/SettingInfo.h b/src/activities/settings/SettingInfo.h index 3ca8d3bd..5b61b6b2 100644 --- a/src/activities/settings/SettingInfo.h +++ b/src/activities/settings/SettingInfo.h @@ -221,9 +221,18 @@ struct SettingInfo { } bool isSeparator = false; + bool usesSelectorActivity = false; // Confirm opens a full-screen selector instead of inline cycling StrId subcategory = StrId::STR_NONE_OPT; // Triggers a separator row on first use and on change StrId submenu = StrId::STR_NONE_OPT; // Routes item into a submenu; hidden from main list + // Marks this entry as requiring a full-screen selector activity on Confirm + // (instead of inline value cycling). The SettingsActivity / SettingsSubmenuActivity + // intercept entries with this flag before toggleValue() is called. + SettingInfo& withSelectorActivity() { + usesSelectorActivity = true; + return *this; + } + // Inserts a separator row in the parent tab when this item's subcategory first appears or changes. SettingInfo& withSubcategory(StrId sub) { subcategory = sub; diff --git a/src/activities/settings/SettingsActivity.cpp b/src/activities/settings/SettingsActivity.cpp index 13e6850f..3c160da5 100644 --- a/src/activities/settings/SettingsActivity.cpp +++ b/src/activities/settings/SettingsActivity.cpp @@ -278,23 +278,14 @@ void SettingsActivity::toggleCurrentSetting() { const auto& setting = (*currentSettings)[selectedSetting]; if (setting.isSeparator) return; - if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) { - startActivityForResult( - std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::EPUB), - [this](const ActivityResult&) { - SETTINGS.saveToFile(); - needsHalfRefresh = true; - }); - return; - } - - if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) { - startActivityForResult( - std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::TXT), - [this](const ActivityResult&) { - SETTINGS.saveToFile(); - needsHalfRefresh = true; - }); + if (setting.usesSelectorActivity) { + const auto target = (setting.valueGetter == txtFontFamilyDynamicGetter) ? FontSelectionActivity::Target::TXT + : FontSelectionActivity::Target::EPUB; + startActivityForResult(std::make_unique(renderer, mappedInput, target), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + }); return; } diff --git a/src/activities/settings/SettingsSubmenuActivity.cpp b/src/activities/settings/SettingsSubmenuActivity.cpp index 754bac00..8ce26963 100644 --- a/src/activities/settings/SettingsSubmenuActivity.cpp +++ b/src/activities/settings/SettingsSubmenuActivity.cpp @@ -8,6 +8,7 @@ #include "CrossPointSettings.h" #include "FontSelectionActivity.h" #include "MappedInputManager.h" +#include "SdCardFontGlobals.h" #include "SettingActionDispatch.h" #include "components/UITheme.h" #include "fontIds.h" @@ -23,26 +24,6 @@ void SettingsSubmenuActivity::onActionSelected(int index) { const auto& setting = menuItems[index]; if (setting.isSeparator) return; - if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_FONT_FAMILY) { - startActivityForResult( - std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::EPUB), - [this](const ActivityResult&) { - SETTINGS.saveToFile(); - needsHalfRefresh = true; - }); - return; - } - - if (setting.type == SettingType::ENUM && setting.nameId == StrId::STR_TXT_FONT_FAMILY) { - startActivityForResult( - std::make_unique(renderer, mappedInput, FontSelectionActivity::Target::TXT), - [this](const ActivityResult&) { - SETTINGS.saveToFile(); - needsHalfRefresh = true; - }); - return; - } - if (setting.type == SettingType::ACTION) { MenuResult menuResult; if (setting.action != SettingAction::None) { @@ -69,6 +50,26 @@ std::string SettingsSubmenuActivity::getItemValueString(int index) const { return MenuListActivity::getItemValueString(index); } +void SettingsSubmenuActivity::toggleCurrentItem() { + if (selectedIndex < 0 || selectedIndex >= static_cast(menuItems.size())) return; + const auto& setting = menuItems[selectedIndex]; + if (setting.isSeparator) return; + + if (setting.usesSelectorActivity) { + const auto target = (setting.valueGetter == txtFontFamilyDynamicGetter) ? FontSelectionActivity::Target::TXT + : FontSelectionActivity::Target::EPUB; + startActivityForResult(std::make_unique(renderer, mappedInput, target), + [this](const ActivityResult&) { + SETTINGS.saveToFile(); + needsHalfRefresh = true; + requestUpdate(); + }); + return; + } + + MenuListActivity::toggleCurrentItem(); +} + void SettingsSubmenuActivity::onSettingToggled(int /*index*/) { SETTINGS.saveToFile(); } void SettingsSubmenuActivity::render(RenderLock&&) { diff --git a/src/activities/settings/SettingsSubmenuActivity.h b/src/activities/settings/SettingsSubmenuActivity.h index 91b0f4b6..741fb386 100644 --- a/src/activities/settings/SettingsSubmenuActivity.h +++ b/src/activities/settings/SettingsSubmenuActivity.h @@ -16,6 +16,7 @@ class SettingsSubmenuActivity final : public MenuListActivity { // MenuListActivity overrides void onEnter() override; + void toggleCurrentItem() override; void onActionSelected(int index) override; void onSettingToggled(int index) override; std::string getItemValueString(int index) const override; From 084263ad3916a124fee2c29fe9394ab638ea17bb Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 00:16:28 +0200 Subject: [PATCH 5/7] Persist settings --- src/JsonSettingsIO.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/JsonSettingsIO.cpp b/src/JsonSettingsIO.cpp index e7ceb177..a283e53e 100644 --- a/src/JsonSettingsIO.cpp +++ b/src/JsonSettingsIO.cpp @@ -213,6 +213,11 @@ bool JsonSettingsIO::saveSettings(const CrossPointSettings& s, const char* path) if (s.sdFontFamilyName[0] != '\0') { doc["sdFontFamilyName"] = s.sdFontFamilyName; } + // TXT/MD font family also uses DynamicEnumCtx (no valuePtr); save manually. + doc["txtFontFamily"] = s.txtFontFamily; + if (s.txtSdFontFamilyName[0] != '\0') { + doc["txtSdFontFamilyName"] = s.txtSdFontFamilyName; + } doc["moveFinishedBooksToCompleted"] = s.moveFinishedBooksToCompleted; doc["removeFinishedBooksFromRecents"] = s.removeFinishedBooksFromRecents; @@ -329,6 +334,12 @@ bool JsonSettingsIO::loadSettings(CrossPointSettings& s, const char* json, bool* const char* sfn = doc["sdFontFamilyName"] | ""; strncpy(s.sdFontFamilyName, sfn, sizeof(s.sdFontFamilyName) - 1); s.sdFontFamilyName[sizeof(s.sdFontFamilyName) - 1] = '\0'; + // TXT/MD font family is dynamic too; load manually. + s.txtFontFamily = clamp(doc["txtFontFamily"] | (uint8_t)CrossPointSettings::NOTOSANS, + CrossPointSettings::BUILTIN_FONT_COUNT, CrossPointSettings::NOTOSANS); + const char* txtSfn = doc["txtSdFontFamilyName"] | ""; + strncpy(s.txtSdFontFamilyName, txtSfn, sizeof(s.txtSdFontFamilyName) - 1); + s.txtSdFontFamilyName[sizeof(s.txtSdFontFamilyName) - 1] = '\0'; s.moveFinishedBooksToCompleted = doc["moveFinishedBooksToCompleted"] | (uint8_t)0; s.removeFinishedBooksFromRecents = doc["removeFinishedBooksFromRecents"] | (uint8_t)0; From 2e1db2ec68af3abdd8d812a73e68fb7d0a022bb1 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 00:21:31 +0200 Subject: [PATCH 6/7] Moe changes --- lib/I18n/translations/english.yaml | 2 +- src/activities/boot_sleep/SleepActivity.cpp | 4 ++-- src/main.cpp | 8 ++------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 78ff9fd0..916f1235 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -569,7 +569,7 @@ STR_MENU_SYS_TOOLS: "Tools" STR_MENU_DISP_SLEEP: "Sleep Screen" STR_MENU_DISP_BATTERY: "Battery symbol" STR_MENU_DISP_REFRESH: "Screen refresh" -STR_MENU_READER_FONT: "EPUB Font" +STR_MENU_READER_FONT: "Reader Font" STR_MENU_TXT_FONT: "TXT/MD Font" STR_MENU_READER_FONT_SETTINGS: "Font Settings" STR_MENU_READER_LAYOUT: "Layout Settings" diff --git a/src/activities/boot_sleep/SleepActivity.cpp b/src/activities/boot_sleep/SleepActivity.cpp index 808269e4..21fbc073 100644 --- a/src/activities/boot_sleep/SleepActivity.cpp +++ b/src/activities/boot_sleep/SleepActivity.cpp @@ -494,7 +494,7 @@ BookOverlayInfo SleepActivity::getBookOverlayInfo(const std::string& bookPath) c f.close(); } } - } else if (FsHelpers::checkFileExtension(bookPath, ".txt")) { + } else if (FsHelpers::hasTxtExtension(bookPath) || FsHelpers::hasMarkdownExtension(bookPath)) { Txt txt(bookPath, "/.crosspoint"); if (txt.load()) { info.title = txt.getTitle(); @@ -834,7 +834,7 @@ void SleepActivity::renderOverlaySleepScreen() const { if (FsHelpers::checkFileExtension(path, ".xtc") || FsHelpers::checkFileExtension(path, ".xtch")) { rendered = XtcReaderActivity::drawCurrentPageToBuffer(path, renderer); - } else if (FsHelpers::checkFileExtension(path, ".txt")) { + } else if (FsHelpers::hasTxtExtension(path) || FsHelpers::hasMarkdownExtension(path)) { rendered = TxtReaderActivity::drawCurrentPageToBuffer(path, renderer); } else if (FsHelpers::checkFileExtension(path, ".epub")) { rendered = EpubReaderActivity::drawCurrentPageToBuffer(path, renderer); diff --git a/src/main.cpp b/src/main.cpp index 6d92e140..3c1ac567 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -196,12 +197,7 @@ void ensureSdFontLoadedForPath(const char* path) { ensureSdFontLoaded(); return; } - const size_t len = strlen(path); - auto endsWith = [&](const char* suffix) { - const size_t sl = strlen(suffix); - return len >= sl && strcasecmp(path + len - sl, suffix) == 0; - }; - const bool isTxtMd = endsWith(".txt") || endsWith(".md"); + const bool isTxtMd = FsHelpers::hasTxtExtension(path) || FsHelpers::hasMarkdownExtension(path); if (isTxtMd) { sdFontSystem.ensureLoaded(renderer, SETTINGS.txtSdFontFamilyName, SETTINGS.txtFontSize); } else { From 85749b9991677d5b0f03a59f6df6e762c01ee5d6 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 10:06:09 +0200 Subject: [PATCH 7/7] Fix --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3c1ac567..09a04b1d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -197,7 +197,9 @@ void ensureSdFontLoadedForPath(const char* path) { ensureSdFontLoaded(); return; } - const bool isTxtMd = FsHelpers::hasTxtExtension(path) || FsHelpers::hasMarkdownExtension(path); + const std::string_view filePath(path); + const bool isTxtMd = static_cast(FsHelpers::hasTxtExtension)(filePath) || + static_cast(FsHelpers::hasMarkdownExtension)(filePath); if (isTxtMd) { sdFontSystem.ensureLoaded(renderer, SETTINGS.txtSdFontFamilyName, SETTINGS.txtFontSize); } else {