[]
The base abstract class representing a font in a PDF document.
public abstract class Font : PdfDictWrapper, IPdfDict
Gets or sets the PostScript name of the font.
public string BaseFont { get; set; }
Gets a value indicating whether the font is embedded.
public abstract bool IsEmbedded { get; }
Gets the value of BaseFont entry.
public PdfName propBaseFont { get; }
Gets a Font object created from the embedded font data.
Note that this method will return null if the font is not embedded or does not support this operation (e.g. Type3 fonts).
public abstract Font CreateNativeFont()
Returns the stream containing the embedded font data, returns null if the font is not embedded, the stream should be disposed after usage.
public Stream GetEmbeddedData()
The stream with font data or null if the font is not embedded.
Extracts the attributes of the current font. If a specific attribute cannot be determined, the corresponding output value is set to null.
public void GetFontAttributes(out string fontFamily, out FontWeight? fontWeight, out FontStretch? fontStretch, out bool? fontItalic)
fontFamily
stringfontWeight
FontWeight?fontStretch
FontStretch?fontItalic
bool?Gets an FontDescriptor object that describes the font.
public abstract FontDescriptor GetFontDescriptor()
The FontDescriptor object.
Removes the embedded font data.
Please note that a PDF may display incorrectly after removing an embedded font's data. Use with caution.
public abstract void RemoveEmbeddedData(GcPdfDocument doc)
doc
GcPdfDocumentThe document that owns the font.
Tries to convert a Unicode value to the character's PDF code.
Note that this method can fail if the font does not contain the necessary info for the conversion or does not contain the specified Unicode value.
Note also that this method can be slow as it uses large font tables like /Encoding, /ToUnicode etc., so it is recommended that the returned results are cached by the caller.
public abstract bool TryGetPdfCode(string unicode, out uint pdfCode, out int pdfCodeLength)
unicode
stringThe character Unicode.
pdfCode
uintOUT: The character PDF code.
pdfCodeLength
intOUT: The length of pdfCode
in bytes.
true if the conversion was successful, false otherwise.
Converts a character's PDF code to its Unicode value.
Note that this method can fail if the font does not contain the necessary info for the conversion.
Note also that this method can be slow as it uses large font tables like /Encoding, /ToUnicode etc., so the returned results better be cached by the caller.
public abstract bool TryGetUnicode(uint pdfCode, out string unicode)
pdfCode
uintThe character PDF code.
unicode
stringOUT: The character Unicode.
True if the conversion was successful, false otherwise.