Working with Type 1 Fonts

Working with Type 1 Fonts

Working with Type 1 Fonts

Type 1 is a legacy PostScript font format used in professional print workflows. Aspose.Font FOSS for Python can load Type 1 fonts from binary .pfb or ASCII .pfa files and provides Type1Interpreter for charstring interpretation.


Loading a Type 1 Font

from aspose_font.loader import FontLoader

font = FontLoader.open("TimesNewRoman.pfb")
print(font.font_name, font.num_glyphs)

Accessing Glyph Outlines

Use GlyphAccessor to retrieve individual glyph outlines.

from aspose_font.loader import FontLoader

font = FontLoader.open("TimesNewRoman.pfb")
gid = font.encoding.unicode_to_gid(0x41)
glyph = font.glyph_accessor.get_glyph_by_id(gid)
for cmd in glyph.path.commands:
    print(type(cmd).__name__)

Type 1 Serialization

Type1Serializer provides three methods: serialize(), serialize_pfa(), and serialize_pfb() for producing ASCII and binary Type 1 output.


Tips and Best Practices

  • Type 1 fonts use a different charstring encoding from CFF Type 2; use Type1Interpreter for raw charstring work
  • Convert Type 1 to TTF or OTF for modern use with FontConverter.convert(font, "ttf")

API Reference Summary

Class / MethodDescription
FontLoader.open(path)Load a Type 1 font
GlyphAccessor.get_glyph_by_id(gid)Retrieve a glyph
Type1InterpreterInterpret Type 1 charstrings
Type1SerializerSerialize to Type 1 format