hdmistat/internal/font/font.go
sneak 402c0797d5 Initial implementation of hdmistat - Linux framebuffer system stats display
Features:
- Beautiful system statistics display using IBM Plex Mono font
- Direct framebuffer rendering without X11/Wayland
- Multiple screens with automatic carousel rotation
- Real-time system monitoring (CPU, memory, disk, network, processes)
- Systemd service integration with install command
- Clean architecture using uber/fx dependency injection

Architecture:
- Cobra CLI with daemon, install, status, and info commands
- Modular design with separate packages for display, rendering, and stats
- Font embedding for zero runtime dependencies
- Layout API for clean text rendering
- Support for multiple screen types (overview, top CPU, top memory)

Technical details:
- Uses gopsutil for cross-platform system stats collection
- Direct Linux framebuffer access via memory mapping
- Anti-aliased text rendering with freetype
- Configurable screen rotation and update intervals
- Structured logging with slog
- Comprehensive test coverage and linting setup

This initial version provides a solid foundation for displaying rich
system information on resource-constrained devices like Raspberry Pis.
2025-07-23 12:55:42 +02:00

45 lines
1.1 KiB
Go

package font
import (
_ "embed"
"fmt"
"github.com/golang/freetype/truetype"
)
//go:embed fonts/IBM_Plex_Mono/IBMPlexMono-ExtraLight.ttf
var ibmPlexMonoLight []byte
//go:embed fonts/IBM_Plex_Mono/IBMPlexMono-Regular.ttf
var ibmPlexMonoRegular []byte
//go:embed fonts/IBM_Plex_Mono/IBMPlexMono-Bold.ttf
var ibmPlexMonoBold []byte
// LoadIBMPlexMono loads the embedded IBM Plex Mono font (Light weight)
func LoadIBMPlexMono() (*truetype.Font, error) {
font, err := truetype.Parse(ibmPlexMonoLight)
if err != nil {
return nil, fmt.Errorf("parsing font: %w", err)
}
return font, nil
}
// LoadIBMPlexMonoRegular loads the regular weight font
func LoadIBMPlexMonoRegular() (*truetype.Font, error) {
font, err := truetype.Parse(ibmPlexMonoRegular)
if err != nil {
return nil, fmt.Errorf("parsing regular font: %w", err)
}
return font, nil
}
// LoadIBMPlexMonoBold loads the bold weight font
func LoadIBMPlexMonoBold() (*truetype.Font, error) {
font, err := truetype.Parse(ibmPlexMonoBold)
if err != nil {
return nil, fmt.Errorf("parsing bold font: %w", err)
}
return font, nil
}