FontFeatures.cs
C# VB
//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//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; // GCTEXT.Font font; var fpath = Path.Combine("Resources", "Fonts", "Gabriola.ttf"); if (File.Exists(fpath)) font = GCTEXT.Font.FromFile(fpath); else font = FontCollection.SystemFonts.FindFamilyName("Gabriola"); 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(FeatureTag.ss03)]; tl.AppendLine("Line with font feature ss03 enabled.", tf); // tf.FontFeatures = [new FontFeature(FeatureTag.ss05)]; tl.AppendLine("Line with font feature ss05 enabled.", tf); // tf.FontFeatures = [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; } }}