2024-03-15 11:34:24 -07:00
|
|
|
|
using UglyToad.PdfPig.Fonts.SystemFonts;
|
2020-09-12 17:11:55 +01:00
|
|
|
|
using UglyToad.PdfPig.Tests.Dla;
|
|
|
|
|
|
|
|
|
|
|
|
namespace UglyToad.PdfPig.Tests.Fonts.SystemFonts
|
|
|
|
|
|
{
|
2022-04-03 15:00:38 -04:00
|
|
|
|
using PdfPig.Core;
|
2025-09-21 14:27:57 +01:00
|
|
|
|
using PdfPig.Geometry;
|
2022-04-03 15:00:38 -04:00
|
|
|
|
|
2020-09-12 17:11:55 +01:00
|
|
|
|
public class Linux
|
|
|
|
|
|
{
|
|
|
|
|
|
public static IEnumerable<object[]> DataExtract => new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new object[]
|
|
|
|
|
|
{
|
|
|
|
|
|
"90 180 270 rotated.pdf",
|
2022-04-03 15:00:38 -04:00
|
|
|
|
new ExpectedLetterData[]
|
|
|
|
|
|
{
|
|
|
|
|
|
new ExpectedLetterData
|
|
|
|
|
|
{
|
|
|
|
|
|
TopLeft = new PdfPoint(53.88, 759.48),
|
|
|
|
|
|
Width = 2.495859375,
|
|
|
|
|
|
Height = 0,
|
|
|
|
|
|
Rotation = 0
|
|
|
|
|
|
},
|
|
|
|
|
|
new ExpectedLetterData
|
|
|
|
|
|
{
|
|
|
|
|
|
TopLeft = new PdfPoint(514.925312502883, 744.099765720344),
|
|
|
|
|
|
Width = 6.83203125,
|
|
|
|
|
|
Height = 7.94531249999983,
|
|
|
|
|
|
Rotation = -90
|
|
|
|
|
|
},
|
|
|
|
|
|
new ExpectedLetterData
|
|
|
|
|
|
{
|
|
|
|
|
|
TopLeft = new PdfPoint(512.505390717836, 736.603703191305),
|
|
|
|
|
|
Width = 5.1796875,
|
|
|
|
|
|
Height = 5.68945312499983,
|
|
|
|
|
|
Rotation = -90
|
|
|
|
|
|
},
|
|
|
|
|
|
new ExpectedLetterData
|
|
|
|
|
|
{
|
|
|
|
|
|
TopLeft = new PdfPoint(512.505390785898, 730.931828191305),
|
|
|
|
|
|
Width = 3.99609375,
|
|
|
|
|
|
Height = 5.52539062499994,
|
|
|
|
|
|
Rotation = -90
|
|
|
|
|
|
},
|
2020-09-12 17:11:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-06-02 11:07:51 +02:00
|
|
|
|
[SkippableTheory]
|
2020-09-12 17:11:55 +01:00
|
|
|
|
[MemberData(nameof(DataExtract))]
|
2022-04-03 15:00:38 -04:00
|
|
|
|
public void GetCorrectBBoxLinux(string name, ExpectedLetterData[] expected)
|
2021-06-02 11:07:51 +02:00
|
|
|
|
{
|
|
|
|
|
|
// 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.");
|
|
|
|
|
|
|
2020-09-12 17:11:55 +01:00
|
|
|
|
using (var document = PdfDocument.Open(DlaHelper.GetDocumentPath(name)))
|
|
|
|
|
|
{
|
|
|
|
|
|
var page = document.GetPage(1);
|
|
|
|
|
|
for (int i = 0; i < expected.Length; i++)
|
|
|
|
|
|
{
|
2022-04-03 15:00:38 -04:00
|
|
|
|
var expectedData = expected[i];
|
|
|
|
|
|
|
|
|
|
|
|
var current = page.Letters[i];
|
|
|
|
|
|
|
2026-02-28 16:25:51 +00:00
|
|
|
|
Assert.Equal(expectedData.TopLeft.X, current.BoundingBox.TopLeft.X, 6);
|
|
|
|
|
|
Assert.Equal(expectedData.TopLeft.Y, current.BoundingBox.TopLeft.Y, 6);
|
|
|
|
|
|
Assert.Equal(expectedData.Width, current.BoundingBox.Width, 6);
|
|
|
|
|
|
Assert.Equal(expectedData.Height, current.BoundingBox.Height, 6);
|
|
|
|
|
|
Assert.Equal(expectedData.Rotation, current.BoundingBox.Rotation, 3);
|
2025-09-21 14:27:57 +01:00
|
|
|
|
|
2026-02-28 16:25:51 +00:00
|
|
|
|
Assert.True(current.BoundingBox.IntersectsWith(current.GlyphRectangleLoose));
|
|
|
|
|
|
Assert.Equal(current.BoundingBox.Rotation, current.GlyphRectangleLoose.Rotation, 3);
|
2020-09-12 17:11:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-04-03 15:00:38 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ExpectedLetterData
|
|
|
|
|
|
{
|
|
|
|
|
|
public PdfPoint TopLeft { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public double Width { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public double Height { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public double Rotation { get; set; }
|
2020-09-12 17:11:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|