FontFeatures.cs
//
// This code is part of Document Solutions for PDF demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GCTEXT = GrapeCity.Documents.Text;
using GCDRAW = GrapeCity.Documents.Drawing;

namespace DsPdfWeb.Demos.Basics
{
    // A simple demonstration of some interesting font features in action.
    // For the complete list of font features see featurelist.htm.
    // See also Ligatures.
    public class FontFeatures
    {
        public int CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            var g = doc.NewPage().Graphics;
            //
            var font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "Gabriola.ttf"));
            var tf = new TextFormat() { Font = font, FontSize = 20 };
            //
            var tl = g.CreateTextLayout();
            tl.AppendLine("Line with no custom font features.", tf);
            //
            tf.FontFeatures = new FontFeature[] { new FontFeature(FeatureTag.ss03) };
            tl.AppendLine("Line with font feature ss03 enabled.", tf);
            //
            tf.FontFeatures = new FontFeature[] { new FontFeature(FeatureTag.ss05) };
            tl.AppendLine("Line with font feature ss05 enabled.", tf);
            //
            tf.FontFeatures = new FontFeature[] { new FontFeature(FeatureTag.ss07) };
            tl.AppendLine("Line with font feature ss07 enabled.", tf);
            //
            tl.PerformLayout(true);
            g.DrawTextLayout(tl, new PointF(72, 72));
            // Done:
            doc.Save(stream);
            return doc.Pages.Count;
        }
    }
}