Load and Extract Data | .NET

Contents
[ Hide Show ]

Load Type1 Font from Disc

Aspose.Font for .NET API lets you read Type1 Font types from files stored in your digital storage. Type1 font files stored on disc can be loaded by using the following steps.

  1. Construct the full path to Type1/courier.pfb with DataDir and Path.Combine().
  2. Create a FontFileDefinition describing the .pfb format and a FileSystemStreamSource for the file, then use it to create a FontDefinition with FontType.Type1.
  3. Open the font using Aspose.Font.Font.Open(fontDefinition), cast the result to Type1Font, and check that the cast succeeded.
 1// Load a Type1 font from disk
 2
 3string fileName = Path.Combine(DataDir, "Type1", "courier.pfb");
 4FontDefinition fontDefinition = new FontDefinition(
 5    FontType.Type1,
 6    new FontFileDefinition("pfb", new FileSystemStreamSource(fileName)));
 7
 8Type1Font? font = Aspose.Font.Font.Open(fontDefinition) as Type1Font;
 9if (font == null)
10    throw new InvalidOperationException("Unable to load the Type1 font.");