public override bool ContainsGlyph(int unicode) { if (cidFontType == CID_FONT_TYPE_0) { if (cmapEncoding.IsDirect()) { return(fontProgram.GetGlyphByCode(unicode) != null); } else { return(GetFontProgram().GetGlyph(unicode) != null); } } else { if (cidFontType == CID_FONT_TYPE_2) { if (fontProgram.IsFontSpecific()) { byte[] b = PdfEncodings.ConvertToBytes((char)unicode, "symboltt"); return(b.Length > 0 && fontProgram.GetGlyph(b[0] & 0xff) != null); } else { return(GetFontProgram().GetGlyph(unicode) != null); } } else { throw new PdfException("Invalid CID font type: " + cidFontType); } } }
public virtual void TrueTypeFontAndCmapConstructorTest() { TrueTypeFont ttf = new TrueTypeFont(sourceFolder + "NotoSerif-Regular_v1.7.ttf"); PdfType0Font type0Font = new PdfType0Font(ttf, PdfEncodings.IDENTITY_H); CMapEncoding cmap = type0Font.GetCmap(); NUnit.Framework.Assert.IsNotNull(cmap); NUnit.Framework.Assert.IsTrue(cmap.IsDirect()); NUnit.Framework.Assert.IsFalse(cmap.HasUniMap()); NUnit.Framework.Assert.IsNull(cmap.GetUniMapName()); NUnit.Framework.Assert.AreEqual("Adobe", cmap.GetRegistry()); NUnit.Framework.Assert.AreEqual("Identity", cmap.GetOrdering()); NUnit.Framework.Assert.AreEqual(0, cmap.GetSupplement()); NUnit.Framework.Assert.AreEqual(PdfEncodings.IDENTITY_H, cmap.GetCmapName()); }
public virtual void DictionaryConstructorTest() { String filePath = sourceFolder + "documentWithType0Noto.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(filePath)); PdfDictionary fontDict = pdfDocument.GetPage(1).GetResources().GetResource(PdfName.Font).GetAsDictionary(new PdfName("F1")); PdfType0Font type0Font = new PdfType0Font(fontDict); CMapEncoding cmap = type0Font.GetCmap(); NUnit.Framework.Assert.IsNotNull(cmap); NUnit.Framework.Assert.IsTrue(cmap.IsDirect()); NUnit.Framework.Assert.IsFalse(cmap.HasUniMap()); NUnit.Framework.Assert.IsNull(cmap.GetUniMapName()); NUnit.Framework.Assert.AreEqual("Adobe", cmap.GetRegistry()); NUnit.Framework.Assert.AreEqual("Identity", cmap.GetOrdering()); NUnit.Framework.Assert.AreEqual(0, cmap.GetSupplement()); NUnit.Framework.Assert.AreEqual(PdfEncodings.IDENTITY_H, cmap.GetCmapName()); }