feat: add --overlay-font-family option for caption font customization
Allow users to specify a custom font family for the overlay captions via a new --overlay-font-family flag, defaulting to "Sans". Validation ensures the font family is not empty. Updated README, config, and tests.
This commit is contained in:
@@ -4,11 +4,13 @@ package config
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultModelsDir = "models"
|
||||
DefaultOverlayFontFamily = "Sans"
|
||||
MinimumOverlayFinalLifetime = 3 * time.Second
|
||||
)
|
||||
|
||||
@@ -60,6 +62,7 @@ type OverlaySettings struct {
|
||||
Backend OverlayBackend
|
||||
Opacity float64
|
||||
FontSize int
|
||||
FontFamily string
|
||||
BottomMargin int
|
||||
MaxWidth int
|
||||
Monitor string
|
||||
@@ -88,6 +91,7 @@ func ParseDesktop() DesktopSettings {
|
||||
flags.StringVar(&backend, "overlay-backend", "auto", "display backend: auto, wayland, or x11")
|
||||
flags.Float64Var(&desktop.Overlay.Opacity, "overlay-opacity", 0.90, "caption background opacity from 0 to 1")
|
||||
flags.IntVar(&desktop.Overlay.FontSize, "overlay-font-size", 28, "caption font size in logical pixels")
|
||||
flags.StringVar(&desktop.Overlay.FontFamily, "overlay-font-family", DefaultOverlayFontFamily, "caption font family")
|
||||
flags.IntVar(&desktop.Overlay.BottomMargin, "overlay-bottom-margin", 100, "distance from the monitor bottom in logical pixels")
|
||||
flags.IntVar(&desktop.Overlay.MaxWidth, "overlay-max-width", 1200, "fixed caption width in logical pixels before the monitor safety cap")
|
||||
flags.StringVar(&desktop.Overlay.Monitor, "overlay-monitor", "auto", "monitor selection: auto, numeric index, or connector name")
|
||||
@@ -129,6 +133,9 @@ func (s DesktopSettings) Validate() error {
|
||||
if s.Overlay.FontSize <= 0 {
|
||||
return errors.New("--overlay-font-size must be positive")
|
||||
}
|
||||
if strings.TrimSpace(s.Overlay.FontFamily) == "" {
|
||||
return errors.New("--overlay-font-family cannot be empty")
|
||||
}
|
||||
if s.Overlay.BottomMargin < 0 {
|
||||
return errors.New("--overlay-bottom-margin cannot be negative")
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func validDesktopSettings() DesktopSettings {
|
||||
Settings: Settings{Mode: ModeVAD, ChunkDuration: time.Second, Threads: 2},
|
||||
Output: OutputOverlay,
|
||||
Overlay: OverlaySettings{
|
||||
Backend: BackendAuto, Opacity: 0.9, FontSize: 28, BottomMargin: 100,
|
||||
Backend: BackendAuto, Opacity: 0.9, FontSize: 28, FontFamily: DefaultOverlayFontFamily, BottomMargin: 100,
|
||||
MaxWidth: 1200, Monitor: "auto", FinalTimeout: 4 * time.Second, ClickThrough: true,
|
||||
},
|
||||
}
|
||||
@@ -40,6 +40,7 @@ func TestDesktopSettingsValidate(t *testing.T) {
|
||||
{"negative opacity", func(s *DesktopSettings) { s.Overlay.Opacity = -0.1 }},
|
||||
{"large opacity", func(s *DesktopSettings) { s.Overlay.Opacity = 1.1 }},
|
||||
{"zero font", func(s *DesktopSettings) { s.Overlay.FontSize = 0 }},
|
||||
{"empty font family", func(s *DesktopSettings) { s.Overlay.FontFamily = " " }},
|
||||
{"negative margin", func(s *DesktopSettings) { s.Overlay.BottomMargin = -1 }},
|
||||
{"zero width", func(s *DesktopSettings) { s.Overlay.MaxWidth = 0 }},
|
||||
{"empty monitor", func(s *DesktopSettings) { s.Overlay.Monitor = "" }},
|
||||
|
||||
Reference in New Issue
Block a user