Class DocumentFontsSubsystem
Namespace: Aspose.Note.Fonts
Assembly: Aspose.Note.dll (25.6.0)
Simple implementation of Aspose.Note.Fonts.FontsSubsystem. Retrieves System.Drawing.FontFamily object from OS.
public class DocumentFontsSubsystem : FontsSubsystem, IFontsSubsystem
{
private readonly IFontFactory _fontFactory;
public DocumentFontsSubsystem(IFontFactory fontFactory)
{
_fontFactory = fontFactory;
}
public Font GetFont(string familyName, FontStyle style, int size)
{
return _fontFactory.CreateFont(familyName, style, size);
}
}
Inheritance
object ← FontsSubsystem ← DocumentFontsSubsystem
Implements
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.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
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.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string dataDirWithPath = dataDir + @"\SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile\_out.pdf";
oneFile.Save(dataDirWithPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
Shows how to save a document in pdf format using default font from a stream.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string pdfOutputPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(pdfOutputPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
Constructors
DocumentFontsSubsystem(Stream, Dictionary<string, string="">)
Initializes a new instance of the Aspose.Note.Fonts.DocumentFontsSubsystem class.
public DocumentFontsSubsystem(
Stream defaultFontStream,
Dictionary<string, string> fontsSubstitutions = null)
{
}
Parameters
defaultFontStream
Stream
The default Font.
fontsSubstitutions
Dictionary
<
string
, string
>
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
>
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
>
The fonts substitutions.
Properties
Default
Gets or sets the static default instance.
public static DocumentFontsSubsystem Default
{
get;
private set;
}
Property Value
Methods
FetchFontFamily(string)
Fetches font family as a candidate for GetFontFamily.
protected override FontFamily FetchFontFamily(string fontName)
{
}
Parameters
fontName
string
The font name.
Returns
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
>
The fonts substitutions.
Returns
The Aspose.Note.Fonts.DocumentFontsSubsystem.
Examples
Shows how to save a document in pdf format using specified default font.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
dataDir += "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
oneFile.Save(dataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
});
UsingDefaultFontFromFile(string, Dictionary<string, string="">)
Create new DocumentFontsSubsystem instance using a font from specified file as default.
public static DocumentFontsSubsystem UsingDefaultFontFromFile(
string filePath,
Dictionary<string, string> fontsSubstitutions = null)
{
}
Parameters
filePath
string
The file containing default font name.
fontsSubstitutions
Dictionary
<
string
, string
>
The fonts substitutions.
Returns
The Aspose.Note.Fonts.DocumentFontsSubsystem.
Examples
Shows how to save a document in pdf format using default font from a file.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
dataDir += "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
oneFile.Save(dataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
UsingDefaultFontFromStream(Stream, Dictionary<string, string="">)
Create new DocumentFontsSubsystem instance using a font from specified stream as default.
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
>
The fonts substitutions.
Returns
The Aspose.Note.Fonts.DocumentFontsSubsystem.
Examples
Shows how to save a document in pdf format using default font from a stream.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string outputPdfPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(outputPdfPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
</string,></string,></string,></string,></string,></string,></string,></string,></string,></string,></string,></string,>