Created
September 2, 2025 20:21
-
-
Save mallomar/2dce591a5df3f8d9cd489047180b762a to your computer and use it in GitHub Desktop.
A patch to maximize the size of the chapter name in the status bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 2-chapter-title-spacing.lua | |
| -- Fix for chapter title truncation in footer | |
| local logger = require("logger") | |
| logger.info("=== CHAPTER TITLE SPACING FIX STARTING ===") | |
| -- Wait for UI to load, then modify the footer text fitting behavior | |
| local UIManager = require("ui/uimanager") | |
| UIManager:scheduleIn(3, function() | |
| logger.info("Starting to patch getFittedText method") | |
| local ok, ReaderFooter = pcall(require, "apps/reader/modules/readerfooter") | |
| if ok and ReaderFooter then | |
| logger.info("Found ReaderFooter module") | |
| -- Override getFittedText to be more generous with chapter titles | |
| if ReaderFooter.getFittedText and not ReaderFooter._spacing_fix_patched then | |
| ReaderFooter._spacing_fix_patched = true | |
| local orig_getFittedText = ReaderFooter.getFittedText | |
| ReaderFooter.getFittedText = function(self, text, ...) | |
| local args = {...} | |
| local width = args[1] | |
| -- If this looks like a chapter title (contains common chapter title words) | |
| local is_chapter_title = text and ( | |
| text:find("Chapter") or | |
| text:find("Part") or | |
| text:find("Book") or | |
| text:find("Legend") or | |
| text:find("Story") or | |
| text:find("Tale") or | |
| -- Add more patterns as needed | |
| (text:len() > 30) -- Long titles are likely chapter titles | |
| ) | |
| if is_chapter_title and width then | |
| -- Give chapter titles 50% more width allowance | |
| local new_width = math.floor(width * 1.5) | |
| args[1] = new_width | |
| logger.info("SPACING FIX: Giving chapter title extra width: " .. width .. " -> " .. new_width) | |
| logger.info("SPACING FIX: Chapter title: " .. text) | |
| local result = orig_getFittedText(self, text, unpack(args)) | |
| logger.info("SPACING FIX: Result: " .. tostring(result)) | |
| return result | |
| else | |
| -- Use original behavior for non-chapter text | |
| return orig_getFittedText(self, text, ...) | |
| end | |
| end | |
| logger.info("Successfully patched ReaderFooter.getFittedText") | |
| else | |
| logger.warn("Could not find or patch getFittedText method") | |
| end | |
| else | |
| logger.warn("Could not find ReaderFooter module") | |
| end | |
| logger.info("Chapter title spacing fix applied") | |
| end) | |
| logger.info("=== CHAPTER TITLE SPACING FIX SETUP COMPLETE ===") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment