EmbedFontFile.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports GrapeCity.Documents.Word

'' This sample shows how to embed a True Type font from a .ttf font file,
'' and add a paragraph run to a DOCX file using that font.
Public Class EmbedFontFile
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()
        Dim p = doc.Body.Paragraphs.Add()
        Dim run = p.GetRange().Runs.Add("the quick brown fox jumps over the lazy dog")
        run.Font.Size = 24
        Dim font = GrapeCity.Documents.Text.Font.FromFile(Path.Combine("Resources", "Fonts", "SEGA.ttf"))
        run.Font.Name = font.FontFamilyName
        doc.Fonts.Add(font, True)

        Return doc
    End Function
End Class