---
Product: Aspose.Font
Platform: python
Page Type: index
Canonical URL: https://products.aspose.org/font/python/
---

# Aspose.Font FOSS for Python

Open-source Python library for loading, inspecting, converting, and subsetting TTF, OTF, CFF, WOFF, WOFF2, and EOT font files.

Free, open-source Python library for font loading, conversion, glyph inspection, subsetting, and variable font previews. MIT licensed.

## Work with Fonts Programmatically in Python

Aspose.Font FOSS for Python is a pure-Python toolkit for loading, inspecting, converting, subsetting, and previewing fonts across TrueType, OpenType, CFF, Type 1, WOFF, WOFF2, and EOT formats. The library runs on Python 3.10 or later and requires no external OS font libraries or native dependencies.

The library exposes a clean API for font loading via `FontLoader`, glyph access via `GlyphAccessor`, format conversion via `FontConverter`, web optimization via `FontCleaner`, text-aware subsetting via `FontSubsetter`, and variable font animation via `AnimationPreviewBuilder`. Font metadata such as name, family, style, glyph count, encoding, and metrics is accessible through the `Font` base class without parsing binary tables manually.

Aspose.Font FOSS is MIT licensed and installable from PyPI with a single pip install command. It is suitable for font design tooling, web font pipelines, glyph rendering engines, and any Python application that needs to read, transform, or produce font files. For the enterprise product family, see [Aspose.Font — Enterprise Product Family](https://products.aspose.com/font/).

## Font Loading and Format Detection

- Load fonts from file paths or raw bytes with `FontLoader.open()` and `FontLoader.load()`
- Automatically detect format: TTF, OTF, CFF, WOFF, WOFF2, EOT, Type 1
- Access font metadata via the `Font` base class: `font_name`, `font_family`, `font_style`, `num_glyphs`
- Read glyph encoding maps with `FontEncoding.unicode_to_gid()` and `get_all_codepoints()`
- Inspect font metrics with `FontMetrics`: ascent, descent, line gap, em-square

## Typical Use Cases

- Font validation and metadata extraction pipelines
- CI/CD checks that verify font family name and glyph count
- Web font ingestion services that accept multiple input formats
- Font design tools that display metadata without a desktop runtime

## Glyph Access and Path Inspection

- Retrieve glyphs by ID or Unicode with `GlyphAccessor.get_glyph_by_id()` and `get_glyph_by_unicode()`
- Resolve all glyphs for a string with `GlyphAccessor.get_glyphs_for_text()`
- Inspect glyph outline paths as typed commands: `MoveTo`, `LineTo`, `QuadraticTo`, `CurveTo`, `ClosePath`
- Access glyph bounding box, advance width, and side bearings from `Glyph` properties
- Read kerning pairs from `KernPair` for accurate text-layout calculations

## Typical Use Cases

- Glyph coverage checks for multilingual text rendering
- Outline extraction for SVG path or vector generation
- Kerning table validation in font QA workflows
- Text shaping research and low-level layout experimentation

## Font Conversion

- Convert between TTF, OTF, CFF, WOFF, WOFF2, EOT, and Type 1 with `FontConverter.convert()`
- Adapt Bezier curve types with `CurveAdapter.quad_to_cubic()` and `cubic_to_quads()`
- Convert glyph paths between quadratic and cubic with `convert_path_quad_to_cubic()` and `convert_path_cubic_to_quad()`

## Typical Use Cases

- Web font pipelines that convert TTF master fonts to WOFF2 for distribution
- Type foundry tooling that exports to multiple format targets from one source
- Legacy EOT conversion for backward-compatible web font stacks
- Automated font format normalization in continuous integration

## Font Subsetting

- Subset fonts by Unicode text with `FontSubsetter.subset_by_text()`
- Subset by glyph ID list with `FontSubsetter.subset_by_gids()`
- Produce web-optimized subsets with `FontSubsetter.subset_for_web()`
- Apply named preset profiles with `FontSubsetter.subset_by_presets()` and `available_presets()`
- Analyse subset coverage with `FontSubsetter.analyze_coverage()` and `analyze_web_coverage()`

## Typical Use Cases

- Reducing WOFF2 payload size for web pages with limited character sets
- Producing language-specific font subsets for i18n deployments
- Font licensing workflows that distribute per-page-set subsets
- Performance optimization for mobile web applications

## Web Optimization and Variable Font Previews

- Strip legacy tables and Mac name records with `FontCleaner.clean_for_web()`
- Check variable font axis compatibility with `CompatibilityChecker.compare_fonts()` and `compare_variable_instances()`
- Generate animated APNG axis sweeps with `AnimationPreviewBuilder.build_axis_sweep()`
- Build multi-step animation paths with `AnimationPreviewBuilder.build_path()`

## Typical Use Cases

- Font specimen pages and interactive axis explorers for type foundries
- CI pipelines that verify variable font behaviour before distribution
- Web performance pipelines that drop non-essential binary tables
- Font preview thumbnails for font management applications

## Load a Font File

Open a TrueType or OpenType font from a file path and read its basic metadata.

```python
from aspose_font.loader import FontLoader
font = FontLoader.open("Roboto-Regular.ttf")
print(font.font_name)    # e.g. "Roboto"
print(font.font_family)  # e.g. "Roboto"
print(font.num_glyphs)   # e.g. 1294
```

## Access Glyphs for a Text String

Resolve all glyphs for a Unicode code point and inspect their outline paths.

```python
from aspose_font.loader import FontLoader
font = FontLoader.open("OpenSans-Regular.otf")
glyph_id = font.encoding.unicode_to_gid(0x41)  # Unicode for A
glyph = font.glyph_accessor.get_glyph_by_id(glyph_id)
for cmd in glyph.path:
    print(type(cmd).__name__, cmd)
```

## Generate a Variable Font Axis Sweep Animation

Create an animated APNG that sweeps a variable font axis from start to end value.

```python
from aspose_font.loader import FontLoader
from aspose_font.animation import AnimationPreviewBuilder

font = FontLoader.open("Roboto-VariableFont_wdth,wght.ttf")

asset = AnimationPreviewBuilder.build_axis_sweep(
    font,
    axis_tag="wdth",
    start_val=75.0,
    end_val=100.0,
    frames=3,
    fps=10,
    text="A",
    size=10.0,
    bounce=True,
)

asset.write_to("roboto-sweep-wdth.png")
```

## Clean a Font for Web Deployment

Strip legacy tables and Mac name records to reduce binary size before web serving.

```python
from aspose_font.loader import FontLoader
from aspose_font.cleaner import FontCleaner
font = FontLoader.open("Roboto-Regular.ttf")
cleaned = FontCleaner.clean_for_web(font)
# DSIG, FFTM, meta tables removed; Mac platform name records stripped
```

## Frequently Asked Questions

### What is Aspose.Font FOSS for Python?

It is a free, MIT-licensed pure-Python library for loading, inspecting, converting, and subsetting fonts in TTF, OTF, CFF, Type 1, WOFF, WOFF2, and EOT formats. No native dependencies are required.

### How do I install Aspose.Font FOSS for Python?

Run `pip install aspose-font-foss`. No system-level dependencies are needed. The library works on Windows, macOS, and Linux with Python 3.10 or later.

### Which font formats are supported?

`FontLoader.open()` reads TTF, OTF, CFF, Type 1, WOFF, WOFF2, and EOT. `FontConverter.convert()` writes TTF, CFF, WOFF, and WOFF2. EOT is read-only.

### Is Font.to_bytes() available?

No. `Font.to_bytes()` is not implemented in the base class. Use `FontConverter.convert()` to produce a new `Font` in the desired format.

### Can I subset a font for web delivery?

Yes. `FontSubsetter.subset_by_text(font, text)` returns a new `Font` containing only the glyphs required for the given text. `FontSubsetter.subset(font, codepoints)` and `subset_by_gids(font, gids)` give finer control.

## Support and Learning Resources

- [Documentation](https://docs.aspose.org/font/python/)
- [API References](https://reference.aspose.org/font/python/)
- [Free Support](https://forum.aspose.org/)
- [Contribution](https://contribution.aspose.org/)
- [Blog](https://blog.aspose.org/)
- [New Releases](https://releases.aspose.org/)