''
'' This code is part of Document Solutions for PDF demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing
'' Ligatures (joining two or more letters into a single glyph) are supported by DsPdf,
'' provided the selected font supports them, and the corresponding font feature is on.
'' For the complete list of font features see featurelist.htm.
'' See also FontFeatures.
Public Class Ligatures
Function CreatePDF(ByVal stream As Stream) As Integer
'' The list of common Latin ligatures:
Const latinLigatures = "fi, fj, fl, ff, ffi, ffl."
'' Set up ligature-related font features:
'' All ON:
Dim allOn As FontFeature() = {
New FontFeature(FeatureTag.clig, True), '' Contextual Ligatures
New FontFeature(FeatureTag.dlig, True), '' Discretionary Ligatures
New FontFeature(FeatureTag.hlig, True), '' Historical Ligatures
New FontFeature(FeatureTag.liga, True), '' Standard Ligatures
New FontFeature(FeatureTag.rlig, True) '' Required Ligatures
}
'' All OFF:
Dim allOff As FontFeature() = {
New FontFeature(FeatureTag.clig, False),
New FontFeature(FeatureTag.dlig, False),
New FontFeature(FeatureTag.hlig, False),
New FontFeature(FeatureTag.liga, False),
New FontFeature(FeatureTag.rlig, False)
}
Dim doc = New GcPdfDocument()
Dim g = doc.NewPage().Graphics
'' Text insertion point:
Dim ip = New PointF(72, 72)
Dim tf = New TextFormat()
tf.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "times.ttf"))
tf.FontSize = 20
g.DrawString($"Common Latin ligatures, font {tf.Font.FontFamilyName}", tf, ip)
ip.Y += 36
'' Turn all ligature features OFF:
tf.FontFeatures = allOff
g.DrawString($"All ligature features OFF: {latinLigatures}", tf, ip)
ip.Y += 36
'' Turn all ligature features ON:
tf.FontFeatures = allOn
g.DrawString($"All ligature features ON: {latinLigatures}", tf, ip)
ip.Y += 72
'' Repeat with a different font:
tf.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "Gabriola.ttf"))
g.DrawString($"Common Latin ligatures, font {tf.Font.FontFamilyName}", tf, ip)
ip.Y += 36
'' Turn all ligature features OFF:
tf.FontFeatures = allOff
g.DrawString($"All ligature features OFF: {latinLigatures}", tf, ip)
ip.Y += 36
'' Turn all ligature features ON:
tf.FontFeatures = allOn
g.DrawString($"All ligature features ON: {latinLigatures}", tf, ip)
''
'' Done:
doc.Save(stream)
Return doc.Pages.Count
End Function
End Class