---
Product: Aspose.Font
Platform: python
Page Type: index
Canonical URL: https://blog.aspose.org/font/python/eot-fonts-in-python/
Published: 2026-05-21
Author: Aspose
---

# Working with EOT Fonts in Python using Aspose.Font FOSS

Aspose.Font FOSS for Python provides a full Python API for loading, inspecting, and converting Embedded OpenType (EOT) font files. Access EotHeader metadata fields such as eot_size, version, flags, and charset, traverse the inner TtfFont, and serialize fonts back to EOT bytes using EotSerializer.

## Introduction

Embedded OpenType (EOT) is a compact font format originally developed for embedding
TrueType fonts in web pages. An EOT file wraps a TTF or OTF font with a fixed-size
header containing metadata fields that describe font dimensions, version, charset, and
embedding permissions. Although modern web development has largely moved to WOFF/WOFF2,
EOT files remain in circulation in legacy documents and enterprise applications.

Aspose.Font FOSS for Python provides direct access to EOT font internals through the
`EotFont` class and its companion `EotHeader`. You can load an EOT file with
`FontLoader.open`, read header fields, traverse the inner `TtfFont`, and serialize the
result back to bytes or to a file using `Font.save`.
The library is distributed as `aspose-font-foss` and licensed under the MIT License.  
It has no mandatory commercial dependencies and works with the standard Python 3 runtime.

---

## Key Features

### Loading EOT Fonts

Use `FontLoader.open` to load an EOT file from a path or a bytes object. The method returns an `EotFont` instance when it detects the EOT signature:

```python
from aspose_font import FontLoader, EotFont

font = FontLoader.open("fonts/sample.eot")
assert isinstance(font, EotFont)

print(font.font_name)     # e.g. "Roboto"
print(font.font_family)   # e.g. "Roboto"
print(font.num_glyphs)    # number of glyphs in the inner font
```

`FontLoader.open` reads the file extension and header magic to detect the format automatically. No `font_type` argument is required for common font files.

---

### Reading EotHeader Metadata

`EotFont` exposes the header fields directly as properties on the class. These
correspond to the fields defined in the EOT binary specification:

```python
from aspose_font import FontLoader, EotFont, EotSerializer

# Load EOT — FontLoader returns an EotFont instance for .eot files
loaded = FontLoader.open("fonts/sample.eot")

# Serialize back to bytes to confirm the font loaded correctly
eot_bytes = EotSerializer.serialize(loaded)
print(f"EOT data loaded: {len(eot_bytes)} bytes")

# Base Font properties work on any loaded font
print("Font name:", loaded.font_name)
print("Glyphs   :", loaded.num_glyphs)
```

The `EotFont` class exposes the following header metadata as properties:
- `eot_version` (`int`) — EOT format version (e.g. `0x00020002`)
- `flags` (`int`) — embedding permission flags
- `charset` (`int`) — character set identifier (0 = ANSI, 1 = DEFAULT)
- `italic` (`int`) — italic flag (0 or 1)
- `weight` (`int`) — font weight (e.g., 400 for Regular, 700 for Bold)
- `fs_type` (`int`) — OS/2 fsType embedding bits

Use `flags` and `fs_type` to determine whether the font permits subsetting or embedding, which is relevant when processing fonts for redistribution pipelines.

### Accessing the Inner TtfFont

Every `EotFont` wraps a standard TrueType font. The `inner_font` property returns
the `TtfFont` instance, giving you access to the full TrueType table set:

```python
from aspose_font import FontLoader

loaded = FontLoader.open("fonts/sample.eot")

# Metrics are accessible directly from the loaded font
metrics = loaded.metrics
print("Units per em :", metrics.units_per_em)
print("Ascender     :", metrics.ascender)
print("Descender    :", metrics.descender)
print("Line gap     :", metrics.line_gap)
```

The `inner_font` property on `EotFont` returns the wrapped `TtfFont` instance, providing
access to the full TrueType table set, kern pairs, and encoding tables.

---

### Serializing EOT to Bytes

`EotSerializer.serialize` converts any `Font` object to a raw EOT byte string:

```python
from aspose_font import FontLoader, EotFont, EotSerializer

font = FontLoader.open("fonts/sample.eot")
assert isinstance(font, EotFont)

eot_bytes = EotSerializer.serialize(font)
with open("output/sample_copy.eot", "wb") as fh:
    fh.write(eot_bytes)

print(f"Serialized {len(eot_bytes)} bytes")
```

---

### Converting TTF to EOT

`EotSerializer.serialize` accepts any `Font` instance, so you can load a TTF and
serialize it directly to EOT bytes:

```python
from aspose_font import FontLoader, EotFont, EotSerializer

ttf = FontLoader.open("fonts/Roboto-Regular.ttf")
eot_bytes = EotSerializer.serialize(ttf)

with open("output/Roboto-Regular.eot", "wb") as fh:
    fh.write(eot_bytes)

reloaded = FontLoader.open("output/Roboto-Regular.eot")
assert isinstance(reloaded, EotFont)
print("Converted and verified:", reloaded.font_name)
```

---

### Font Metrics and Kern Pairs

The `EotFont` inherits the full `Font` interface, so metrics and encoding are
available directly without going through `inner_font`:

```python
from aspose_font import FontLoader

loaded = FontLoader.open("fonts/sample.eot")

metrics = loaded.metrics
print(f"Ascender : {metrics.ascender}")
print(f"Descender: {metrics.descender}")
print(f"Line gap : {metrics.line_gap}")
print(f"Underline: {metrics.underline_position}")

for pair in loaded.get_kern_pairs():
    print(f"  Kern: {pair}")
```

---

## Quick Start

Install the library:

```bash
pip install aspose-font-foss
```

Load and inspect an EOT font:

```python
from aspose_font import FontLoader, EotFont, EotSerializer

loaded = FontLoader.open("sample.eot")

# Base font info
print(f"Font name : {loaded.font_name}")
print(f"Glyphs    : {loaded.num_glyphs}")

# Metrics
metrics = loaded.metrics
print(f"UPM       : {metrics.units_per_em}")
print(f"Ascender  : {metrics.ascender}")

# Serialize the loaded font back to EOT bytes
eot_bytes = EotSerializer.serialize(loaded)
print(f"Serialized: {len(eot_bytes)} bytes")
```

---

## Supported Formats

| Format | Extension | Read | Write |
|--------|-----------|------|-------|
| TTF | .ttf | ✓ | — |
| OTF | .otf | ✓ | — |
| EOT | .eot | ✓ | — |
| CFF | .cff | ✓ | — |
| TYPE1 | .pfb/.pfa | ✓ | — |
| WOFF | .woff | ✓ | — |
| WOFF2 | .woff2 | ✓ | — |

All formats listed above are supported for loading via `FontLoader.open`. Writing
to a specific format uses `Font.save` or `EotSerializer.serialize` for EOT.

---

## Open Source & Licensing

Aspose.Font FOSS for Python is released under the MIT License. You can use it in
personal, commercial, and open-source projects at no cost. The source code is
available on GitHub, packaged as `aspose-font-foss`.

---

## Getting Started

- [Getting Started](https://docs.aspose.org/font/python/getting-started/)
- [Developer Guide](https://docs.aspose.org/font/python/developer-guide/)
- [KB Articles](https://kb.aspose.org/font/python/)
- [API Reference](https://reference.aspose.org/font/python/)

## Related Resources
- [Aspose.Font — Enterprise Blog](https://blog.aspose.com/)