diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue37.cs b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue37.cs index 37cf59d..c74762d 100644 --- a/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue37.cs +++ b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue37.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections; -using System.IO; +using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue38.cs b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue38.cs new file mode 100644 index 0000000..09c7013 --- /dev/null +++ b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue38.cs @@ -0,0 +1,46 @@ +using System.IO; +using iTextSharp.text; +using iTextSharp.text.pdf; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues +{ + /// + /// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/38 + /// + [TestClass] + public class Issue38 + { + [TestMethod] + public void Verify_Issue38_CanBe_Processed() + { + var pdfDoc = new Document(PageSize.A4); + + var pdfFilePath = TestUtils.GetOutputFileName(); + var fileStream = new FileStream(pdfFilePath, FileMode.Create); + PdfWriter.GetInstance(pdfDoc, fileStream); + + pdfDoc.AddAuthor(TestUtils.Author); + pdfDoc.Open(); + + var swiss721BT = TestUtils.GetUnicodeFont("SWIS721 BT", TestUtils.GetFontPath("Swiss721BT.ttf"), + 20, Font.NORMAL, BaseColor.Blue); + + var swiss721ThinBT = TestUtils.GetUnicodeFont("SWIS721 Th BT", TestUtils.GetFontPath("Swiss721ThinBT.ttf"), + 20, Font.NORMAL, BaseColor.DarkGray); + + var text = new Phrase("Default font") + { + new Chunk("\nSwiss721BT", swiss721BT), + new Chunk("\nSwiss721ThinBT", swiss721ThinBT) + }; + + pdfDoc.Add(text); + + pdfDoc.Close(); + fileStream.Dispose(); + + TestUtils.VerifyPdfFileIsReadable(pdfFilePath); + } + } +} \ No newline at end of file diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs b/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs index 37a4fad..3f1e6ed 100644 --- a/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs +++ b/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs @@ -50,24 +50,29 @@ public static string GetPosterPath(string fileName) return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "posters", fileName); } + public static string GetFontPath(string fileName) + { + return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", fileName); + } + public static string GetTahomaFontPath() { - return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "tahoma.ttf"); + return GetFontPath("tahoma.ttf"); } public static string GetArialUnicodeMSFontPath() { - return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "arialuni.ttf"); + return GetFontPath("arialuni.ttf"); } public static string GetSimSunFontPath() { - return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "simsun.ttf"); + return GetFontPath("simsun.ttf"); } public static string GetThaiFontPath() { - return Path.Combine(GetBaseDir(), ITextExamplesFolder, ResourcesFolder, "fonts", "thsarabunnew.ttf"); + return GetFontPath("thsarabunnew.ttf"); } public static string GetTxtPath(string fileName) diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721BT.ttf b/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721BT.ttf new file mode 100644 index 0000000..75f2017 Binary files /dev/null and b/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721BT.ttf differ diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721ThinBT.ttf b/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721ThinBT.ttf new file mode 100644 index 0000000..ebc5cf5 Binary files /dev/null and b/src/iTextSharp.LGPLv2.Core.FunctionalTests/iTextExamples/resources/fonts/Swiss721ThinBT.ttf differ