# Bundled Fonts

This directory contains free, open-source TrueType fonts bundled with pyWebLayout for consistent rendering across all platforms.

## Font Families

### DejaVu Sans (Sans-serif)
A modern, clean sans-serif font excellent for body text and UI elements.

- `DejaVuSans.ttf` - Regular
- `DejaVuSans-Bold.ttf` - Bold
- `DejaVuSans-Oblique.ttf` - Italic
- `DejaVuSans-BoldOblique.ttf` - Bold Italic

### DejaVu Serif (Serif)
A classic serif font ideal for formal documents and traditional layouts.

- `DejaVuSerif.ttf` - Regular
- `DejaVuSerif-Bold.ttf` - Bold
- `DejaVuSerif-Italic.ttf` - Italic
- `DejaVuSerif-BoldItalic.ttf` - Bold Italic

### DejaVu Sans Mono (Monospace)
A fixed-width font perfect for code blocks and technical content.

- `DejaVuSansMono.ttf` - Regular
- `DejaVuSansMono-Bold.ttf` - Bold
- `DejaVuSansMono-Oblique.ttf` - Italic
- `DejaVuSansMono-BoldOblique.ttf` - Bold Italic

## Usage

### Easy Way: Using Font.from_family() (Recommended)

The easiest way to use bundled fonts is with the `Font.from_family()` class method:

```python
from pyWebLayout.style import Font, BundledFont, FontWeight, FontStyle

# Create a sans-serif font
sans_font = Font.from_family(
    BundledFont.SANS,
    font_size=16
)

# Create a bold serif font
serif_bold = Font.from_family(
    BundledFont.SERIF,
    font_size=18,
    weight=FontWeight.BOLD
)

# Create an italic monospace font
mono_italic = Font.from_family(
    BundledFont.MONOSPACE,
    font_size=14,
    style=FontStyle.ITALIC
)

# Create a bold italic sans font
sans_bold_italic = Font.from_family(
    BundledFont.SANS,
    font_size=16,
    weight=FontWeight.BOLD,
    style=FontStyle.ITALIC
)
```

### Manual Way: Using get_bundled_font_path()

You can also get the path to bundled fonts directly:

```python
from pyWebLayout.style import Font, BundledFont, FontWeight, FontStyle, get_bundled_font_path

# Get the path to a specific font
font_path = get_bundled_font_path(
    BundledFont.SERIF,
    weight=FontWeight.BOLD,
    style=FontStyle.ITALIC
)

# Create a font with that path
font = Font(font_path=font_path, font_size=16)
```

### Low-level Way: Direct Paths

If you prefer to specify paths directly:

```python
import os
from pyWebLayout.style import Font, get_bundled_fonts_dir

# Get the fonts directory
fonts_dir = get_bundled_fonts_dir()

# Use specific font files
sans_font = Font(
    font_path=os.path.join(fonts_dir, 'DejaVuSans.ttf'),
    font_size=16
)

serif_bold = Font(
    font_path=os.path.join(fonts_dir, 'DejaVuSerif-Bold.ttf'),
    font_size=18
)

mono_italic = Font(
    font_path=os.path.join(fonts_dir, 'DejaVuSansMono-Oblique.ttf'),
    font_size=14
)
```

## License

The DejaVu fonts are free software under the terms of the Bitstream Vera Fonts Copyright and the Arev Fonts Copyright.

See `DEJAVU_LICENSE.txt` for full license details.

## About DejaVu Fonts

DejaVu fonts are a font family based on the Bitstream Vera Fonts. Its purpose is to provide a wider range of characters while maintaining the original look and feel through the process of collaborative development.

- **Version**: 2.37
- **Website**: https://dejavu-fonts.github.io/
- **Repository**: https://github.com/dejavu-fonts/dejavu-fonts

The fonts provide excellent Unicode coverage and are widely used in open-source projects.
