Coverage for fastblocks/adapters/fonts/_base.py: 100%
19 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-09 00:47 -0700
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-09 00:47 -0700
1"""Base classes and protocols for font adapters."""
3from contextlib import suppress
4from typing import Protocol
5from uuid import UUID
7from acb.config import AdapterBase, Settings
8from acb.depends import depends
11class FontsBaseSettings(Settings): # type: ignore[misc]
12 """Base settings for font adapters."""
14 primary_font: str = "Arial, sans-serif"
15 secondary_font: str = "Georgia, serif"
16 cdn_url: str | None = None
17 font_weights: list[str] = ["400", "700"]
20class FontsProtocol(Protocol):
21 """Protocol for font adapter implementations."""
23 async def get_font_import(self) -> str: ...
24 def get_font_family(self, font_type: str) -> str: ...
27class FontsBase(AdapterBase): # type: ignore[misc]
28 """Base class for font adapters."""
30 # Required ACB 0.19.0+ metadata
31 MODULE_ID: UUID = UUID("01937d86-4f2a-7b3c-8d9e-f3b4d3c2b1a4") # Static UUID7
32 MODULE_STATUS = "stable"
34 def __init__(self) -> None:
35 """Initialize font adapter."""
36 # Register with ACB dependency system
37 with suppress(Exception):
38 depends.set(self)
40 async def get_font_import(self) -> str:
41 """Generate font import statements."""
42 raise NotImplementedError()
44 def get_font_family(self, font_type: str) -> str:
45 """Get font family CSS values."""
46 raise NotImplementedError()