summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-15 03:40:06 -0600
committerCraig Jennings <c@cjennings.net>2025-11-15 03:40:06 -0600
commit72f2ed186ee9d226503ce39037b1e26b53d203fa (patch)
tree27629b0a0e0b9efa927e228e1e24e8686282600f
parent8126e7334bd86d06775c7cf72042b840b314beb2 (diff)
feat(epub): Improve nov reader typography and layout
- Reduce variable-pitch font from 1.8x to 1.0x for normal reading size - Add configurable margin percentage (cj/nov-margin-percent, default 25%) - Calculate text width dynamically based on window size and margins - Text now uses 50% of window width with 25% margins on each side 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
-rw-r--r--modules/calibredb-epub-config.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/calibredb-epub-config.el b/modules/calibredb-epub-config.el
index ab9defd0..cf4b65ba 100644
--- a/modules/calibredb-epub-config.el
+++ b/modules/calibredb-epub-config.el
@@ -87,6 +87,10 @@
;; ------------------------------ Nov Epub Reader ------------------------------
+(defvar cj/nov-margin-percent 25
+ "Percentage of window width to use as margins on each side when reading epubs.
+For example, 25 means 25% left margin + 25% right margin, with 50% for text.")
+
;; Prevent magic-fallback-mode-alist from opening epub as archive-mode
;; Advise set-auto-mode to force nov-mode for .epub files before magic-fallback runs
(defun cj/force-nov-mode-for-epub (orig-fun &rest args)
@@ -123,7 +127,7 @@
(interactive)
;; Use Merriweather for comfortable reading with appropriate scaling
;; Darker sepia color (#E8DCC0) is easier on the eyes than pure white
- (face-remap-add-relative 'variable-pitch :family "Merriweather" :height 1.8 :foreground "#E8DCC0")
+ (face-remap-add-relative 'variable-pitch :family "Merriweather" :height 1.0 :foreground "#E8DCC0")
(face-remap-add-relative 'default :family "Merriweather" :height 180 :foreground "#E8DCC0")
(face-remap-add-relative 'fixed-pitch :height 180 :foreground "#E8DCC0")
;; Make this buffer-local so other Nov buffers can choose differently
@@ -136,8 +140,14 @@
;; Enable visual-fill-column for centered text with margins
(when (require 'visual-fill-column nil t)
(setq-local visual-fill-column-center-text t)
- ;; Set text width for comfortable reading (characters per line)
- (setq-local visual-fill-column-width 100)
+ ;; Calculate text width based on configurable margin percentage
+ (let ((window (get-buffer-window (current-buffer)))
+ (text-width-ratio (- 1.0 (* 2 (/ cj/nov-margin-percent 100.0)))))
+ (if window
+ (setq-local visual-fill-column-width
+ (floor (* text-width-ratio (window-body-width window))))
+ ;; Fallback if no window yet
+ (setq-local visual-fill-column-width 80)))
(visual-fill-column-mode 1))
(nov-render-document)
;; Force visual-fill-column to recalculate after rendering