diff --git a/src/UglyToad.PdfPig.Tests/Dla/DocstrumBoundingBoxesTests.cs b/src/UglyToad.PdfPig.Tests/Dla/DocstrumBoundingBoxesTests.cs index 2df80b91..831c1215 100644 --- a/src/UglyToad.PdfPig.Tests/Dla/DocstrumBoundingBoxesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Dla/DocstrumBoundingBoxesTests.cs @@ -3,7 +3,8 @@ using System.Collections.Generic; using System.Linq; using UglyToad.PdfPig.DocumentLayoutAnalysis.PageSegmenter; - using UglyToad.PdfPig.DocumentLayoutAnalysis.WordExtractor; + using UglyToad.PdfPig.DocumentLayoutAnalysis.WordExtractor; + using UglyToad.PdfPig.Fonts.SystemFonts; using Xunit; public class DocstrumBoundingBoxesTests @@ -70,10 +71,18 @@ } }; - [Theory] + [SkippableTheory] [MemberData(nameof(DataExtract))] public void GetBlocks(string name, string[] expected) { + if (name == "90 180 270 rotated.pdf") + { + // The 'TimesNewRomanPSMT' font is used by this particular document. Thus, results cannot be trusted on + // platforms where this font isn't generally available (e.g. OSX, Linux, etc.), so we skip it! + var font = SystemFontFinder.Instance.GetTrueTypeFont("TimesNewRomanPSMT"); + Skip.If(font == null, "Skipped because the font TimesNewRomanPSMT could not be found in the execution environment."); + } + var options = new DocstrumBoundingBoxes.DocstrumBoundingBoxesOptions() { LineSeparator = " " }; using (var document = PdfDocument.Open(DlaHelper.GetDocumentPath(name))) { diff --git a/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs b/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs index ba99acce..5959b7f7 100644 --- a/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs +++ b/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using UglyToad.PdfPig.Fonts.SystemFonts; using UglyToad.PdfPig.Tests.Dla; using Xunit; @@ -21,11 +22,15 @@ namespace UglyToad.PdfPig.Tests.Fonts.SystemFonts }, }; - [Theory] + [SkippableTheory] [MemberData(nameof(DataExtract))] public void GetCorrectBBoxLinux(string name, object[][] expected) - { - // success on Windows but LinuxSystemFontLister cannot find the 'TimesNewRomanPSMT' font + { + // success on Windows but LinuxSystemFontLister cannot find the 'TimesNewRomanPSMT' font + var font = SystemFontFinder.Instance.GetTrueTypeFont("TimesNewRomanPSMT"); + + Skip.If(font == null, "Skipped because the font TimesNewRomanPSMT could not be found in the execution environment."); + using (var document = PdfDocument.Open(DlaHelper.GetDocumentPath(name))) { var page = document.GetPage(1); diff --git a/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs b/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs index 70d6d4d1..cc3a1cda 100644 --- a/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs +++ b/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs @@ -48,7 +48,7 @@ var result = FileHeaderParser.Parse(scanner, false, log); Assert.Equal(1.2m, result.Version); - Assert.Equal(9, result.OffsetInFile); + Assert.Equal(TestEnvironment.IsUnixPlatform ? 7 : 9, result.OffsetInFile); } [Fact] @@ -70,7 +70,7 @@ var result = FileHeaderParser.Parse(scanner, false, log); Assert.Equal(1.2m, result.Version); - Assert.Equal(13, result.OffsetInFile); + Assert.Equal(TestEnvironment.IsUnixPlatform ? 12 : 13, result.OffsetInFile); } [Fact] @@ -82,7 +82,7 @@ var result = FileHeaderParser.Parse(scanner, true, log); Assert.Equal(1.7m, result.Version); - Assert.Equal(13, result.OffsetInFile); + Assert.Equal(TestEnvironment.IsUnixPlatform ? 12 : 13, result.OffsetInFile); } [Fact] @@ -94,7 +94,7 @@ three %PDF-1.6"); var result = FileHeaderParser.Parse(scanner, true, log); Assert.Equal(1.6m, result.Version); - Assert.Equal(15, result.OffsetInFile); + Assert.Equal(TestEnvironment.IsUnixPlatform ? 14 : 15, result.OffsetInFile); } [Fact] diff --git a/src/UglyToad.PdfPig.Tests/TestEnvironment.cs b/src/UglyToad.PdfPig.Tests/TestEnvironment.cs new file mode 100644 index 00000000..abc44914 --- /dev/null +++ b/src/UglyToad.PdfPig.Tests/TestEnvironment.cs @@ -0,0 +1,9 @@ +namespace UglyToad.PdfPig.Tests +{ + using System; + + public static class TestEnvironment + { + public static readonly bool IsUnixPlatform = Environment.NewLine.Length == 1; + } +} diff --git a/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj b/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj index 7d1c6f49..6f7f0f5e 100644 --- a/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj +++ b/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj @@ -101,6 +101,7 @@ all runtime; build; native; contentfiles; analyzers +