ManimPango

0.6.1 · active · verified Fri Apr 17

ManimPango provides Python bindings for the Pango text layout library, specifically designed to integrate with the Manim animation engine for advanced text rendering. It allows Manim users to leverage Pango's rich text features, font handling, and internationalization capabilities. The current version is 0.6.1, and the library is actively maintained with frequent minor releases addressing Python version compatibility, OS-specific build issues, and Pango library updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to list available system fonts and create a `FontDescriptor` using ManimPango. While `register_font` is a key feature, it's commented out as it requires a specific font file path which is not universally available for a quickstart example. It requires Python 3.8+.

from manimpango import FontDescriptor, list_fonts, register_font
import os

print("Available fonts (first 5):")
# In a real scenario, this might return hundreds of fonts.
# We limit for demonstration.
for font_name in list_fonts()[:5]:
    print(f"- {font_name}")

# Create a font descriptor (Pango uses 'family style weight size')
try:
    descriptor = FontDescriptor("Arial Bold 16")
    print(f"\nSuccessfully created FontDescriptor for: {descriptor.family}, style={descriptor.style}, weight={descriptor.weight}, size={descriptor.size}")
except Exception as e:
    print(f"\nError creating FontDescriptor: {e}")

# Example of how you would register a font (requires an actual font file path)
# For a runnable quickstart, we'll just demonstrate the call without a real file.
# font_file_path = os.environ.get('MANIMPANGO_CUSTOM_FONT_PATH', '/path/to/your/custom_font.ttf')
# if os.path.exists(font_file_path):
#     register_font(font_file_path)
#     print(f"Registered font from {font_file_path}")
# else:
#     print(f"(Skipping font registration: custom font file not found at {font_file_path})")

view raw JSON →