OpenTypeFont

Represents an OpenType font.

public class OpenTypeFont : Font, IDisposable, IFontSubsettable
Public Class OpenTypeFont
    Inherits Font
    Implements IDisposable, IFontSubsettable

Inheritance: ObjectResourceFontOpenTypeFont

Implements: IDisposable, IFontSubsettable

Derived: GoogleFont

Licensing Info

This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples

This example shows how to use the open type font.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Text
     
Module MyModule
     
    Sub Main()
     
        ' Create a PDF Document
        Dim MyDocument As Document = New Document 
     
        ' Create a Page and add it to the document
        Dim MyPage As Page = New Page
        MyDocument.Pages.Add(MyPage)
     
        ' Create a open type font
        Dim  MyOpentypefont As OpenTypeFont = New OpenTypeFont("Path of .otf file")
     
        ' Create a label
        Dim MyLabel As ceTe.DynamicPDF.PageElements.Label  = New ceTe.DynamicPDF.PageElements.Label("This text uses open type font ", 0, 0, 300, 300)
     
        ' Assign open type font to label
        MyLabel.Font = MyOpentypefont
     
        ' Add label to the page
        MyPage.Elements.Add(MyLabel)
     
        ' Save the PDF document
        MyDocument.Draw("C:\MyDocument.pdf")
     
    End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Text;

public class Example
{
    public static void CreatePDF(string outputPath, string fontPath)
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a Page and add it to the document
        Page page = new Page();
        document.Pages.Add(page);

        // Create a open type font
        OpenTypeFont opentypefont = new OpenTypeFont(fontPath);

        //Create a label
        Label label = new Label("This text uses opentype font ", 0, 0, 300, 300);

        // Assign opentype font to label
        label.Font = opentypefont;

        // Add label to the page
        page.Elements.Add(label);

        // Save the PDF document
        document.Draw(outputPath);
    }
}

Remarks

See the OpenType Fonts topic for more on OpenType fonts.

Constructors

OpenTypeFont(Byte[])Intializes a new instance of OpenTypeFont class.
OpenTypeFont(Stream)Intializes a new instance of OpenTypeFont class.
OpenTypeFont(String)Initializes a new instance of OpenTypeFont class.
OpenTypeFont(String, LineBreaker)Initializes a new instance of OpenTypeFont class.

Properties

AscenderGets the ascender for the font.
DescenderGets the descender for the font.
EmbedGets or sets a value indicating whether the font need to be embedded in to the pdf.
EncoderGets the encoder for the font.
(Inherited from Font)
FormFontNameGets the four character name of the font.
(Inherited from Font)
LineBreakerGets the instance of LineBreaker used for the font.
LineGapGets the line gap for the font.
NameGets the font name for the file given.
OutLineTypeGets the OutLineType of the opentype font.
RequiredPdfObjectsGets the required pdf objects.
ResourceTypeGets the value of ResourceType .
SubsetGets or sets a value indicating whether the font need to subset while embedding.
UidGets the unique ID of the resource.
(Inherited from Resource)

Methods

Dispose()Releases all resources used by the OpenTypeFont object.
Draw(DocumentWriter)Draw the opentype font data to the DocumentWriter .
Equals(Object)Determines whether the specified Object is equal to the current Object .
(Inherited from Object)
GetAscender(Single)Returns the ascender of the font in points for the given font size.
(Inherited from Font)
GetBaseLine(Single, Single)Returns the baseline of the font in points for the given leading and font size.
(Inherited from Font)
GetDefaultLeading(Single)Returns the default leading of the font in points for the given font size.
(Inherited from Font)
GetDescender(Single)Returns the descender of the font in points for the given font size.
(Inherited from Font)
GetFontSubsetter()eturns a font subsetter for the opentype font.
GetGlyphWidth(Char)Returns the mwidth of the given char.
GetHashCode()Serves as a hash function for a particular type.
(Inherited from Object)
GetKernValue(Char, Char)Returns the kern value correspoding to the given glyph combination.
GetLineGap(Single)Returns the line gap of the font in points for the given font size.
(Inherited from Font)
GetTextLines(Char[], Single, Single)Returns a TextLineList for the given character array.
(Inherited from Font)
GetTextLines(Char[], Single, Single, Single)Returns a TextLineList for the given character array.
(Inherited from Font)
GetTextWidth(Char[], Single)Returns the width of the given text.
(Inherited from Font)
GetTextWidth(String, Single)Returns the width of the given text.
(Inherited from Font)
GetType()Gets the Type of the current instance.
(Inherited from Object)
HasKerning()Returns whether the font has inbuilt kerning pairs.
ToString()Returns a String that represents the current Object .
(Inherited from Object)

See Also

ceTe.DynamicPDF.Text

In this topic