Class DocumentFontsSubsystem

Class DocumentFontsSubsystem

Namespace: Aspose.Note.Fonts
Assembly: Aspose.Note.dll (24.12.0)

Simple implementation of Aspose.Note.Fonts.FontsSubsystem. Retrieves System.Drawing.FontFamily object from OS.

public class DocumentFontsSubsystem : FontsSubsystem, IFontsSubsystem

Inheritance

objectFontsSubsystemDocumentFontsSubsystem

Implements

IFontsSubsystem

Inherited Members

FontsSubsystem.AddFontSubstitution(string, string), FontsSubsystem.AddFont(Stream, string), FontsSubsystem.AddFont(Stream), FontsSubsystem.AddFont(string), FontsSubsystem.LoadFontsFromFolder(string), FontsSubsystem.GetFontFamily(string), FontsSubsystem.TranslateFontName(string), FontsSubsystem.FetchFontFamily(string), FontsSubsystem.FindFontFamilyInInternalCollection(string), FontsSubsystem.DefaultFont, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

Shows how to save a document in pdf format using specified default font.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                               // Load the document into Aspose.Note.
                                                                               Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                               // Save the document as PDF
                                                                               dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
                                                                               oneFile.Save(dataDir, new PdfSaveOptions() 
                                                                                                     {
                                                                                                         FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
                                                                                                     });

Shows how to save a document in pdf format using default font from a file.```csharp
// The path to the documents directory.
                                                                                     string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                                     string fontFile = Path.Combine(dataDir, "geo_1.ttf");

                                                                                     // Load the document into Aspose.Note.
                                                                                     Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                                     // Save the document as PDF
                                                                                     dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
                                                                                     oneFile.Save(dataDir, new PdfSaveOptions()
                                                                                                               {
                                                                                                                   FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
                                                                                                               });

Shows how to save a document in pdf format using default font from a stream.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                                   string fontFile = Path.Combine(dataDir, "geo_1.ttf");

                                                                                   // Load the document into Aspose.Note.
                                                                                   Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                                   // Save the document as PDF
                                                                                   dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";

                                                                                   using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                                                                                   {
                                                                                       oneFile.Save(dataDir, new PdfSaveOptions()
                                                                                                                 {
                                                                                                                     FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
                                                                                                                 });
                                                                                   }

## Constructors

### <a id="Aspose_Note_Fonts_DocumentFontsSubsystem__ctor_System_IO_Stream_System_Collections_Generic_Dictionary_System_String_System_String__"></a> DocumentFontsSubsystem\(Stream, Dictionary<string, string\="">\)

Initializes a new instance of the Aspose.Note.Fonts.DocumentFontsSubsystem class.

```csharp
public DocumentFontsSubsystem(Stream defaultFontStream, Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

defaultFontStream Stream

The default Font.

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

DocumentFontsSubsystem(string, Dictionary<string, string="">)

Initializes a new instance of the Aspose.Note.Fonts.DocumentFontsSubsystem class.

public DocumentFontsSubsystem(string defaultFontFile, Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

defaultFontFile string

The default Font.

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

DocumentFontsSubsystem(Dictionary<string, string="">)

Initializes a new instance of the Aspose.Note.Fonts.DocumentFontsSubsystem class.

public DocumentFontsSubsystem(Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

Properties

Default

Gets or sets the static default instance.

public static DocumentFontsSubsystem Default { get; set; }

Property Value

DocumentFontsSubsystem

Methods

FetchFontFamily(string)

Fetches font family as a candidate for GetFontFamily.

protected override FontFamily FetchFontFamily(string fontName)

Parameters

fontName string

The font name.

Returns

FontFamily

The System.Drawing.FontFamily.

UsingDefaultFont(string, Dictionary<string, string="">)

Create new DocumentFontsSubsystem instance using specified default font name.

public static DocumentFontsSubsystem UsingDefaultFont(string defaultFontName, Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

defaultFontName string

The default font name.

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

Returns

DocumentFontsSubsystem

The Aspose.Note.Fonts.DocumentFontsSubsystem.

Examples

Shows how to save a document in pdf format using specified default font.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                               // Load the document into Aspose.Note.
                                                                               Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                               // Save the document as PDF
                                                                               dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
                                                                               oneFile.Save(dataDir, new PdfSaveOptions() 
                                                                                                     {
                                                                                                         FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
                                                                                                     });

### <a id="Aspose_Note_Fonts_DocumentFontsSubsystem_UsingDefaultFontFromFile_System_String_System_Collections_Generic_Dictionary_System_String_System_String__"></a> UsingDefaultFontFromFile\(string, Dictionary<string, string\="">\)

Create new DocumentFontsSubsystem instance using a font from specified file as default.

```csharp
public static DocumentFontsSubsystem UsingDefaultFontFromFile(string filePath, Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

filePath string

The file containing default font name.

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

Returns

DocumentFontsSubsystem

The Aspose.Note.Fonts.DocumentFontsSubsystem.

Examples

Shows how to save a document in pdf format using default font from a file.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                                 string fontFile = Path.Combine(dataDir, "geo_1.ttf");

                                                                                 // Load the document into Aspose.Note.
                                                                                 Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                                 // Save the document as PDF
                                                                                 dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
                                                                                 oneFile.Save(dataDir, new PdfSaveOptions()
                                                                                                           {
                                                                                                               FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
                                                                                                           });

### <a id="Aspose_Note_Fonts_DocumentFontsSubsystem_UsingDefaultFontFromStream_System_IO_Stream_System_Collections_Generic_Dictionary_System_String_System_String__"></a> UsingDefaultFontFromStream\(Stream, Dictionary<string, string\="">\)

Create new DocumentFontsSubsystem instance using a font from specified stream as default.

```csharp
public static DocumentFontsSubsystem UsingDefaultFontFromStream(Stream defaultFontStream, Dictionary<string, string=""> fontsSubstitutions = null)

Parameters

defaultFontStream Stream

The stream containing the default font name.

fontsSubstitutions Dictionary<string, string&gt;

The fonts substitutions.

Returns

DocumentFontsSubsystem

The Aspose.Note.Fonts.DocumentFontsSubsystem.

Examples

Shows how to save a document in pdf format using default font from a stream.```csharp // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

                                                                                   string fontFile = Path.Combine(dataDir, "geo_1.ttf");

                                                                                   // Load the document into Aspose.Note.
                                                                                   Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));

                                                                                   // Save the document as PDF
                                                                                   dataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";

                                                                                   using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
                                                                                   {
                                                                                       oneFile.Save(dataDir, new PdfSaveOptions()
                                                                                                                 {
                                                                                                                     FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
                                                                                                                 });
                                                                                   }
</string,></string,></string,></string,></string,></string,></string,></string,></string,></string,></string,></string,>