public static void Run() { string dataDir = RunExamples.GetDataDir_Data(); //ExStart: 1 string fileName = dataDir + "courier.pfb"; //Font file name with full path FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName))); Type1Font font = Aspose.Font.Font.Open(fd) as Type1Font; bool latinText = true; for (uint code = 65; code < 123; code++) { GlyphId gid = font.Encoding.DecodeToGid(code); if (gid == null || gid == GlyphUInt32Id.NotDefId) { latinText = false; } } if (latinText) { Console.WriteLine(string.Format("Font {0} supports latin symbols.", font.FontName)); } else { Console.WriteLine(string.Format("Latin symbols are not supported by font {0}.", font.FontName)); } //ExEnd: 1 }
public virtual void StandardFontForceNotEmbeddedTest() { Type1Font fontProgram = (Type1Font)FontProgramFactory.CreateFont(StandardFonts.HELVETICA); PdfType1Font font = (PdfType1Font)PdfFontFactory.CreateFont(fontProgram, PdfEncodings.UTF8, PdfFontFactory.EmbeddingStrategy .FORCE_NOT_EMBEDDED); NUnit.Framework.Assert.IsNotNull(font); NUnit.Framework.Assert.IsFalse(font.IsEmbedded()); }
public virtual void StandardFontForceEmbeddedTest() { Type1Font fontProgram = (Type1Font)FontProgramFactory.CreateFont(StandardFonts.HELVETICA); NUnit.Framework.Assert.That(() => { PdfFontFactory.CreateFont(fontProgram, PdfEncodings.UTF8, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); } , NUnit.Framework.Throws.InstanceOf <PdfException>().With.Message.EqualTo(PdfException.CannotEmbedStandardFont)) ; }
public static void Run() { string dataDir = RunExamples.GetDataDir_Data(); //ExStart: 1 string fileName = dataDir + "courier.pfb"; //Font file name with full path FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName))); Type1Font font = Aspose.Font.Font.Open(fd) as Type1Font; //ExEnd: 1 }
public static void Run() { string dataDir = RunExamples.GetDataDir_Data(); //ExStart: 1 string fileName = dataDir + "courier.pfb"; //Font file name with full path FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName))); Type1Font font = Aspose.Font.Font.Open(fd) as Type1Font; DrawText("Hello world", font, 14, Brushes.White, Brushes.Black, dataDir + "hello1_type1_out.jpg"); DrawText("Hello world", font, 14, Brushes.Yellow, Brushes.Red, dataDir + "hello2_type1_out.jpg"); //ExEnd: 1 }
public static void Run() { string dataDir = RunExamples.GetDataDir_Data(); //ExStart: 1 string fileName = dataDir + "courier.pfb"; //Font file name with full path FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName))); Type1Font font = Aspose.Font.Font.Open(fd) as Type1Font; string name = font.FontName; Console.WriteLine("Font name: " + name); Console.WriteLine("Glyph count: " + font.NumGlyphs); string metrics = string.Format( "Font metrics: ascender - {0}, descender - {1}, typo ascender = {2}, typo descender = {3}, UnitsPerEm = {4}", font.Metrics.Ascender, font.Metrics.Descender, font.Metrics.TypoAscender, font.Metrics.TypoDescender, font.Metrics.UnitsPerEM); Console.WriteLine(metrics); //ExEnd: 1 }
internal PdfFont AddFont(System.Drawing.Font f) { PdfFont pf = null; PdfFont.FontType fontType = PdfFont.ResolveFontType(f); string name = (fontType == PdfFont.FontType.Type1) ? PdfFont.FontToPdfType(f) : PdfDocument.GetFullFontName(f).Replace(" ", ""); if (this.ContainsFont(name)) { pf = GetFont(name); } else { if (fontType == PdfFont.FontType.Type1) { pf = new Type1Font(name, this); } else { pf = new PdfTrueTypeFont(f, this); } pf.ID = this.GetNextId; this.AddPdfObject(pf); pf.AddDescriptors(); pf.Alias = String.Format("F{0}", fontList.Count); fontList[pf] = pf.Alias; } return(pf); }