diff --git a/.gitattributes b/.gitattributes index f7bd4d061..7de2c1597 100644 --- a/.gitattributes +++ b/.gitattributes @@ -85,18 +85,12 @@ ############################################################################### *.basis binary *.dll binary -*.eot binary *.exe binary -*.otf binary *.pdf binary *.ppt binary *.pptx binary *.pvr binary *.snk binary -*.ttc binary -*.ttf binary -*.woff binary -*.woff2 binary *.xls binary *.xlsx binary ############################################################################### @@ -126,6 +120,7 @@ *.dds filter=lfs diff=lfs merge=lfs -text *.ktx filter=lfs diff=lfs merge=lfs -text *.ktx2 filter=lfs diff=lfs merge=lfs -text +*.astc filter=lfs diff=lfs merge=lfs -text *.pam filter=lfs diff=lfs merge=lfs -text *.pbm filter=lfs diff=lfs merge=lfs -text *.pgm filter=lfs diff=lfs merge=lfs -text @@ -143,3 +138,12 @@ # Handle ICC files by git lfs ############################################################################### *.icc filter=lfs diff=lfs merge=lfs -text +############################################################################### +# Handle font files by git lfs +############################################################################### +*.eot filter=lfs diff=lfs merge=lfs -text +*.otf filter=lfs diff=lfs merge=lfs -text +*.ttc filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.woff filter=lfs diff=lfs merge=lfs -text +*.woff2 filter=lfs diff=lfs merge=lfs -text diff --git a/SixLabors.Fonts.sln b/SixLabors.Fonts.sln index a7d974b2e..41d80f947 100644 --- a/SixLabors.Fonts.sln +++ b/SixLabors.Fonts.sln @@ -31,15 +31,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SixLabors.Fonts", "src\SixL EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SixLabors.Fonts.Tests", "tests\SixLabors.Fonts.Tests\SixLabors.Fonts.Tests.csproj", "{F836E8E6-B4D9-4208-8346-140C74678B91}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{71A3911C-D6B9-4EBE-9691-2FE28BDF462E}" - ProjectSection(SolutionItems) = preProject - samples\Directory.Build.props = samples\Directory.Build.props - samples\Directory.Build.targets = samples\Directory.Build.targets - samples\Fonts.Samples.ruleset = samples\Fonts.Samples.ruleset - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListFonts", "samples\ListFonts\ListFonts.csproj", "{6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{7CDD4908-7CCD-4945-860C-D2F1732D3AE6}" ProjectSection(SolutionItems) = preProject .github\CONTRIBUTING.md = .github\CONTRIBUTING.md @@ -73,8 +64,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnicodeTestData", "UnicodeT EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SixLabors.Fonts.Benchmarks", "tests\SixLabors.Fonts.Benchmarks\SixLabors.Fonts.Benchmarks\SixLabors.Fonts.Benchmarks.csproj", "{FB8FDC5F-7FEB-4132-9133-C25E05C0B3D9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DrawWithImageSharp", "samples\DrawWithImageSharp\DrawWithImageSharp.csproj", "{01863664-6C7E-61F2-F74B-7D451FFDC3C2}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -89,10 +78,6 @@ Global {F836E8E6-B4D9-4208-8346-140C74678B91}.Debug|Any CPU.Build.0 = Debug|Any CPU {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.ActiveCfg = Release|Any CPU {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.Build.0 = Release|Any CPU - {6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA}.Release|Any CPU.Build.0 = Release|Any CPU {ABB6E111-672F-4846-88D6-C49C6CD01606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ABB6E111-672F-4846-88D6-C49C6CD01606}.Debug|Any CPU.Build.0 = Debug|Any CPU {ABB6E111-672F-4846-88D6-C49C6CD01606}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -101,10 +86,6 @@ Global {FB8FDC5F-7FEB-4132-9133-C25E05C0B3D9}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB8FDC5F-7FEB-4132-9133-C25E05C0B3D9}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB8FDC5F-7FEB-4132-9133-C25E05C0B3D9}.Release|Any CPU.Build.0 = Release|Any CPU - {01863664-6C7E-61F2-F74B-7D451FFDC3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {01863664-6C7E-61F2-F74B-7D451FFDC3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {01863664-6C7E-61F2-F74B-7D451FFDC3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {01863664-6C7E-61F2-F74B-7D451FFDC3C2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -112,14 +93,12 @@ Global GlobalSection(NestedProjects) = preSolution {09E744EC-4852-4FC7-BE78-C1B399F17967} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {F836E8E6-B4D9-4208-8346-140C74678B91} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} - {6DF4C474-1FDF-4DE0-9CB2-9674D2CCE1BA} = {71A3911C-D6B9-4EBE-9691-2FE28BDF462E} {7CDD4908-7CCD-4945-860C-D2F1732D3AE6} = {C317F1B1-D75E-4C6D-83EB-80367343E0D7} {EC0F1812-C6AF-48D8-882B-5637730D2DB1} = {7CDD4908-7CCD-4945-860C-D2F1732D3AE6} {CFCC940C-DEA3-42CC-9626-0B7D09289FF4} = {7CDD4908-7CCD-4945-860C-D2F1732D3AE6} {ABB6E111-672F-4846-88D6-C49C6CD01606} = {249327CF-1415-428B-8EEA-8C7705B1DE8F} {654DD381-B93D-4459-B669-296F5D9172ED} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {FB8FDC5F-7FEB-4132-9133-C25E05C0B3D9} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} - {01863664-6C7E-61F2-F74B-7D451FFDC3C2} = {71A3911C-D6B9-4EBE-9691-2FE28BDF462E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {38F4B47F-4F74-40F5-8707-C0EF1D0BDF92} diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props deleted file mode 100644 index 2dbf17e14..000000000 --- a/samples/Directory.Build.props +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - samples - false - - - - - - - ..\Fonts.Samples.ruleset - - - diff --git a/samples/Directory.Build.targets b/samples/Directory.Build.targets deleted file mode 100644 index b0310fc38..000000000 --- a/samples/Directory.Build.targets +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/samples/DrawWithImageSharp/BoundingBoxes.cs b/samples/DrawWithImageSharp/BoundingBoxes.cs deleted file mode 100644 index 49815fcd1..000000000 --- a/samples/DrawWithImageSharp/BoundingBoxes.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Numerics; -using SixLabors.Fonts; -using SixLabors.Fonts.Rendering; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using IOPath = System.IO.Path; - -namespace DrawWithImageSharp; - -public static class BoundingBoxes -{ - public static void Generate(string text, TextOptions options) - { - FontRectangle bounds = TextMeasurer.MeasureBounds(text, options); - FontRectangle advance = TextMeasurer.MeasureAdvance(text, options); - using Image image = new((int)Math.Ceiling(options.Origin.X + (Math.Max(advance.Width, bounds.Width) + 1)), (int)Math.Ceiling(options.Origin.Y + (Math.Max(advance.Height, bounds.Height) + 1))); - image.Mutate(x => x.Fill(Color.White)); - - Vector2 origin = options.Origin; - - FontRectangle size = TextMeasurer.MeasureSize(text, options); - - (IPathCollection paths, IPathCollection boxes) = GenerateGlyphsWithBox(text, options); - image.Mutate( - x => x.Fill(Color.Black, paths) - .Draw(Color.Yellow, 1, boxes) - .Draw(Color.Purple, 1, new RectangularPolygon(bounds.X, bounds.Y, bounds.Width, bounds.Height)) - .Draw(Color.Green, 1, new RectangularPolygon(size.X + bounds.X, size.Y + bounds.Y, size.Width, size.Height)) - .Draw(Color.Red, 1, new RectangularPolygon(advance.X + origin.X, advance.Y + origin.Y, advance.Width, advance.Height))); - - string path = IOPath.GetInvalidFileNameChars().Aggregate(text, (x, c) => x.Replace($"{c}", "-")); - string fullPath = IOPath.GetFullPath(IOPath.Combine($"Output/Boxed/{options.Font.Name}", IOPath.Combine(path))); - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - - image.Save($"{fullPath}.png"); - } - - /// - /// Generates the shapes corresponding the glyphs described by the font and settings. - /// - /// The text to generate glyphs for - /// The style and settings to use while rendering the glyphs - /// The paths, boxes, and text box. - private static (IPathCollection Paths, IPathCollection Boxes) GenerateGlyphsWithBox(string text, TextOptions options) - { - CustomGlyphBuilder glyphBuilder = new(); - - TextRenderer renderer = new(glyphBuilder); - - renderer.RenderText(text, options); - - return (glyphBuilder.Paths, glyphBuilder.Boxes); - } -} diff --git a/samples/DrawWithImageSharp/CustomGlyphBuilder.cs b/samples/DrawWithImageSharp/CustomGlyphBuilder.cs deleted file mode 100644 index dc9fb5057..000000000 --- a/samples/DrawWithImageSharp/CustomGlyphBuilder.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Numerics; -using SixLabors.Fonts; -using SixLabors.Fonts.Rendering; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Text; - -namespace DrawWithImageSharp; - -/// -/// A custom glyph builder used to render character and text bounds. -/// -internal sealed class CustomGlyphBuilder : GlyphBuilder -{ - private readonly List glyphBounds = []; - - public CustomGlyphBuilder() - { - } - - public CustomGlyphBuilder(Vector2 origin) - : base(origin) - { - } - - /// - /// Gets the paths that have been rendered by this. - /// - public IPathCollection Boxes => new PathCollection(this.glyphBounds.Select(x => new RectangularPolygon(x.X, x.Y, x.Width, x.Height))); - - /// - /// Gets the paths that have been rendered by this builder. - /// - public IPath TextBox { get; private set; } - - protected override void BeginText(in FontRectangle bounds) - { - this.TextBox = new RectangularPolygon(bounds.X, bounds.Y, bounds.Width, bounds.Height); - base.BeginText(bounds); - } - - protected override void BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters) - { - this.glyphBounds.Add(bounds); - - base.BeginText(bounds); - } -} diff --git a/samples/DrawWithImageSharp/DrawWithImageSharp.csproj b/samples/DrawWithImageSharp/DrawWithImageSharp.csproj deleted file mode 100644 index cab0193e1..000000000 --- a/samples/DrawWithImageSharp/DrawWithImageSharp.csproj +++ /dev/null @@ -1,52 +0,0 @@ - - - - portable - Exe - true - - - SixLabors.ImageSharp.Tests - DrawWithImageSharp - - - - - - net8.0;net9.0 - - - - - net8.0 - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - - - - - diff --git a/samples/DrawWithImageSharp/NuGet.config b/samples/DrawWithImageSharp/NuGet.config deleted file mode 100644 index e7c5c4504..000000000 --- a/samples/DrawWithImageSharp/NuGet.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/samples/DrawWithImageSharp/Program.cs b/samples/DrawWithImageSharp/Program.cs deleted file mode 100644 index 968cbe937..000000000 --- a/samples/DrawWithImageSharp/Program.cs +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Globalization; -using System.Numerics; -using System.Text; -using DrawWithImageSharp; -using SixLabors.Fonts.Unicode; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.Drawing.Processing.Processors.Text; -using SixLabors.ImageSharp.Drawing.Text; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using IOPath = System.IO.Path; - -namespace SixLabors.Fonts.DrawWithImageSharp; - -public static class Program -{ - public static void Main(string[] args) - { - var fonts = new FontCollection(); - var woffFonts = new FontCollection(); - FontFamily font = fonts.Add(IOPath.Combine("Fonts", "SixLaborsSampleAB.ttf")); - FontFamily fontWoff = woffFonts.Add(IOPath.Combine("Fonts", "SixLaborsSampleAB.woff")); - FontFamily fontWoff2 = woffFonts.Add(IOPath.Combine("Fonts", "OpenSans-Regular.woff2")); - FontFamily carter = fonts.Add(IOPath.Combine("Fonts", "CarterOne.ttf")); - FontFamily wendyOne = fonts.Add(IOPath.Combine("Fonts", "WendyOne-Regular.ttf")); - FontFamily whitneyBook = fonts.Add(IOPath.Combine("Fonts", "whitney-book.ttf")); - FontFamily colorEmoji = fonts.Add(IOPath.Combine("Fonts", "Twemoji Mozilla.ttf")); - FontFamily openSans = fonts.Add(IOPath.Combine("Fonts", "OpenSans-Regular.ttf")); - FontFamily sunflower = fonts.Add(IOPath.Combine("Fonts", "Sunflower-Medium.ttf")); - FontFamily bugzilla = fonts.Add(IOPath.Combine("Fonts", "me_quran_volt_newmet.ttf")); - - FontFamily notoKR = fonts.Add(IOPath.Combine("Fonts", "NotoSansKR-Regular.otf")); - FontFamily marker = fonts.Add(IOPath.Combine("Fonts", "PermanentMarker-Regular.ttf")); - - FontFamily sEmji = fonts.Add(IOPath.Combine("Fonts", "seguiemj-win11.ttf")); - BoundingBoxes.Generate("\U0001F469\U0001F3FB\u200D\U0001F91D\u200D\U0001F469\U0001F3FC", new TextOptions(sEmji.CreateFont(72)) { LineSpacing = 1.4f }); - BoundingBoxes.Generate("\U0001F46D\U0001F3FB", new TextOptions(sEmji.CreateFont(72)) { LineSpacing = 1.4f }); - BoundingBoxes.Generate("È", new TextOptions(marker.CreateFont(142)) { LineSpacing = 1.4f }); - BoundingBoxes.Generate("H", new TextOptions(whitneyBook.CreateFont(25))); - - openSans.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); - BoundingBoxes.Generate("A\nA\nA\nA", new TextOptions(openSans.CreateFont(metrics.UnitsPerEm)) { LineSpacing = 1.5f }); - - RenderText(notoKR, "\uD734", pointSize: 72); - RenderText(notoKR, "Sphinx of black quartz, judge my vow!", pointSize: 72); - RenderText(notoKR, "모든인간", pointSize: 72); - RenderText(notoKR, "\uD734\uAC00\u0020\uAC00\u002D\u002D\u0020\u0028\uC624\u002D\u002D\u0029", pointSize: 72); - RenderText(notoKR, "\u1112\u1172\u1100\u1161\u0020\u1100\u1161\u002D\u002D\u0020\u0028\u110B\u1169\u002D\u002D\u0029", pointSize: 72); - RenderText(notoKR, "\ua960\ud7b0\ud7cb", pointSize: 72); - RenderText(notoKR, "\u1100\u1161\ud7cb", pointSize: 72); - RenderText(notoKR, "\ua960\ud7b0\u302f", pointSize: 72); - RenderText(notoKR, "\u1100\u302f\u1161", pointSize: 72); - RenderText(notoKR, "\u1100", pointSize: 72); - -#if OS_WINDOWS - - FontFamily arial = SystemFonts.Get("Arial"); - FontFamily jhengHei = SystemFonts.Get("Microsoft JhengHei"); - FontFamily emojiFont = SystemFonts.Get("Segoe UI Emoji"); - FontFamily uiFont = SystemFonts.Get("Segoe UI"); - FontFamily arabicFont = SystemFonts.Get("Dubai"); - FontFamily tahoma = SystemFonts.Get("Tahoma"); - - BoundingBoxes.Generate( - "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu グレートブリテンおよび北アイルランド連合王国という言葉は本当に長い言葉", - new TextOptions(arial.CreateFont(20)) - { - WrappingLength = 400, - LayoutMode = LayoutMode.HorizontalBottomTop, - WordBreaking = WordBreaking.Standard, - FallbackFontFamilies = new[] { jhengHei } - }); - - return; - RenderText(arial, "abcdefghijklmnopqrstuvwxyz", pointSize: 30); - RenderText(arial, "abcdefghijklmnopqrstuvwxyz\r\nabcdefghijklmnopqrstuvwxyz", pointSize: 30); - RenderText(arial, "abcdef ghijk lmnopq rstuvwxyz", pointSize: 30); - // return; - - var textRuns = new List - { - new RichTextRun { Start = 4, End = 10, Font = uiFont.CreateFont(72, FontStyle.Bold), TextAttributes = TextAttributes.Superscript, TextDecorations = TextDecorations.Underline | TextDecorations.Strikeout | TextDecorations.Overline }, - new RichTextRun { Start = 26, End = 30, Font = uiFont.CreateFont(72, FontStyle.Italic), TextAttributes = TextAttributes.Subscript, TextDecorations = TextDecorations.Strikeout | TextDecorations.Underline | TextDecorations.Overline } - }; - - RenderText(uiFont, "The quick👩🏽‍🚒 brown fox jumps over the lazy dog", pointSize: 72, textRuns: textRuns, fallbackFonts: new[] { emojiFont }); - - string arabic = "بِسْمِ ٱللَّهِ ٱلرَّحْمَٟنِ ٱلرَّحِيمِ"; - textRuns = new List - { - new RichTextRun { Start = 0, End = arabic.GetGraphemeCount(), TextDecorations = TextDecorations.Underline } - }; - - RenderText(uiFont, arabic, pointSize: 72, textRuns: textRuns); - - textRuns = new List - { - new RichTextRun { Start = 0, End = arabic.GetGraphemeCount(), TextDecorations = TextDecorations.Underline } - }; - RenderText(bugzilla, arabic, pointSize: 72, textRuns: textRuns); - - RenderText(openSans, "\uFB01", pointSize: 11.25F); - RenderText(fontWoff2, "\uFB01", pointSize: 11.25F); - RenderText(tahoma, "p", pointSize: 11.25F); - RenderText(tahoma, "Lorem ipsum dolor sit amet", pointSize: 11.25F); - RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72); - - RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72); - - RenderText(uiFont, "first\n\n\n\nl", pointSize: 20, fallbackFonts: new[] { openSans }); - - RenderText(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { openSans }); - RenderText(uiFont, "Testing", pointSize: 20); - RenderText(emojiFont, "👩🏽‍🚒a", pointSize: 72, fallbackFonts: new[] { openSans }); - RenderText(arabicFont, "English اَلْعَرَبِيَّةُ English", pointSize: 20); - RenderText(arabicFont, "English English", pointSize: 20); - RenderText(arabicFont, "اَلْعَرَبِيَّةُ اَلْعَرَبِيَّةُ", pointSize: 20); - RenderText(arabicFont, "اَلْعَرَبِيَّةُ", pointSize: 20); - RenderText(arabicFont, "SS ص", pointSize: 20); - RenderText(arabicFont, "S ص", pointSize: 20); - RenderText(arabicFont, "English اَلْعَرَبِيَّةُ", pointSize: 20); - - RenderTextProcessorWithAlignment(emojiFont, "😀A😀", pointSize: 20, fallbackFonts: new[] { colorEmoji }); - RenderTextProcessorWithAlignment(uiFont, "this\nis\na\ntest", pointSize: 20, fallbackFonts: new[] { openSans }); - RenderTextProcessorWithAlignment(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { openSans }); - - RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { openSans }); - RenderText(openSans, string.Empty, pointSize: 72, fallbackFonts: new[] { emojiFont }); - RenderText(openSans, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont }); -#endif - - // fallback font tests - RenderTextProcessor(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { openSans }); - RenderText(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { openSans }); - - RenderText(colorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { openSans }); - - //// general - RenderText(font, "abc", 72); - RenderText(font, "ABd", 72); - RenderText(fontWoff, "abe", 72); - RenderText(fontWoff, "ABf", 72); - RenderText(fontWoff2, "woff2", 72); - RenderText(openSans, "ov", 72); - RenderText(openSans, "a\ta", 72); - RenderText(openSans, "aa\ta", 72); - RenderText(openSans, "aaa\ta", 72); - RenderText(openSans, "aaaa\ta", 72); - RenderText(openSans, "aaaaa\ta", 72); - RenderText(openSans, "aaaaaa\ta", 72); - RenderText(openSans, "Hello\nWorld", 72); - RenderText(carter, "Hello\0World", 72); - RenderText(wendyOne, "Hello\0World", 72); - RenderText(whitneyBook, "Hello\0World", 72); - RenderText(sunflower, "í", 30); - - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 4 }, "\t\tx"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 4 }, "\t\t\tx"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 4 }, "\t\t\t\tx"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 4 }, "\t\t\t\t\tx"); - - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 0 }, "Zero\tTab"); - - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 0 }, "Zero\tTab"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, "One\tTab"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 6 }, "\tTab Then Words"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, "Tab Then Words"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, "Words Then Tab\t"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, " Spaces Then Words"); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, "Words Then Spaces "); - RenderText(new RichTextOptions(new Font(openSans, 72)) { TabWidth = 1 }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs"); - -#if OS_WINDOWS - RenderText(new Font(SystemFonts.Get("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50); - RenderText(new Font(SystemFonts.Get("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50); - RenderText(new RichTextOptions(SystemFonts.CreateFont("consolas", 72)) { TabWidth = 4 }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx"); - BoundingBoxes.Generate("a b c y q G H T", new TextOptions(SystemFonts.CreateFont("arial", 40f))); - TextAlignmentSample.Generate(SystemFonts.CreateFont("arial", 50f)); - TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f)); - - FontFamily simsum = SystemFonts.Get("SimSun"); - RenderText(simsum, "这是一段长度超出设定的换行宽度的文本,但是没有在设定的宽度处换行。这段文本用于演示问题。希望可以修复。如果有需要可以联系我。", 16); - RenderText(jhengHei, " ,;:!¥()?{}-=+\|~!@#%&", 16); - RenderText(arial, "ìíîï", 72); -#endif - var sb = new StringBuilder(); - for (char c = 'a'; c <= 'z'; c++) - { - sb.Append(c); - } - - for (char c = 'A'; c <= 'Z'; c++) - { - sb.Append(c); - } - - for (char c = '0'; c <= '9'; c++) - { - sb.Append(c); - } - - string text = sb.ToString(); - - foreach (FontFamily f in fonts.Families) - { - RenderText(f, text, 72); - } - } - - public static void RenderText(Font font, string text, int width, int height) - { - string path = IOPath.GetInvalidFileNameChars().Aggregate(text, (x, c) => x.Replace($"{c}", "-")); - string fullPath = IOPath.GetFullPath(IOPath.Combine("Output", IOPath.Combine(path))); - - using var img = new Image(width, height); - img.Mutate(x => x.Fill(Color.White)); - - IPathCollection shapes = TextBuilder.GeneratePaths(text, new RichTextOptions(font) { Origin = new Vector2(50f, 4f) }); - img.Mutate(x => x.Fill(Color.Black, shapes)); - - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - - using FileStream fs = File.Create(fullPath + ".png"); - img.SaveAsPng(fs); - } - - public static void RenderText(RichTextOptions options, string text) - { - FontRectangle size = TextMeasurer.MeasureAdvance(text, options); - if (size == FontRectangle.Empty) - { - return; - } - - SaveImage(options, text, (int)size.Width, (int)size.Height, options.Font.Name, text + ".png"); - } - - public static void RenderText( - FontFamily font, - string text, - float pointSize = 12, - IEnumerable fallbackFonts = null, - IEnumerable textRuns = null) - => RenderText( - new RichTextOptions(new Font(font, pointSize)) - { - WrappingLength = 180, - FallbackFontFamilies = fallbackFonts?.ToArray(), - TextRuns = textRuns?.ToArray(), - WordBreaking = WordBreaking.BreakWord - }, - text); - - public static void RenderTextProcessor( - FontFamily fontFamily, - string text, - float pointSize = 12, - IEnumerable fallbackFonts = null) - { - Font font = new(fontFamily, pointSize); - RichTextOptions textOptions = new(font) - { - Dpi = 96, - }; - - if (fallbackFonts != null) - { - textOptions.FallbackFontFamilies = fallbackFonts.ToArray(); - } - - FontRectangle textSize = TextMeasurer.MeasureAdvance(text, textOptions); - textOptions.Origin = new PointF(5, 5); - - using var img = new Image((int)Math.Ceiling(textSize.Width) + 20, (int)Math.Ceiling(textSize.Height) + 20); - img.Mutate(x => x.Fill(Color.White).ApplyProcessor(new DrawTextProcessor(x.GetDrawingOptions(), textOptions, text, new SolidBrush(Color.Black), null))); - - string fullPath = CreatePath(font.Name, text + ".caching.png"); - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - img.Save(fullPath); - } - - public static void RenderTextProcessorWithAlignment( - FontFamily fontFamily, - string text, - float pointSize = 12, - IEnumerable fallbackFonts = null) - { - foreach (VerticalAlignment va in (VerticalAlignment[])Enum.GetValues(typeof(VerticalAlignment))) - { - foreach (HorizontalAlignment ha in (HorizontalAlignment[])Enum.GetValues(typeof(HorizontalAlignment))) - { - Font font = new(fontFamily, pointSize); - RichTextOptions textOptions = new(font) - { - Dpi = 96, - VerticalAlignment = va, - HorizontalAlignment = ha, - }; - - if (fallbackFonts != null) - { - textOptions.FallbackFontFamilies = fallbackFonts.ToArray(); - } - - FontRectangle textSize = TextMeasurer.MeasureSize(text, textOptions); - using var img = new Image(((int)textSize.Width * 2) + 20, ((int)textSize.Height * 2) + 20); - Size size = img.Size; - textOptions.Origin = new PointF(size.Width / 2F, size.Height / 2F); - - img.Mutate(x => x.Fill(Color.Black).ApplyProcessor( - new DrawTextProcessor( - x.GetDrawingOptions(), - textOptions, - text, - new SolidBrush(Color.Yellow), - null))); - - img[size.Width / 2, size.Height / 2] = Color.White.ToPixel(); - - string h = ha.ToString().Replace(nameof(HorizontalAlignment), string.Empty).ToLower(); - string v = va.ToString().Replace(nameof(VerticalAlignment), string.Empty).ToLower(); - - string fullPath = CreatePath(font.Name, text + "-" + h + "-" + v + ".png"); - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - img.Save(fullPath); - } - } - } - - private static string CreatePath(params string[] path) - { - path = path.Select(p => IOPath.GetInvalidFileNameChars().Aggregate(p, (x, c) => x.Replace($"{c}", "-"))).ToArray(); - return IOPath.GetFullPath(IOPath.Combine("Output", IOPath.Combine(path))); - } - - private static void SaveImage( - RichTextOptions options, - string text, - int width, - int height, - params string[] path) - { - string fullPath = CreatePath(path); - - using var img = new Image(width, height); - img.Mutate(x => x.Fill(Color.Black)); - - img.Mutate(x => x.DrawText(options, text, Color.White)); - - // Ensure directory exists - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - - using FileStream fs = File.Create(fullPath); - img.SaveAsPng(fs); - } - - public static void SaveImage(this IEnumerable shapes, params string[] path) - { - IPath shape = new ComplexPolygon(shapes.ToArray()); - shape = shape.Translate(shape.Bounds.Location * -1) // touch top left - .Translate(new Vector2(10)); // move in from top left - - var sb = new StringBuilder(); - IEnumerable converted = shape.Flatten(); - converted.Aggregate(sb, (s, p) => - { - ReadOnlySpan points = p.Points.Span; - for (int i = 0; i < points.Length; i++) - { - PointF point = points[i]; - sb.Append(point.X); - sb.Append('x'); - sb.Append(point.Y); - sb.Append(' '); - } - - s.Append('\n'); - return s; - }); - string str = sb.ToString(); - shape = new ComplexPolygon(converted.Select(x => new Polygon(new LinearLineSegment(x.Points.ToArray()))).ToArray()); - - path = path.Select(p => IOPath.GetInvalidFileNameChars().Aggregate(p, (x, c) => x.Replace($"{c}", "-"))).ToArray(); - string fullPath = IOPath.GetFullPath(IOPath.Combine("Output", IOPath.Combine(path))); - - // pad even amount around shape - int width = (int)(shape.Bounds.Left + shape.Bounds.Right); - int height = (int)(shape.Bounds.Top + shape.Bounds.Bottom); - if (width < 1) - { - width = 1; - } - - if (height < 1) - { - height = 1; - } - - using var img = new Image(width, height); - img.Mutate(x => x.Fill(Color.DarkBlue)); - img.Mutate(x => x.Fill(Color.HotPink, shape)); - - // img.Draw(Color.LawnGreen, 1, shape); - - // Ensure directory exists - Directory.CreateDirectory(IOPath.GetDirectoryName(fullPath)); - - using FileStream fs = File.Create(fullPath); - img.SaveAsPng(fs); - } -} diff --git a/samples/DrawWithImageSharp/TextAlignmentSample.cs b/samples/DrawWithImageSharp/TextAlignmentSample.cs deleted file mode 100644 index 1bec4e407..000000000 --- a/samples/DrawWithImageSharp/TextAlignmentSample.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Numerics; -using SixLabors.Fonts; -using SixLabors.Fonts.Rendering; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace DrawWithImageSharp; - -public static class TextAlignmentSample -{ - public static void Generate(Font font) - { - using Image img = new(1000, 1000); - img.Mutate(x => x.Fill(Color.White)); - - foreach (VerticalAlignment v in Enum.GetValues(typeof(VerticalAlignment))) - { - foreach (HorizontalAlignment h in Enum.GetValues(typeof(HorizontalAlignment))) - { - Draw(img, font, v, h); - } - } - - img.Save("Output/Alignment.png"); - } - - public static void Draw(Image img, Font font, VerticalAlignment vert, HorizontalAlignment horiz) - { - Vector2 location = Vector2.Zero; - - switch (vert) - { - case VerticalAlignment.Top: - location.Y = 0; - break; - case VerticalAlignment.Center: - location.Y = img.Height / 2F; - break; - case VerticalAlignment.Bottom: - location.Y = img.Height; - break; - default: - break; - } - - switch (horiz) - { - case HorizontalAlignment.Left: - location.X = 0; - break; - case HorizontalAlignment.Right: - location.X = img.Width; - break; - case HorizontalAlignment.Center: - location.X = img.Width / 2F; - break; - default: - break; - } - - CustomGlyphBuilder glyphBuilder = new(); - - TextRenderer renderer = new(glyphBuilder); - - TextOptions textOptions = new(font) - { - TabWidth = 4, - WrappingLength = 0, - HorizontalAlignment = horiz, - VerticalAlignment = vert, - Origin = location - }; - - string text = $"{horiz} x y z\n{vert} x y z"; - renderer.RenderText(text, textOptions); - - IEnumerable shapesToDraw = glyphBuilder.Paths; - img.Mutate(x => x.Fill(Color.Black, glyphBuilder.Paths)); - - Color f = Color.Fuchsia.WithAlpha(.5F); - img.Mutate(x => x.Fill(Color.Black, glyphBuilder.Paths)); - img.Mutate(x => x.Draw(f, 1, glyphBuilder.Boxes)); - img.Mutate(x => x.Draw(Color.Lime, 1, glyphBuilder.TextBox)); - } -} diff --git a/samples/DrawWithImageSharp/TextAlignmentWrapped.cs b/samples/DrawWithImageSharp/TextAlignmentWrapped.cs deleted file mode 100644 index 24b272bf3..000000000 --- a/samples/DrawWithImageSharp/TextAlignmentWrapped.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Numerics; -using SixLabors.Fonts; -using SixLabors.Fonts.Rendering; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; - -namespace DrawWithImageSharp; - -public static class TextAlignmentWrapped -{ - public static void Generate(Font font) - { - const int wrappingWidth = 400; - const int size = (wrappingWidth + (wrappingWidth / 3)) * 3; - - using Image img = new(size, size); - img.Mutate(x => x.Fill(Color.White)); - - foreach (VerticalAlignment v in Enum.GetValues(typeof(VerticalAlignment))) - { - foreach (HorizontalAlignment h in Enum.GetValues(typeof(HorizontalAlignment))) - { - Draw(img, font, v, h, wrappingWidth); - } - } - - img.Save("Output/AlignmentWrapped.png"); - } - - public static void Draw(Image img, Font font, VerticalAlignment vert, HorizontalAlignment horiz, float wrappingWidth) - { - Vector2 location = Vector2.Zero; - switch (vert) - { - case VerticalAlignment.Top: - location.Y = 0; - break; - case VerticalAlignment.Center: - location.Y = img.Height / 2F; - break; - case VerticalAlignment.Bottom: - location.Y = img.Height; - break; - default: - break; - } - - switch (horiz) - { - case HorizontalAlignment.Left: - - location.X = 0; - break; - case HorizontalAlignment.Right: - location.X = img.Width; - break; - case HorizontalAlignment.Center: - location.X = img.Width / 2F; - break; - default: - break; - } - - CustomGlyphBuilder glyphBuilder = new(); - - TextRenderer renderer = new(glyphBuilder); - - TextOptions textOptions = new(font) - { - TabWidth = 4, - WrappingLength = wrappingWidth, - HorizontalAlignment = horiz, - VerticalAlignment = vert, - Origin = location - }; - - string text = $" {horiz} {vert} {horiz} {vert} {horiz} {vert} "; - renderer.RenderText(text, textOptions); - - IEnumerable shapesToDraw = glyphBuilder.Paths; - img.Mutate(x => x.Fill(Color.Black, glyphBuilder.Paths)); - - Color f = Color.Fuchsia.WithAlpha(.5F); - img.Mutate(x => x.Fill(Color.Black, glyphBuilder.Paths)); - img.Mutate(x => x.Draw(f, 1, glyphBuilder.Boxes)); - img.Mutate(x => x.Draw(Color.Lime, 1, glyphBuilder.TextBox)); - } -} diff --git a/samples/Fonts.Samples.ruleset b/samples/Fonts.Samples.ruleset deleted file mode 100644 index b62d3e10d..000000000 --- a/samples/Fonts.Samples.ruleset +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/ListFonts/ListFonts.csproj b/samples/ListFonts/ListFonts.csproj deleted file mode 100644 index 24fb7b7f0..000000000 --- a/samples/ListFonts/ListFonts.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - - - - - - net8.0;net9.0 - - - - - net8.0 - - - - - - - - - diff --git a/samples/ListFonts/Program.cs b/samples/ListFonts/Program.cs deleted file mode 100644 index d76588502..000000000 --- a/samples/ListFonts/Program.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -using System.Diagnostics; -using SixLabors.Fonts; - -namespace ListFonts; - -public static class Program -{ - public static void Main(string[] args) - { - var pairings = new List(); - IOrderedEnumerable ordered = SystemFonts.Families.OrderBy(x => x.Name); - foreach (FontFamily family in ordered) - { - IOrderedEnumerable styles = family.GetAvailableStyles().OrderBy(x => x); - foreach (FontStyle style in styles) - { - Font font = family.CreateFont(0F, style); - font.TryGetPath(out string path); - pairings.Add(new Pairing(font.Name, path)); - } - } - - int max = pairings.Max(x => x.Name.Length); - foreach (Pairing p in pairings) - { - Console.WriteLine($"{p.Name.PadRight(max)} {p.Path}"); - } - - if (Debugger.IsAttached) - { - Console.WriteLine(string.Empty); - while (!Console.KeyAvailable) - { - Thread.Sleep(100); - } - } - } - - public struct Pairing - { - public Pairing(string name, string path) - { - this.Name = name; - this.Path = path; - } - - public string Name { get; } - - public string Path { get; } - } -} diff --git a/shared-infrastructure b/shared-infrastructure index 57699ffb7..bed6f53be 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 57699ffb797bc2389c5d6cbb3b1800f2eb5fb947 +Subproject commit bed6f53bea0239e4afa19e81c24a6fff421707e1 diff --git a/src/UnicodeTrieGenerator/StateAutomation/DeterministicFiniteAutomata.cs b/src/UnicodeTrieGenerator/StateAutomation/DeterministicFiniteAutomata.cs index 0732e5252..5484c5ff0 100644 --- a/src/UnicodeTrieGenerator/StateAutomation/DeterministicFiniteAutomata.cs +++ b/src/UnicodeTrieGenerator/StateAutomation/DeterministicFiniteAutomata.cs @@ -24,7 +24,7 @@ public static IEnumerable Build(ILogicalNode root, int numSymbols) State failState = new(new HashSet(), numSymbols); State initialState = new(root.FirstPos, numSymbols); - List dstates = new() { failState, initialState }; + List dstates = [failState, initialState]; // While there is an unmarked state S in dstates while (true) @@ -53,7 +53,7 @@ public static IEnumerable Build(ILogicalNode root, int numSymbols) { // let U be the union of followpos(p) for all // p in S that correspond to a - HashSet u = new(); + HashSet u = []; foreach (INode p in s.Positions) { if (p is Literal l && l.Value == a) diff --git a/tests/Fonts/AdobeVFPrototype-Subset.otf b/tests/Fonts/AdobeVFPrototype-Subset.otf new file mode 100644 index 000000000..59cc0153d --- /dev/null +++ b/tests/Fonts/AdobeVFPrototype-Subset.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f7e3b59c2c44ba3683bd636b4f24541ec405f9132b4d37eef1baa78ebb559db +size 7096 diff --git a/tests/Fonts/AdobeVFPrototype.ttf b/tests/Fonts/AdobeVFPrototype.ttf new file mode 100644 index 000000000..f15da0f16 --- /dev/null +++ b/tests/Fonts/AdobeVFPrototype.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:518cdd59e6d50b7072c050fcbaa55b072cf99df5a549c61973f107ad9980f26f +size 179988 diff --git a/tests/Fonts/AliceFrancesHMK-Regular.ttf b/tests/Fonts/AliceFrancesHMK-Regular.ttf new file mode 100644 index 000000000..d99c0f99c --- /dev/null +++ b/tests/Fonts/AliceFrancesHMK-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83b5a17789d330ced68956e5c555fdcb1aac95d4a57bf2c874cafba00c521913 +size 518696 diff --git a/tests/Fonts/BNazanin.ttf b/tests/Fonts/BNazanin.ttf new file mode 100644 index 000000000..060b8b1f1 --- /dev/null +++ b/tests/Fonts/BNazanin.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85e99f938567b29918530044b0111799ff6a9ba4376ca1adba495a5af5a91c46 +size 57824 diff --git a/tests/Fonts/Carter_One/CarterOne.ttf b/tests/Fonts/Carter_One/CarterOne.ttf new file mode 100644 index 000000000..b20cdddd7 --- /dev/null +++ b/tests/Fonts/Carter_One/CarterOne.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9267b32e571924b5977a3bfb068726603a1eecf2af8dadbc4262e943b53959c8 +size 66532 diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Carter_One/OFL.txt b/tests/Fonts/Carter_One/OFL.txt similarity index 100% rename from tests/SixLabors.Fonts.Tests/Fonts/Carter_One/OFL.txt rename to tests/Fonts/Carter_One/OFL.txt diff --git a/tests/Fonts/CharisSIL-Regular.ttf b/tests/Fonts/CharisSIL-Regular.ttf new file mode 100644 index 000000000..ee5983ccd --- /dev/null +++ b/tests/Fonts/CharisSIL-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5082098fdf2abe90e80253d649eb2b52aa84c1849f8c59db23abf2121cfa784e +size 822204 diff --git a/tests/Fonts/Cousine-Regular.ttf b/tests/Fonts/Cousine-Regular.ttf new file mode 100644 index 000000000..38aec4dcc --- /dev/null +++ b/tests/Fonts/Cousine-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69e1ea59eb770014204e5174f805750f9a793db4a2531e6516b30b7460d470b3 +size 308360 diff --git a/tests/Fonts/DejaVuSans.ttf b/tests/Fonts/DejaVuSans.ttf new file mode 100644 index 000000000..356575d14 --- /dev/null +++ b/tests/Fonts/DejaVuSans.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7da195a74c55bef988d0d48f9508bd5d849425c1770dba5d7bfc6ce9ed848954 +size 757076 diff --git a/tests/Fonts/Dubai-Regular.ttf b/tests/Fonts/Dubai-Regular.ttf new file mode 100644 index 000000000..97010e6eb --- /dev/null +++ b/tests/Fonts/Dubai-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a0be62452c4a73b8f86f3b6c1b0915074c47fa40bb658255b3d0b1cdf6d2f2f +size 181484 diff --git a/tests/Fonts/EBGaramond-Regular.ttf b/tests/Fonts/EBGaramond-Regular.ttf new file mode 100644 index 000000000..e207fea6b --- /dev/null +++ b/tests/Fonts/EBGaramond-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:799397b7b8c290e43bfe6abfc43f4e7162a8070b6e0417703483c3b35588dead +size 560568 diff --git a/tests/Fonts/FDArrayTest257.otf b/tests/Fonts/FDArrayTest257.otf new file mode 100644 index 000000000..2cc3feabc --- /dev/null +++ b/tests/Fonts/FDArrayTest257.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:211f9ecb8b8064931f860e84bfe6e746e926273ef924990887ff2df13e6fede7 +size 145212 diff --git a/tests/Fonts/Font-Version1.ttf b/tests/Fonts/Font-Version1.ttf new file mode 100644 index 000000000..ee4f65fbc --- /dev/null +++ b/tests/Fonts/Font-Version1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:625aef564d5b7895718bbd4c138a7a24dd2b2cfdc8d0f46e00aa7c84550a0d40 +size 62348 diff --git a/tests/Fonts/FormalScript.ttf b/tests/Fonts/FormalScript.ttf new file mode 100644 index 000000000..5fc7c9bb6 --- /dev/null +++ b/tests/Fonts/FormalScript.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b956ab8667f3ca92044f32f7bad8ec5b1489457c2438ca12da7848f13b21954 +size 30136 diff --git a/tests/Fonts/GposLookupType1Format1.ttf b/tests/Fonts/GposLookupType1Format1.ttf new file mode 100644 index 000000000..95cf2fa4f --- /dev/null +++ b/tests/Fonts/GposLookupType1Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b291d9846aaef39a681a1d56b041dd9fa6ff10f86a20641c67709a16b4dfe78 +size 37764 diff --git a/tests/Fonts/GposLookupType1Format2.ttf b/tests/Fonts/GposLookupType1Format2.ttf new file mode 100644 index 000000000..9579df5c6 --- /dev/null +++ b/tests/Fonts/GposLookupType1Format2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f90b27c8a7658e51e8c0a691bd5ba1b3458cbba5e2ef591534a8d4b4eec2788 +size 37732 diff --git a/tests/Fonts/GposLookupType2Format1.ttf b/tests/Fonts/GposLookupType2Format1.ttf new file mode 100644 index 000000000..720e7092c --- /dev/null +++ b/tests/Fonts/GposLookupType2Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb829c4dfe2188640fc38f31928e7471ebc1a2dc68778baa0221f92c267c76a4 +size 37744 diff --git a/tests/Fonts/GposLookupType3Format1.ttf b/tests/Fonts/GposLookupType3Format1.ttf new file mode 100644 index 000000000..1307739cc --- /dev/null +++ b/tests/Fonts/GposLookupType3Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:990375af4b308a6b6cfaf7a890b681b0802091a1f79d43030522ac79fb88137c +size 37744 diff --git a/tests/Fonts/GposLookupType4Format1.ttf b/tests/Fonts/GposLookupType4Format1.ttf new file mode 100644 index 000000000..85df3737f --- /dev/null +++ b/tests/Fonts/GposLookupType4Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a60b01ecd7a69a3570a72a5cd5789d7a8514adf35a309bf53b4aa328ff549d93 +size 37780 diff --git a/tests/Fonts/GposLookupType5Format1.ttf b/tests/Fonts/GposLookupType5Format1.ttf new file mode 100644 index 000000000..3ba3f508a --- /dev/null +++ b/tests/Fonts/GposLookupType5Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67929495025219cbdabdc941fab865cb9ba08a32cd0d21acfe250e5db5940e82 +size 37772 diff --git a/tests/Fonts/GposLookupType6Format1.ttf b/tests/Fonts/GposLookupType6Format1.ttf new file mode 100644 index 000000000..bc3e5f6f5 --- /dev/null +++ b/tests/Fonts/GposLookupType6Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15aacb5925deb94c12784e2475c3a7c61df37c3b5ee8eddf0baf5ba5899a23e0 +size 37708 diff --git a/tests/Fonts/GposLookupType7Format1.ttf b/tests/Fonts/GposLookupType7Format1.ttf new file mode 100644 index 000000000..a3c9271b4 --- /dev/null +++ b/tests/Fonts/GposLookupType7Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bc7f3faf7880c529d7c28084d5bbd51bea67d191dc725aaf68688fcc87faf52 +size 37956 diff --git a/tests/Fonts/GposLookupType7Format2.ttf b/tests/Fonts/GposLookupType7Format2.ttf new file mode 100644 index 000000000..a0232d804 --- /dev/null +++ b/tests/Fonts/GposLookupType7Format2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c2c58df7eb7d36f3394894569658b88afb6729ca1253b6804eb769e0bca08a0 +size 37976 diff --git a/tests/Fonts/GposLookupType7Format3.ttf b/tests/Fonts/GposLookupType7Format3.ttf new file mode 100644 index 000000000..5b6c9a463 --- /dev/null +++ b/tests/Fonts/GposLookupType7Format3.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4e4d749a6a90d1c57eb7828d61fdc5d19827dc8641c51f9d82cd3be49cf4099 +size 37960 diff --git a/tests/Fonts/GposLookupType8Format1.ttf b/tests/Fonts/GposLookupType8Format1.ttf new file mode 100644 index 000000000..4e8803163 --- /dev/null +++ b/tests/Fonts/GposLookupType8Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddae3096d965915ba3bf0865b4a7b2ce17de227aeb4aad8b5dceee82c12d310b +size 37964 diff --git a/tests/Fonts/GposLookupType8Format2.ttf b/tests/Fonts/GposLookupType8Format2.ttf new file mode 100644 index 000000000..334fd51b2 --- /dev/null +++ b/tests/Fonts/GposLookupType8Format2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f749ddcef084f9afea68c7396fcf98fd6679911731a1657dedc3f26fd3d6228 +size 38044 diff --git a/tests/Fonts/GposLookupType8Format3.ttf b/tests/Fonts/GposLookupType8Format3.ttf new file mode 100644 index 000000000..63ba275b6 --- /dev/null +++ b/tests/Fonts/GposLookupType8Format3.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31ced8f766e837b7e961666eba1b19eb784a20c57c021e2b6e65b588a29449a8 +size 37976 diff --git a/tests/Fonts/GposTestFont.ttf b/tests/Fonts/GposTestFont.ttf new file mode 100644 index 000000000..479bf1790 --- /dev/null +++ b/tests/Fonts/GposTestFont.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22eb234189b9a384c9d866e060f6d4a70e5d0a211d98f95a3629a412a058815b +size 37812 diff --git a/tests/Fonts/GsubLookupType5Format1.ttf b/tests/Fonts/GsubLookupType5Format1.ttf new file mode 100644 index 000000000..0b31265d3 --- /dev/null +++ b/tests/Fonts/GsubLookupType5Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe966a19bf1294ff72f6116ad0f9e7922716039b24eadc3fef60c632ff13de05 +size 3548 diff --git a/tests/Fonts/GsubLookupType5Format2.ttf b/tests/Fonts/GsubLookupType5Format2.ttf new file mode 100644 index 000000000..d7250fb17 --- /dev/null +++ b/tests/Fonts/GsubLookupType5Format2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17a32541f2228badfc9011cd82202c218c8db37de2fddeab90fe0983201bf23a +size 3568 diff --git a/tests/Fonts/GsubLookupType5Format3.ttf b/tests/Fonts/GsubLookupType5Format3.ttf new file mode 100644 index 000000000..a48f9a99a --- /dev/null +++ b/tests/Fonts/GsubLookupType5Format3.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df67682c0654bd0f0e4721630dfc9c6c5e195290fb58178f76dc2a892a333985 +size 38040 diff --git a/tests/Fonts/GsubLookupType6Format1.ttf b/tests/Fonts/GsubLookupType6Format1.ttf new file mode 100644 index 000000000..9c5600c08 --- /dev/null +++ b/tests/Fonts/GsubLookupType6Format1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2fe433c571a2e46edb1eb965aa54f060a4089d022dac13094f94a9211d424df +size 38008 diff --git a/tests/Fonts/GsubLookupType6Format2.ttf b/tests/Fonts/GsubLookupType6Format2.ttf new file mode 100644 index 000000000..7620bcbb0 --- /dev/null +++ b/tests/Fonts/GsubLookupType6Format2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf2954884dbe4fdec7fb1cff9769fac82d2a5b84cec7011059909d61771010dc +size 38204 diff --git a/tests/Fonts/GsubTestFont1.ttf b/tests/Fonts/GsubTestFont1.ttf new file mode 100644 index 000000000..01a488ca3 --- /dev/null +++ b/tests/Fonts/GsubTestFont1.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3398aa6d55fa5b0b992f6fb0c3a2b185cb31d55529e1c3eef0badc1cafee839 +size 37824 diff --git a/tests/Fonts/GsubTestFont2.ttf b/tests/Fonts/GsubTestFont2.ttf new file mode 100644 index 000000000..c4db5fe47 --- /dev/null +++ b/tests/Fonts/GsubTestFont2.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2cad6a5300625c58f6e9b175f22ad75409108a41bd9e776087ca1724f9e346d +size 33472 diff --git a/tests/Fonts/Helvetica.ttc b/tests/Fonts/Helvetica.ttc new file mode 100644 index 000000000..903722711 --- /dev/null +++ b/tests/Fonts/Helvetica.ttc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4cb0b7e8b3e53b29d356bfae0663075fdd20e45ad94b56e1b77cca117e415e0 +size 2356684 diff --git a/tests/Fonts/Hind-Regular.ttf b/tests/Fonts/Hind-Regular.ttf new file mode 100644 index 000000000..01fbcbc37 --- /dev/null +++ b/tests/Fonts/Hind-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01de158022f53077b52303e46de3b0ab5fb245222a7ffe25a2a57fdd9e969162 +size 299532 diff --git a/tests/Fonts/Inconsolata-Regular.ttf b/tests/Fonts/Inconsolata-Regular.ttf new file mode 100644 index 000000000..ccfd6e8d4 --- /dev/null +++ b/tests/Fonts/Inconsolata-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23ded25b447074d00659392bf9b1123d89df55cb07b0ad9bfef3366d199b5fcb +size 347180 diff --git a/tests/Fonts/Issues/GPosTable.GetFeatureLookups.ttf b/tests/Fonts/Issues/GPosTable.GetFeatureLookups.ttf new file mode 100644 index 000000000..9c1c2c617 --- /dev/null +++ b/tests/Fonts/Issues/GPosTable.GetFeatureLookups.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29a7aed2418be4af5aa124d037f22147eb1c90fa1a10882e4721152c75462344 +size 10947 diff --git a/tests/Fonts/Issues/GSubTable.GetFeatureLookups.ttf b/tests/Fonts/Issues/GSubTable.GetFeatureLookups.ttf new file mode 100644 index 000000000..2d8d00020 --- /dev/null +++ b/tests/Fonts/Issues/GSubTable.GetFeatureLookups.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d02167a1f122c3cda6de7a89d4c07de379d36964a8b741d0fff3d4852da33c1b +size 10932 diff --git a/tests/Fonts/Issues/GlyphTable.GetGlyph.ttf b/tests/Fonts/Issues/GlyphTable.GetGlyph.ttf new file mode 100644 index 000000000..829194164 --- /dev/null +++ b/tests/Fonts/Issues/GlyphTable.GetGlyph.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce1dd6952a5d8d9d5ff2d8cf7a968e076649fe53489cbdfd32673deff5022759 +size 10932 diff --git a/tests/Fonts/Issues/HorizontalMetricsTable.GetAdvancedWidth.ttf b/tests/Fonts/Issues/HorizontalMetricsTable.GetAdvancedWidth.ttf new file mode 100644 index 000000000..55bb20992 --- /dev/null +++ b/tests/Fonts/Issues/HorizontalMetricsTable.GetAdvancedWidth.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca809a5a5f098c021adf0e1b875aea3913be62a82a1e51cdd03784e93673edb9 +size 10932 diff --git a/tests/Fonts/Issues/Issue96.ttf b/tests/Fonts/Issues/Issue96.ttf new file mode 100644 index 000000000..1755fea2b --- /dev/null +++ b/tests/Fonts/Issues/Issue96.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24a092f80c604bd37fc1766a40d52f19de3b4245b2e1001bedb8cbcdbd75108f +size 2308 diff --git a/tests/Fonts/Issues/Issue97.ttf b/tests/Fonts/Issues/Issue97.ttf new file mode 100644 index 000000000..180fd5748 --- /dev/null +++ b/tests/Fonts/Issues/Issue97.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5770acbb4f103c0a94e10cfabdd28db05478683af2354c96ac4bf33525aa367c +size 2308 diff --git a/tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf b/tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf new file mode 100644 index 000000000..3bf762a40 --- /dev/null +++ b/tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc3e537c21494e67748d7423630ccacb82b9ef8e0636e841aa5166fdcb4a9168 +size 10932 diff --git a/tests/Fonts/Issues/StyleScript.ttf b/tests/Fonts/Issues/StyleScript.ttf new file mode 100644 index 000000000..26186337b --- /dev/null +++ b/tests/Fonts/Issues/StyleScript.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12c979bc908a08ab00844632b02fd958cd513244de650b5243e7a2ee63629ec6 +size 330020 diff --git a/tests/Fonts/KellySlab-Regular.ttf b/tests/Fonts/KellySlab-Regular.ttf new file mode 100644 index 000000000..a6f10afb4 --- /dev/null +++ b/tests/Fonts/KellySlab-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5c26ac241be3ebacf5e96b0297c21c00d6e028fa1a760f51e17c8d5f67fee39 +size 75956 diff --git a/tests/Fonts/Mada-VF.ttf b/tests/Fonts/Mada-VF.ttf new file mode 100644 index 000000000..45e37d5de --- /dev/null +++ b/tests/Fonts/Mada-VF.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8eb0a5069980354c3ce35e49f70274dd0c46a4b8fa1e201ed3f19087cd9c607c +size 120384 diff --git a/tests/Fonts/NanumGothicCoding-Regular.ttf b/tests/Fonts/NanumGothicCoding-Regular.ttf new file mode 100644 index 000000000..d1ac5c8e8 --- /dev/null +++ b/tests/Fonts/NanumGothicCoding-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:787effd7efed2abca88ade231faa8191f4e9fcf85b1805a13ee1dc3724b72089 +size 2315924 diff --git a/tests/Fonts/NotoColorEmoji-Regular.ttf b/tests/Fonts/NotoColorEmoji-Regular.ttf new file mode 100644 index 000000000..2579d30f6 --- /dev/null +++ b/tests/Fonts/NotoColorEmoji-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69f216a4ec672bb910d652678301ffe3094c44e5d03276e794ef793d936a1f1d +size 25096376 diff --git a/tests/Fonts/NotoEmoji-VariableFont_wght.ttf b/tests/Fonts/NotoEmoji-VariableFont_wght.ttf new file mode 100644 index 000000000..e3ba630f2 --- /dev/null +++ b/tests/Fonts/NotoEmoji-VariableFont_wght.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbd8394b0ee513b356b5a101fb0f64628ce9508294523e051a0efb1679bb34e3 +size 1989588 diff --git a/tests/Fonts/NotoNaskhArabic-Regular.ttf b/tests/Fonts/NotoNaskhArabic-Regular.ttf new file mode 100644 index 000000000..f47628a5f --- /dev/null +++ b/tests/Fonts/NotoNaskhArabic-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:358196ebc526c7c89b5e33c1217a0a9bf1337644a2f8aedbe23a04a80de23f16 +size 306952 diff --git a/tests/Fonts/NotoSans-Regular.ttf b/tests/Fonts/NotoSans-Regular.ttf new file mode 100644 index 000000000..348441d58 --- /dev/null +++ b/tests/Fonts/NotoSans-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe8c022f48d8dd29f17b744d16f9346f4357e16f7d4f7be58b000ae7c291b614 +size 629024 diff --git a/tests/Fonts/NotoSansArabic-Regular.ttf b/tests/Fonts/NotoSansArabic-Regular.ttf new file mode 100644 index 000000000..25b9d90a9 --- /dev/null +++ b/tests/Fonts/NotoSansArabic-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:252629ca0e87b6233851249b8cbf7b43445211a8caf199f1b306a19202251508 +size 194176 diff --git a/tests/Fonts/NotoSansBalinese-Regular.ttf b/tests/Fonts/NotoSansBalinese-Regular.ttf new file mode 100644 index 000000000..bbd6a0704 --- /dev/null +++ b/tests/Fonts/NotoSansBalinese-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e17cb03597adde450d41e823417cdfcf9049c77342348f5f2f4ccb1868ec3d1 +size 32304 diff --git a/tests/Fonts/NotoSansBengali-Regular.ttf b/tests/Fonts/NotoSansBengali-Regular.ttf new file mode 100644 index 000000000..8ebdb5646 --- /dev/null +++ b/tests/Fonts/NotoSansBengali-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:582998fe05dc49509fdf9a2383fb36d495a2eeb164a70dfb20b5d127e3e44f44 +size 102860 diff --git a/tests/Fonts/NotoSansDevanagari-Regular.ttf b/tests/Fonts/NotoSansDevanagari-Regular.ttf new file mode 100644 index 000000000..d6cb314fd --- /dev/null +++ b/tests/Fonts/NotoSansDevanagari-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b1dffa1fccb30dc45287111834a9db15c652b05d4d67201abe73e67717017590 +size 144816 diff --git a/tests/Fonts/NotoSansGujarati-Regular.ttf b/tests/Fonts/NotoSansGujarati-Regular.ttf new file mode 100644 index 000000000..2f8c572b9 --- /dev/null +++ b/tests/Fonts/NotoSansGujarati-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9114781246e64ec044a93f3fa84cb6cffd3911da801497d9ba61cc6eb508701 +size 128336 diff --git a/tests/Fonts/NotoSansGurmukhi-Regular.ttf b/tests/Fonts/NotoSansGurmukhi-Regular.ttf new file mode 100644 index 000000000..5fa69ab78 --- /dev/null +++ b/tests/Fonts/NotoSansGurmukhi-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51820e8c432fd05f1fe5615faa75a761520bef01152c884d6f6f9cfa3a9caa17 +size 37440 diff --git a/tests/Fonts/NotoSansHK-VariableFont_wght.ttf b/tests/Fonts/NotoSansHK-VariableFont_wght.ttf new file mode 100644 index 000000000..45c19d9a3 --- /dev/null +++ b/tests/Fonts/NotoSansHK-VariableFont_wght.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52fdbfb954285acc9fb797be57dd424114e0657b656bae4180ca022a1d12be8f +size 11907100 diff --git a/tests/Fonts/NotoSansHebrew-Regular.ttf b/tests/Fonts/NotoSansHebrew-Regular.ttf new file mode 100644 index 000000000..872aeb484 --- /dev/null +++ b/tests/Fonts/NotoSansHebrew-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0ee753f09733337b9236221018d4bf71fd6d06c87dd76bbc83120514bc55911 +size 48036 diff --git a/tests/Fonts/NotoSansJP-Regular.ttf b/tests/Fonts/NotoSansJP-Regular.ttf new file mode 100644 index 000000000..56b6e3543 --- /dev/null +++ b/tests/Fonts/NotoSansJP-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2f3b4d463500a2ddcd3849cded1fceeb9fd6d1c32e6cbecd568453ba50fc68f +size 9589900 diff --git a/tests/Fonts/NotoSansKR-Regular.otf b/tests/Fonts/NotoSansKR-Regular.otf new file mode 100644 index 000000000..be8befcb3 --- /dev/null +++ b/tests/Fonts/NotoSansKR-Regular.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29445948e432137e0de104dec389e956d72633aa0e4cb04ca572bb8e378e3d35 +size 4744692 diff --git a/tests/Fonts/NotoSansKannada-Regular.ttf b/tests/Fonts/NotoSansKannada-Regular.ttf new file mode 100644 index 000000000..afc0ca9bd --- /dev/null +++ b/tests/Fonts/NotoSansKannada-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:333ad7ed3c5feb093193322fa2557e7880c528959cc8925d4c72cfd405f8cbbc +size 83868 diff --git a/tests/Fonts/NotoSansKhmer-Regular.ttf b/tests/Fonts/NotoSansKhmer-Regular.ttf new file mode 100644 index 000000000..7362ba31c --- /dev/null +++ b/tests/Fonts/NotoSansKhmer-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9625c328c0d81f07f7546e764ac446ccc5a69f86a015dc2dfd4f0a004d4de20 +size 37144 diff --git a/tests/Fonts/NotoSansMalayalam-Regular.ttf b/tests/Fonts/NotoSansMalayalam-Regular.ttf new file mode 100644 index 000000000..cfa27a9dd --- /dev/null +++ b/tests/Fonts/NotoSansMalayalam-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8efbc6dcc49345df429cf25af568d9a27e0ea165a4d663a92f83506dffde0a35 +size 61200 diff --git a/tests/Fonts/NotoSansMyanmar-Regular.ttf b/tests/Fonts/NotoSansMyanmar-Regular.ttf new file mode 100644 index 000000000..70123d28f --- /dev/null +++ b/tests/Fonts/NotoSansMyanmar-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06b818a06a612231181e74b3b31e186a6aef65dca2d4d98857e1b8aaab38b7f6 +size 196004 diff --git a/tests/Fonts/NotoSansOgham-Regular.ttf b/tests/Fonts/NotoSansOgham-Regular.ttf new file mode 100644 index 000000000..05bfe521a --- /dev/null +++ b/tests/Fonts/NotoSansOgham-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa61febfa01f9fe08679f10d57c29ef92fd3ddb3d4f894dd6437c900ec496304 +size 47312 diff --git a/tests/Fonts/NotoSansOriya-Regular.ttf b/tests/Fonts/NotoSansOriya-Regular.ttf new file mode 100644 index 000000000..c12d3b398 --- /dev/null +++ b/tests/Fonts/NotoSansOriya-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3474944dd081f1aa0969a9af65a17e47dc606ad607f79914ca6bb089bd40422 +size 103684 diff --git a/tests/Fonts/NotoSansRunic-Regular.ttf b/tests/Fonts/NotoSansRunic-Regular.ttf new file mode 100644 index 000000000..d0bb0fd20 --- /dev/null +++ b/tests/Fonts/NotoSansRunic-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e36597f50710231e9a23e6ab8a50ff2257b17d47b852c614e0714b07119bf24 +size 55528 diff --git a/tests/Fonts/NotoSansSC-Regular.ttf b/tests/Fonts/NotoSansSC-Regular.ttf new file mode 100644 index 000000000..2dc375850 --- /dev/null +++ b/tests/Fonts/NotoSansSC-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc71173babc38dfd019912965f2b4b3421fb347ebd854e7b96f64ad63673924a +size 10560076 diff --git a/tests/Fonts/NotoSansSC-Thin-Bad.ttf b/tests/Fonts/NotoSansSC-Thin-Bad.ttf new file mode 100644 index 000000000..59fea539a --- /dev/null +++ b/tests/Fonts/NotoSansSC-Thin-Bad.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b054c3c388ed0cd0a147fd914dc0451f305968452b161706b308add66db17b1 +size 6432 diff --git a/tests/Fonts/NotoSansSC-Thin.ttf b/tests/Fonts/NotoSansSC-Thin.ttf new file mode 100644 index 000000000..18ab119c5 --- /dev/null +++ b/tests/Fonts/NotoSansSC-Thin.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82387b972ce226190d722d731b1ba5b103106f868b5b266be4f6857b212a856d +size 17804708 diff --git a/tests/Fonts/NotoSansSinhala-Regular.ttf b/tests/Fonts/NotoSansSinhala-Regular.ttf new file mode 100644 index 000000000..7d9c433d5 --- /dev/null +++ b/tests/Fonts/NotoSansSinhala-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33a77b6965e5245f1bab858ead09e4789aaa8daa918f9e26e924b016a3e1d7bd +size 243496 diff --git a/tests/Fonts/NotoSansTamil-Regular.ttf b/tests/Fonts/NotoSansTamil-Regular.ttf new file mode 100644 index 000000000..f85f788c2 --- /dev/null +++ b/tests/Fonts/NotoSansTamil-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85c2b36e95bdc0138eb58460551cefaa43315a9921fec67c89ebb670f57c0e52 +size 38180 diff --git a/tests/Fonts/NotoSansTelugu-Regular.ttf b/tests/Fonts/NotoSansTelugu-Regular.ttf new file mode 100644 index 000000000..9e74f754f --- /dev/null +++ b/tests/Fonts/NotoSansTelugu-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db35c2c4beab4231863ab2def70426817c67c39dad177513fcb8bb6447b9a397 +size 114240 diff --git a/tests/Fonts/NotoSerifKannada-Regular.ttf b/tests/Fonts/NotoSerifKannada-Regular.ttf new file mode 100644 index 000000000..ef64f5456 --- /dev/null +++ b/tests/Fonts/NotoSerifKannada-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d862205d2a997de5a0be3b3fdb8b5cc577ea5ac7e38f18cbf2a32b08122d597 +size 96936 diff --git a/tests/Fonts/NotoSerifLao-Regular.ttf b/tests/Fonts/NotoSerifLao-Regular.ttf new file mode 100644 index 000000000..638aab625 --- /dev/null +++ b/tests/Fonts/NotoSerifLao-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c87870f1267565a484355870ddbe7f48f0ff621a5dde0e51f4dad35e9868fd2 +size 63988 diff --git a/tests/Fonts/NotoSerifTibetan-Regular.ttf b/tests/Fonts/NotoSerifTibetan-Regular.ttf new file mode 100644 index 000000000..6dd523493 --- /dev/null +++ b/tests/Fonts/NotoSerifTibetan-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33bd11da711ad8fbf55e5df25f29e6ebdfce53424fb41d61c7c6b83c2ba948cf +size 736448 diff --git a/tests/Fonts/OpenSans-Regular.ttf b/tests/Fonts/OpenSans-Regular.ttf new file mode 100644 index 000000000..966f1d001 --- /dev/null +++ b/tests/Fonts/OpenSans-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4efcfa559f6e1b5ca6d704edcc128f3f26c6352a1677eab92910fb59638d6bde +size 122076 diff --git a/tests/Fonts/OpenSans-Regular.woff b/tests/Fonts/OpenSans-Regular.woff new file mode 100644 index 000000000..410d07588 --- /dev/null +++ b/tests/Fonts/OpenSans-Regular.woff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e86d8560ea889be6cd3798b20125fd2262df872a2c9e0ebe72991f6dca54282e +size 70736 diff --git a/tests/Fonts/OpenSans-Regular.woff2 b/tests/Fonts/OpenSans-Regular.woff2 new file mode 100644 index 000000000..f9f90e24d --- /dev/null +++ b/tests/Fonts/OpenSans-Regular.woff2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5f41dd4cd8281cf151091cef9e9add0cda9b6ccd1db2010f72c3f056f0775fb +size 56304 diff --git a/tests/Fonts/PMINGLIU.ttf b/tests/Fonts/PMINGLIU.ttf new file mode 100644 index 000000000..d55b0fdb2 --- /dev/null +++ b/tests/Fonts/PMINGLIU.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36354e475274cda9d840beaf2a05485254beef1f2ea046c1122769074d2812eb +size 8590676 diff --git a/tests/Fonts/PermanentMarker-Regular.ttf b/tests/Fonts/PermanentMarker-Regular.ttf new file mode 100644 index 000000000..9b6990d49 --- /dev/null +++ b/tests/Fonts/PermanentMarker-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a613a4e0a67ad9c48ee6bbf664a59f73450069ad27c08d4ed21e1b9b1893590 +size 73620 diff --git a/tests/Fonts/PermanentMarker-Regular.woff2 b/tests/Fonts/PermanentMarker-Regular.woff2 new file mode 100644 index 000000000..f9175e6e4 --- /dev/null +++ b/tests/Fonts/PermanentMarker-Regular.woff2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4884fec2c73aa52a2461073c1b87d1ceb80f400520391b43f97ca7d3c39eeb24 +size 29564 diff --git a/tests/Fonts/PlantinStdRegular.otf b/tests/Fonts/PlantinStdRegular.otf new file mode 100644 index 000000000..99136d7a4 --- /dev/null +++ b/tests/Fonts/PlantinStdRegular.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11dff9f1a44280a99962b9e0ffbefa62776e3db4b2e80cf1645dd5159e336721 +size 32248 diff --git a/tests/Fonts/Roboto-Regular.ttf b/tests/Fonts/Roboto-Regular.ttf new file mode 100644 index 000000000..5b51b1410 --- /dev/null +++ b/tests/Fonts/Roboto-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:319cff6e7a31f0f2a41c475dca42890aa5d19fe16017e2290f8c1d4e14f76481 +size 168260 diff --git a/tests/Fonts/RobotoFlex.ttf b/tests/Fonts/RobotoFlex.ttf new file mode 100644 index 000000000..4d89af9c7 --- /dev/null +++ b/tests/Fonts/RobotoFlex.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbdf64d63b504073dfa1ab6eb6dec1dba693422355b18d165bed3d369d9c8105 +size 1755856 diff --git a/tests/Fonts/Sample.ttc b/tests/Fonts/Sample.ttc new file mode 100644 index 000000000..453a46a0b --- /dev/null +++ b/tests/Fonts/Sample.ttc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1885c764af74cb7c656ebf3885e8342a12bc00597200d2e35e9b65d16554d94 +size 116612 diff --git a/tests/Fonts/Sarabun-Regular.ttf b/tests/Fonts/Sarabun-Regular.ttf new file mode 100644 index 000000000..56bce1055 --- /dev/null +++ b/tests/Fonts/Sarabun-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:226d4f368fbc0457990ddef2692679badfd2c1a4e89e5ac4d43c10ba7743b2f1 +size 90220 diff --git a/tests/Fonts/Segoeui.ttf b/tests/Fonts/Segoeui.ttf new file mode 100644 index 000000000..e10587634 --- /dev/null +++ b/tests/Fonts/Segoeui.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba32a222b23d727267cf1aba4e5296fe84ce99b9d910915103fc085d7931bc88 +size 955804 diff --git a/tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff b/tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff new file mode 100644 index 000000000..bf62e40af --- /dev/null +++ b/tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b199645c4a2130e50c82685d4d9c2ede105c0cba581865694d09b237fec5de15 +size 13696 diff --git a/tests/Fonts/SixLaborsSampleAB.ttf b/tests/Fonts/SixLaborsSampleAB.ttf new file mode 100644 index 000000000..2cde0e08b --- /dev/null +++ b/tests/Fonts/SixLaborsSampleAB.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d088c9f484fdc7408f1a2904329961fd8b5310c8a4ed21b671dd4d27a2c80b1 +size 2308 diff --git a/tests/Fonts/SixLaborsSampleAB.woff b/tests/Fonts/SixLaborsSampleAB.woff new file mode 100644 index 000000000..127cbac2c --- /dev/null +++ b/tests/Fonts/SixLaborsSampleAB.woff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d3e68120321c42fd9b6b6430a520f4ce8c89438af9eff1f5f56ff8f2ae76465e +size 1352 diff --git a/tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf b/tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf new file mode 100644 index 000000000..a66704453 --- /dev/null +++ b/tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:864e7464e256e288e79ce67aa1ec34940654ef14b14ca1a2487c035dac7313bb +size 168692 diff --git a/tests/Fonts/SourceSansPro-Regular.otf b/tests/Fonts/SourceSansPro-Regular.otf new file mode 100644 index 000000000..f874e46ae --- /dev/null +++ b/tests/Fonts/SourceSansPro-Regular.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9eefd0655161b5558b4caf1a0667b3931c55ef8e06b58b034e8955190261d99 +size 234960 diff --git a/tests/Fonts/Sumana-Regular.ttf b/tests/Fonts/Sumana-Regular.ttf new file mode 100644 index 000000000..5e86dcdd0 --- /dev/null +++ b/tests/Fonts/Sumana-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4500324cfcf3b7bcaab619928fdbde5f2503b7fa2de6fefba352afac272bbd3 +size 196012 diff --git a/tests/Fonts/Sunflower-Medium.ttf b/tests/Fonts/Sunflower-Medium.ttf new file mode 100644 index 000000000..849d1d7a1 --- /dev/null +++ b/tests/Fonts/Sunflower-Medium.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a844d3c0c01856acc50bc1145ca9a1017774e70483438773761e1556fd4bc53b +size 765812 diff --git a/tests/Fonts/THSarabun.ttf b/tests/Fonts/THSarabun.ttf new file mode 100644 index 000000000..56563c96a --- /dev/null +++ b/tests/Fonts/THSarabun.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51a071f55fe0b21d05334bea94d6e13393edd23e4bf775fd6b1f829bece967f4 +size 99980 diff --git a/tests/Fonts/TestGSUBThree.ttf b/tests/Fonts/TestGSUBThree.ttf new file mode 100644 index 000000000..a790ac775 --- /dev/null +++ b/tests/Fonts/TestGSUBThree.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ff51ee352be72acf16ebc95c50a870bc163f03343ffb9853f01aeea7136379f +size 1504 diff --git a/tests/Fonts/TestGVARFour.ttf b/tests/Fonts/TestGVARFour.ttf new file mode 100644 index 000000000..7639e1c23 --- /dev/null +++ b/tests/Fonts/TestGVARFour.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a749ef97d87e7bb6ab211e1e9ac262c8ab9bb0fb7e2cb7b2e9647dc78fe5676f +size 3204 diff --git a/tests/Fonts/TestGVAROne.ttf b/tests/Fonts/TestGVAROne.ttf new file mode 100644 index 000000000..21fda91ff --- /dev/null +++ b/tests/Fonts/TestGVAROne.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8997093856e17a432593cf401004e67795016030d24d4300b7f2d5aadfe8c6cd +size 14064 diff --git a/tests/Fonts/TestGVARThree.ttf b/tests/Fonts/TestGVARThree.ttf new file mode 100644 index 000000000..918d62678 --- /dev/null +++ b/tests/Fonts/TestGVARThree.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0729b31c39e6abf627957964f43c34554d2e087aad22dc0a424ffeb63df25204 +size 14076 diff --git a/tests/Fonts/TestGVARTwo.ttf b/tests/Fonts/TestGVARTwo.ttf new file mode 100644 index 000000000..7204b26c1 --- /dev/null +++ b/tests/Fonts/TestGVARTwo.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1aa1581af3e3d2ee0941cd44c158a53ae972a97f69d7e7d5c1110b51ecd6a4cf +size 15420 diff --git a/tests/Fonts/TestHVARTwo.ttf b/tests/Fonts/TestHVARTwo.ttf new file mode 100644 index 000000000..69e6b4101 --- /dev/null +++ b/tests/Fonts/TestHVARTwo.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dba292b3000989b54c6b61e2ace37addf32132a8dbd3e69215f02cdf09d90bed +size 4004 diff --git a/tests/Fonts/TestShapeEthi.ttf b/tests/Fonts/TestShapeEthi.ttf new file mode 100644 index 000000000..61f95ace0 --- /dev/null +++ b/tests/Fonts/TestShapeEthi.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af27baefc64f21d73a036bb509c0f143fc3658e5f285f6a37c1ef655c8dbb8c8 +size 5292 diff --git a/tests/Fonts/TimesNewRoman.ttf b/tests/Fonts/TimesNewRoman.ttf new file mode 100644 index 000000000..e5fbe9057 --- /dev/null +++ b/tests/Fonts/TimesNewRoman.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cff2a03d8034801979dd6d16f09b9a825c3d710fcf068f2ebfbf0e1425c87cf +size 1195688 diff --git a/tests/Fonts/Twemoji Mozilla.ttf b/tests/Fonts/Twemoji Mozilla.ttf new file mode 100644 index 000000000..b65bfa7a8 --- /dev/null +++ b/tests/Fonts/Twemoji Mozilla.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e52ebdb734105d3d634936b5ee436b2b91bed9c0200f0e9c84c7d663224610c7 +size 1437964 diff --git a/tests/Fonts/VeryBerryProRegular.ttf b/tests/Fonts/VeryBerryProRegular.ttf new file mode 100644 index 000000000..2b2bf9bd4 --- /dev/null +++ b/tests/Fonts/VeryBerryProRegular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15793c3e5d364b67eccb6c0b7f8b38877374a8d44610e37570876e3e8eb2a3ca +size 418956 diff --git a/tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf b/tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf new file mode 100644 index 000000000..a3a22052d --- /dev/null +++ b/tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9c25065c82e97d8880fbf155ffa66152ed49280be2a2a372f85375d2fe72f07 +size 122976 diff --git a/tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf b/tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf new file mode 100644 index 000000000..8c4cbea69 --- /dev/null +++ b/tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ac3ed59ca69513874b764ff52edf945d521912a3c9fac1a3e2bbe966cc2112c +size 123056 diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Wendy_One/OFL.txt b/tests/Fonts/Wendy_One/OFL.txt similarity index 100% rename from tests/SixLabors.Fonts.Tests/Fonts/Wendy_One/OFL.txt rename to tests/Fonts/Wendy_One/OFL.txt diff --git a/tests/Fonts/Wendy_One/WendyOne-Regular.ttf b/tests/Fonts/Wendy_One/WendyOne-Regular.ttf new file mode 100644 index 000000000..ee1c1eb9b --- /dev/null +++ b/tests/Fonts/Wendy_One/WendyOne-Regular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e2da0e8bb0a593656d38fc8e265c5b09b2c45b294bd23f39f135c2e36c89daf +size 22772 diff --git a/tests/Fonts/arial.ttf b/tests/Fonts/arial.ttf new file mode 100644 index 000000000..7e1850218 --- /dev/null +++ b/tests/Fonts/arial.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d071ea275a34d2b0308a7bcb8284a5ea3f916e676ba148a4dad75c918d94860 +size 774236 diff --git a/tests/Fonts/consola.ttf b/tests/Fonts/consola.ttf new file mode 100644 index 000000000..a858e8825 --- /dev/null +++ b/tests/Fonts/consola.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6e6ce8119fdd47ec6a5449a08e2d2ad7f41ea03143aae193068ed9fa58eaebc +size 459180 diff --git a/tests/Fonts/courier-prime.woff2 b/tests/Fonts/courier-prime.woff2 new file mode 100644 index 000000000..f11bcf4ee --- /dev/null +++ b/tests/Fonts/courier-prime.woff2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb8761bf3adb57942e0f6bdea353ba81e8a57a44b2c8600cd50387fb3c8fa14a +size 18764 diff --git a/tests/Fonts/kaiu.ttf b/tests/Fonts/kaiu.ttf new file mode 100644 index 000000000..6f48a62dd --- /dev/null +++ b/tests/Fonts/kaiu.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd18bf7c4204f469ea37e03df19c7d398c29643648961918054d227ff8128fd1 +size 5180940 diff --git a/tests/Fonts/me_quran_volt_newmet.ttf b/tests/Fonts/me_quran_volt_newmet.ttf new file mode 100644 index 000000000..c54022784 --- /dev/null +++ b/tests/Fonts/me_quran_volt_newmet.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83d56cab9933f9e3ac1361ac0e926324a1cc70f37c3bcc5b22f62f270160b4a0 +size 459976 diff --git a/tests/Fonts/mgopencanonicaregular.ttf b/tests/Fonts/mgopencanonicaregular.ttf new file mode 100644 index 000000000..55a4bd353 --- /dev/null +++ b/tests/Fonts/mgopencanonicaregular.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:731224f3cd7b4ed2f7a1932f4b0b2c1febc3a2c8c4d0490b3d0e0556b39acdd2 +size 281580 diff --git a/tests/Fonts/seguiemj-win11.ttf b/tests/Fonts/seguiemj-win11.ttf new file mode 100644 index 000000000..2c82d2a29 --- /dev/null +++ b/tests/Fonts/seguiemj-win11.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edd76b88c44432ba1818992259c31d45abd28fbcfbb3eeebad3f6af27636213c +size 2766328 diff --git a/tests/Fonts/tahoma.ttf b/tests/Fonts/tahoma.ttf new file mode 100644 index 000000000..006d35ee5 --- /dev/null +++ b/tests/Fonts/tahoma.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbccddcd68ffa5f9e4d2b9f8ca2507145e0c1f02f8f03298cb1f6281fe3ad12e +size 948860 diff --git a/tests/Fonts/whitney-book.ttf b/tests/Fonts/whitney-book.ttf new file mode 100644 index 000000000..2f1460b15 --- /dev/null +++ b/tests/Fonts/whitney-book.ttf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1165801907ae5a6fa0e9d42ae1fe4366f530f54982731cbfa42973130a04368 +size 61140 diff --git a/tests/Images/ReferenceOutput/TextAlignmentSample_RendersReferenceImage-.png b/tests/Images/ReferenceOutput/TextAlignmentSample_RendersReferenceImage-.png new file mode 100644 index 000000000..908c537bc --- /dev/null +++ b/tests/Images/ReferenceOutput/TextAlignmentSample_RendersReferenceImage-.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb8e2e0c705c7ce1a097bff3367f9402cd5e30ed27e9caf15fa4d769851cd7ad +size 79382 diff --git a/tests/Images/ReferenceOutput/TextAlignmentWrapped_RendersReferenceImage-.png b/tests/Images/ReferenceOutput/TextAlignmentWrapped_RendersReferenceImage-.png new file mode 100644 index 000000000..3e5c2ab28 --- /dev/null +++ b/tests/Images/ReferenceOutput/TextAlignmentWrapped_RendersReferenceImage-.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a48dd79fd46fc05cf7e31f90e12e40334fc2f251acf83480a89fc9e7132f8ff +size 148916 diff --git a/tests/SixLabors.Fonts.Tests/Accents.cs b/tests/SixLabors.Fonts.Tests/Accents.cs index da9a2eedb..3395abf4d 100644 --- a/tests/SixLabors.Fonts.Tests/Accents.cs +++ b/tests/SixLabors.Fonts.Tests/Accents.cs @@ -16,10 +16,9 @@ public class Accents [InlineData('õ')] public void MeasuringAccentedCharacterDoesNotThrow(char c) { - FontFamily sans = new FontCollection().Add(TestFonts.OpenSansFile); - var font = new Font(sans, 1f, FontStyle.Regular); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 1f); - FontRectangle size = TextMeasurer.MeasureSize(c.ToString(), new TextOptions(font)); + _ = TextMeasurer.MeasureSize(c.ToString(), new TextOptions(font)); } [Theory] @@ -33,9 +32,8 @@ public void MeasuringAccentedCharacterDoesNotThrow(char c) [InlineData('õ')] public void MeasuringWordWithAccentedCharacterDoesNotThrow(char c) { - FontFamily sans = new FontCollection().Add(TestFonts.OpenSansFile); - var font = new Font(sans, 1f, FontStyle.Regular); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 1f); - FontRectangle size = TextMeasurer.MeasureSize($"abc{c}def", new TextOptions(font)); + _ = TextMeasurer.MeasureSize($"abc{c}def", new TextOptions(font)); } } diff --git a/tests/SixLabors.Fonts.Tests/BigEndianBinaryWriter.cs b/tests/SixLabors.Fonts.Tests/BigEndianBinaryWriter.cs index f7898b394..adcdb99c5 100644 --- a/tests/SixLabors.Fonts.Tests/BigEndianBinaryWriter.cs +++ b/tests/SixLabors.Fonts.Tests/BigEndianBinaryWriter.cs @@ -62,7 +62,7 @@ public void Flush() this.BaseStream.Flush(); } - public BigEndianBinaryReader GetReader() => new BigEndianBinaryReader(this.GetStream(), true); + public BigEndianBinaryReader GetReader() => new(this.GetStream(), true); public MemoryStream GetStream() { @@ -70,7 +70,7 @@ public MemoryStream GetStream() long p = this.BaseStream.Position; this.BaseStream.Position = 0; - var ms = new MemoryStream(); + MemoryStream ms = new(); this.BaseStream.CopyTo(ms); ms.Position = 0; this.BaseStream.Position = 0; diff --git a/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs b/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs index 6dd5d717a..712e0ba6a 100644 --- a/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs +++ b/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs @@ -9,7 +9,7 @@ namespace SixLabors.Fonts.Tests; // We should refactor tests to remove it where possible. public class ColorGlyphRenderer : GlyphRenderer { - public List Colors { get; } = new List(); + public List Colors { get; } = []; public override void BeginLayer(Paint paint, FillRule fillRule, ClipQuad? clipBounds) { diff --git a/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs b/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs index 81a4554e6..ca98a0aa1 100644 --- a/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs +++ b/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs @@ -15,8 +15,8 @@ public class CompactFontFormatTests public void FDSelectFormat0_Works(string testStr, int expectedGlyphIndex) { // arrange - Font font = new FontCollection().Add(TestFonts.FDArrayTest257File).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.FDArrayTest257File, 8); + ColorGlyphRenderer renderer = new(); // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); diff --git a/tests/SixLabors.Fonts.Tests/FakeFont.cs b/tests/SixLabors.Fonts.Tests/FakeFont.cs index 3bf449403..4d77698b2 100644 --- a/tests/SixLabors.Fonts.Tests/FakeFont.cs +++ b/tests/SixLabors.Fonts.Tests/FakeFont.cs @@ -31,7 +31,7 @@ public static Font CreateFont(string text, string name = "name") internal static Font CreateFontWithInstance(string text, string name, out FakeFontInstance instance) { - var fc = (IFontMetricsCollection)new FontCollection(); + IFontMetricsCollection fc = (IFontMetricsCollection)new FontCollection(); instance = FakeFontInstance.CreateFontWithVaryingVerticalFontMetrics(text, name); Font d = fc.AddMetrics(instance, CultureInfo.InvariantCulture).CreateFont(12); return new Font(d, 1F); diff --git a/tests/SixLabors.Fonts.Tests/Fakes/FakeFontInstance.cs b/tests/SixLabors.Fonts.Tests/Fakes/FakeFontInstance.cs index 4b54b8615..f7b3756dc 100644 --- a/tests/SixLabors.Fonts.Tests/Fakes/FakeFontInstance.cs +++ b/tests/SixLabors.Fonts.Tests/Fakes/FakeFontInstance.cs @@ -33,9 +33,9 @@ public static FakeFontInstance CreateFontWithVaryingVerticalFontMetrics(string t NameTable name = GenerateNameTable(fontName); MaximumProfileTable maxp = GenerateMaxpTable(glyphs); CMapTable cmap = GenerateCMapTable(glyphs); - var glyf = new FakeGlyphTable(glyphs); + FakeGlyphTable glyf = new(glyphs); PostTable post = GeneratePostTable(); - var kern = new KerningTable(Array.Empty()); + KerningTable kern = new(Array.Empty()); OS2Table os2 = GenerateOS2TableWithVaryingVerticalFontMetrics(); HorizontalMetricsTable htmx = GenerateHorizontalMetricsTable(glyphs); VerticalHeadTable vhea = GenerateVerticalHeadTable(); @@ -60,9 +60,9 @@ private static TrueTypeFontTables CreateTrueTypeFontTables(string text, string f NameTable name = GenerateNameTable(fontName); MaximumProfileTable maxp = GenerateMaxpTable(glyphs); CMapTable cmap = GenerateCMapTable(glyphs); - var glyf = new FakeGlyphTable(glyphs); + FakeGlyphTable glyf = new(glyphs); PostTable post = GeneratePostTable(); - var kern = new KerningTable(Array.Empty()); + KerningTable kern = new(Array.Empty()); OS2Table os2 = GenerateOS2Table(); HorizontalMetricsTable htmx = GenerateHorizontalMetricsTable(glyphs); VerticalHeadTable vhea = GenerateVerticalHeadTable(); @@ -79,29 +79,23 @@ private static TrueTypeFontTables CreateTrueTypeFontTables(string text, string f private static List GetGlyphs(string text) { - HashSet codePoints = new() - { + HashSet codePoints = + [ // Regardless of the encoding scheme, character codes that do // not correspond to any glyph in the font should be mapped to glyph index 0. // The glyph at this location must be a special glyph representing a missing character, commonly known as .notdef. - default // Add default at position 0; - }; - - foreach (CodePoint codePoint in text.AsSpan().EnumerateCodePoints()) - { - codePoints.Add(codePoint); - } + default, .. text.AsSpan().EnumerateCodePoints() // Add default at position 0; + ]; - return codePoints.Select((x, i) => new FakeGlyphSource(x, (ushort)i)).ToList(); + return [.. codePoints.Select((x, i) => new FakeGlyphSource(x, (ushort)i))]; } private static NameTable GenerateNameTable(string name) => new( - new[] - { + [ new NameRecord(WellKnownIds.PlatformIDs.Windows, 0, WellKnownIds.KnownNameIds.FullFontName, name), new NameRecord(WellKnownIds.PlatformIDs.Windows, 0, WellKnownIds.KnownNameIds.FontFamilyName, name) - }, + ], Array.Empty()); private static CMapTable GenerateCMapTable(List glyphs) @@ -123,10 +117,10 @@ private static OS2Table GenerateOS2TableWithVaryingVerticalFontMetrics() => new(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, Array.Empty(), 1, 1, 1, 1, string.Empty, OS2Table.FontStyleSelection.USE_TYPO_METRICS, 1, 1, 35, 8, 12, 33, 11); private static HorizontalMetricsTable GenerateHorizontalMetricsTable(List glyphs) - => new(glyphs.Select(_ => (ushort)30).ToArray(), glyphs.Select(_ => (short)10).ToArray()); + => new([.. glyphs.Select(_ => (ushort)30)], [.. glyphs.Select(_ => (short)10)]); private static VerticalMetricsTable GenerateVerticalMetricsTable(List glyphs) - => new(glyphs.Select(_ => (ushort)30).ToArray(), glyphs.Select(_ => (short)10).ToArray()); + => new([.. glyphs.Select(_ => (ushort)30)], [.. glyphs.Select(_ => (short)10)]); private static IndexLocationTable GenerateIndexLocationTable(List glyphs) => new(new uint[glyphs.Count + 1]); diff --git a/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs b/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs index b8342e185..2d231994e 100644 --- a/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs @@ -10,9 +10,7 @@ public class FontCodePointsTests [Fact] public void TtfTest() { - FontCollection collection = new FontCollection(); - FontFamily family = collection.Add(TestFonts.SimpleFontFile); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); IReadOnlyList codePoints = font.FontMetrics.GetAvailableCodePoints(); IEnumerable codePointValues = codePoints.Select(x => x.Value); @@ -30,7 +28,7 @@ public void TtfTest() Assert.Contains(0x0062, codePointValues); Assert.Contains(0xFFFF, codePointValues); - HashSet glyphIds = new(); + HashSet glyphIds = []; foreach (CodePoint codePoint in codePoints) { Assert.True(font.TryGetGlyphs(codePoint, out Glyph? glyph)); @@ -44,9 +42,7 @@ public void TtfTest() [Fact] public void WoffTest() { - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.SimpleFontFileWoff); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFileWoff, 12); IReadOnlyList codePoints = font.FontMetrics.GetAvailableCodePoints(); IEnumerable codePointValues = codePoints.Select(x => x.Value); @@ -64,7 +60,7 @@ public void WoffTest() Assert.Contains(0x0062, codePointValues); Assert.Contains(0xFFFF, codePointValues); - HashSet glyphIds = new(); + HashSet glyphIds = []; foreach (CodePoint codePoint in codePoints) { Assert.True(font.TryGetGlyphs(codePoint, out Glyph? glyph)); diff --git a/tests/SixLabors.Fonts.Tests/FontCollectionTests.cs b/tests/SixLabors.Fonts.Tests/FontCollectionTests.cs index 3ccefdb91..1b4d9d0da 100644 --- a/tests/SixLabors.Fonts.Tests/FontCollectionTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontCollectionTests.cs @@ -10,7 +10,7 @@ public class FontCollectionTests [Fact] public void AddViaPathReturnsDescription() { - var sut = new FontCollection(); + FontCollection sut = new(); sut.Add(TestFonts.CarterOneFile, out FontDescription description); Assert.NotNull(description); @@ -22,7 +22,7 @@ public void AddViaPathReturnsDescription() [Fact] public void AddViaPathAddFontFileInstances() { - var sut = new FontCollection(); + FontCollection sut = new(); FontFamily family = sut.Add(TestFonts.CarterOneFile, out FontDescription descriptions); IEnumerable allInstances = ((IReadOnlyFontMetricsCollection)sut).GetAllMetrics(family.Name, CultureInfo.InvariantCulture); @@ -36,7 +36,7 @@ public void AddViaPathAddFontFileInstances() [Fact] public void AddViaStreamReturnsDescription() { - var sut = new FontCollection(); + FontCollection sut = new(); using Stream s = TestFonts.CarterOneFileData(); FontFamily family = sut.Add(s, out FontDescription description); Assert.NotNull(description); @@ -59,7 +59,7 @@ public void NotFoundThrowsCorrectException() [Fact] public void CanAddSystemFonts() { - var collection = new FontCollection(); + FontCollection collection = new(); Assert.False(collection.Families.Any()); @@ -72,7 +72,7 @@ public void CanAddSystemFonts() [Fact] public void CanAddSystemFontsWithFilter() { - var collection = new FontCollection(); + FontCollection collection = new(); collection.AddSystemFonts(_ => false); Assert.False(collection.Families.Any()); diff --git a/tests/SixLabors.Fonts.Tests/FontDescriptionTests.cs b/tests/SixLabors.Fonts.Tests/FontDescriptionTests.cs index e0e1d740b..72706ebf2 100644 --- a/tests/SixLabors.Fonts.Tests/FontDescriptionTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontDescriptionTests.cs @@ -11,7 +11,7 @@ public class FontDescriptionTests [Fact] public void LoadFontDescription() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(1, 0, 0, 0); writer.WriteTableHeader("name", 0, 28, 999); writer.WriteNameTable( @@ -22,7 +22,7 @@ public void LoadFontDescription() { KnownNameIds.FontFamilyName, "fam" } }); - var description = FontDescription.LoadDescription(writer.GetStream()); + FontDescription description = FontDescription.LoadDescription(writer.GetStream()); Assert.Equal("name", description.FontNameInvariantCulture); Assert.Equal("sub", description.FontSubFamilyNameInvariantCulture); Assert.Equal("fam", description.FontFamilyInvariantCulture); @@ -31,11 +31,11 @@ public void LoadFontDescription() [Fact] public void LoadFontDescription_CultureNamePriority_FirstWindows() { - var usCulture = new CultureInfo(0x0409); - var c1 = new CultureInfo(1034); // spanish - international - var c2 = new CultureInfo(3082); // spanish - traditional + CultureInfo usCulture = new(0x0409); + CultureInfo c1 = new(1034); // spanish - international + CultureInfo c2 = new(3082); // spanish - traditional - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(1, 0, 0, 0); writer.WriteTableHeader("name", 0, 28, 999); writer.WriteNameTable( @@ -46,7 +46,7 @@ public void LoadFontDescription_CultureNamePriority_FirstWindows() (KnownNameIds.FontSubfamilyName, "sub_c2", c2), (KnownNameIds.FontFamilyName, "fam_c2", c2)); - var description = FontDescription.LoadDescription(writer.GetStream()); + FontDescription description = FontDescription.LoadDescription(writer.GetStream()); // unknown culture should prioritise US, but missing so will return first Assert.Equal("name_c1", description.FontNameInvariantCulture); @@ -57,11 +57,11 @@ public void LoadFontDescription_CultureNamePriority_FirstWindows() [Fact] public void LoadFontDescription_CultureNamePriority_US() { - var usCulture = new CultureInfo(0x0409); - var c1 = new CultureInfo(1034); // spanish - international - var c2 = new CultureInfo(3082); // spanish - traditional + CultureInfo usCulture = new(0x0409); + CultureInfo c1 = new(1034); // spanish - international + CultureInfo c2 = new(3082); // spanish - traditional - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(1, 0, 0, 0); writer.WriteTableHeader("name", 0, 28, 999); writer.WriteNameTable( @@ -75,7 +75,7 @@ public void LoadFontDescription_CultureNamePriority_US() (KnownNameIds.FontSubfamilyName, "sub_us", usCulture), (KnownNameIds.FontFamilyName, "fam_us", usCulture)); - var description = FontDescription.LoadDescription(writer.GetStream()); + FontDescription description = FontDescription.LoadDescription(writer.GetStream()); // unknown culture should prioritise US, but missing so will return first Assert.Equal("name_us", description.FontNameInvariantCulture); @@ -86,11 +86,11 @@ public void LoadFontDescription_CultureNamePriority_US() [Fact] public void LoadFontDescription_CultureNamePriority_ExactMatch() { - var usCulture = new CultureInfo(0x0409); - var c1 = new CultureInfo(1034); // spanish - international - var c2 = new CultureInfo(3082); // spanish - traditional + CultureInfo usCulture = new(0x0409); + CultureInfo c1 = new(1034); // spanish - international + CultureInfo c2 = new(3082); // spanish - traditional - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(1, 0, 0, 0); writer.WriteTableHeader("name", 0, 28, 999); writer.WriteNameTable( @@ -104,7 +104,7 @@ public void LoadFontDescription_CultureNamePriority_ExactMatch() (KnownNameIds.FontSubfamilyName, "sub_us", usCulture), (KnownNameIds.FontFamilyName, "fam_us", usCulture)); - var description = FontDescription.LoadDescription(writer.GetStream()); + FontDescription description = FontDescription.LoadDescription(writer.GetStream()); // unknown culture should prioritise US, but missing so will return first Assert.Equal("name_c2", description.FontName(c2)); @@ -135,10 +135,10 @@ public void CanLoadFontCollectionDescriptionsFromPath() [Fact] public void LoadFontDescription_GetNameById() { - var c1 = new CultureInfo(1034); // spanish - international - var c2 = new CultureInfo(3082); // spanish - traditional + CultureInfo c1 = new(1034); // spanish - international + CultureInfo c2 = new(3082); // spanish - traditional - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(1, 0, 0, 0); writer.WriteTableHeader("name", 0, 28, 999); writer.WriteNameTable( @@ -149,7 +149,7 @@ public void LoadFontDescription_GetNameById() (KnownNameIds.FontSubfamilyName, "sub_c2", c2), (KnownNameIds.FontFamilyName, "fam_c2", c2)); - var description = FontDescription.LoadDescription(writer.GetStream()); + FontDescription description = FontDescription.LoadDescription(writer.GetStream()); Assert.Equal("name_c1", description.GetNameById(c1, KnownNameIds.FullFontName)); Assert.Equal("sub_c1", description.GetNameById(c1, KnownNameIds.FontSubfamilyName)); diff --git a/tests/SixLabors.Fonts.Tests/FontFamilyTests.cs b/tests/SixLabors.Fonts.Tests/FontFamilyTests.cs index ab2e96e0a..5f2e59bc4 100644 --- a/tests/SixLabors.Fonts.Tests/FontFamilyTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontFamilyTests.cs @@ -5,7 +5,7 @@ namespace SixLabors.Fonts.Tests; public class FontFamilyTests { - private readonly FontFamily[] families = SystemFonts.Families.ToArray(); + private readonly FontFamily[] families = [.. SystemFonts.Families]; [Fact] public void EqualNullTests() diff --git a/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs b/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs index f3823fc9b..9894c976f 100644 --- a/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs @@ -11,7 +11,7 @@ public class FontLoaderTests [Fact] public void Issue21_LoopDetectedLoadingGlyphs() { - Font font = new FontCollection().Add(TestFonts.CarterOneFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.CarterOneFile, 12); Assert.True(font.FontMetrics.TryGetGlyphMetrics( new CodePoint('\0'), @@ -43,7 +43,7 @@ public void LoadFontMetadataWoff() [Fact] public void LoadFont_WithTtfFormat() { - Font font = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 12); Assert.True(font.TryGetGlyphs(new CodePoint('A'), ColorFontSupport.None, out Glyph? glyph)); @@ -58,7 +58,7 @@ public void LoadFont_WithTtfFormat() [Fact] public void LoadFont_WithWoff1Format() { - Font font = new FontCollection().Add(TestFonts.OpenSansFileWoff1).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFileWoff1, 12); Assert.True(font.TryGetGlyphs(new CodePoint('A'), ColorFontSupport.None, out Glyph? glyph)); GlyphRenderer r = new(); @@ -90,7 +90,7 @@ public void LoadFontMetadata_WithWoff2Format() [Fact] public void LoadFont_WithWoff2Format() { - Font font = new FontCollection().Add(TestFonts.OpensSansWoff2Data()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFileWoff2, 12); Assert.True(font.TryGetGlyphs(new CodePoint('A'), ColorFontSupport.None, out Glyph? glyph)); GlyphRenderer r = new(); @@ -104,7 +104,7 @@ public void LoadFont_WithWoff2Format() [Fact] public void LoadFont() { - Font font = new FontCollection().Add(TestFonts.SimpleFontFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); Assert.Equal("SixLaborsSampleAB regular", font.FontMetrics.Description.FontNameInvariantCulture); Assert.Equal("Regular", font.FontMetrics.Description.FontSubFamilyNameInvariantCulture); @@ -120,7 +120,7 @@ public void LoadFont() [Fact] public void LoadFontWoff() { - Font font = new FontCollection().Add(TestFonts.SimpleFontFileWoffData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFileWoff, 12); Assert.Equal("SixLaborsSampleAB regular", font.FontMetrics.Description.FontNameInvariantCulture); Assert.Equal("Regular", font.FontMetrics.Description.FontSubFamilyNameInvariantCulture); @@ -138,7 +138,7 @@ public void LoadFontWithIncorrectClassDefinitionTableOffset() { // The following font contains a ClassDefinitionTable with an invalid offset. // See https://forum.stimulsoft.com/viewtopic.php?t=60972 - Font font = new FontCollection().Add(TestFonts.THSarabunFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.THSarabunFile, 12); FontRectangle advance = TextMeasurer.MeasureAdvance("เราใช้คุกกี้เพื่อพัฒนาประสิทธิภาพ และประสบการณ์ที่ดีในการใช้เว็บไซต์ของคุณ คุณสามารถศึกษารายละเอียดได้ที่", new(font)); diff --git a/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs b/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs index e73055a15..7d19a71da 100644 --- a/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs @@ -13,9 +13,7 @@ public void FontMetricsMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.OpenSansFile); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 12); Assert.Equal(2048, font.FontMetrics.UnitsPerEm); Assert.Equal(2189, font.FontMetrics.HorizontalMetrics.Ascender); @@ -52,9 +50,7 @@ public void FontMetricsVerticalFontMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.NotoSansSCThinBad); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.NotoSansSCThinBad, 12); Assert.Equal(1000, font.FontMetrics.UnitsPerEm); @@ -99,9 +95,7 @@ public void FontMetricsVerticalFontMatchesReferenceCFF() { // Compared to OpenTypeJS Font Inspector metrics // https://opentype.js.org/font-inspector.html - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.NotoSansKRRegular); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.NotoSansKRRegular, 12); Assert.Equal(1000, font.FontMetrics.UnitsPerEm); @@ -146,9 +140,7 @@ public void GlyphMetricsMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.OpenSansFile); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 12); CodePoint codePoint = new('A'); @@ -177,9 +169,7 @@ public void GlyphMetricsMatchesReference_WithWoff1format() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.OpenSansFileWoff1); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFileWoff1, 12); CodePoint codePoint = new('A'); @@ -208,9 +198,7 @@ public void GlyphMetricsMatchesReference_WithWoff2format() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.OpenSansFileWoff2); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.OpenSansFileWoff2, 12); CodePoint codePoint = new('A'); @@ -239,9 +227,7 @@ public void GlyphMetricsVerticalMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.NotoSansSCThinBad); - Font font = family.CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.NotoSansSCThinBad, 12); CodePoint codePoint = new('A'); diff --git a/tests/SixLabors.Fonts.Tests/FontReaderTests.cs b/tests/SixLabors.Fonts.Tests/FontReaderTests.cs index 2c0983279..a6ffeae6b 100644 --- a/tests/SixLabors.Fonts.Tests/FontReaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontReaderTests.cs @@ -12,32 +12,32 @@ public class FontReaderTests [Fact] public void ReadTrueTypeOutlineType() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(0, 0, 0, 0); - using var reader = new FontReader(writer.GetStream()); + using FontReader reader = new(writer.GetStream()); Assert.Equal(OutlineType.TrueType, reader.OutlineType); } [Fact] public void ReadCffOutlineType() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteCffFileHeader(0, 0, 0, 0); - using var reader = new FontReader(writer.GetStream()); + using FontReader reader = new(writer.GetStream()); Assert.Equal(OutlineType.CFF, reader.OutlineType); } [Fact] public void ReadTableHeaders() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(2, 0, 0, 0); writer.WriteTableHeader("name", 0, 10, 0); writer.WriteTableHeader("cmap", 0, 1, 0); - using var reader = new FontReader(writer.GetStream()); + using FontReader reader = new(writer.GetStream()); Assert.Equal(2, reader.Headers.Count); } @@ -45,7 +45,7 @@ public void ReadTableHeaders() [Fact] public void ReadCMapTable() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(new TableHeader("cmap", 0, 0, 20)); @@ -56,10 +56,10 @@ public void ReadCMapTable() 0, WellKnownIds.PlatformIDs.Macintosh, 1, - new byte[] { 2, 9 }) + [2, 9]) }); - using var reader = new FontReader(writer.GetStream()); + using FontReader reader = new(writer.GetStream()); CMapTable cmap = reader.GetTable(); Assert.NotNull(cmap); } @@ -67,8 +67,8 @@ public void ReadCMapTable() [Fact] public void ReadFont_WithWoffFormat_EqualsTtf() { - using var fontReaderTtf = new FontReader(TestFonts.OpenSansTtfData()); - using var fontReaderWoff = new FontReader(TestFonts.OpensSansWoff1Data()); + using FontReader fontReaderTtf = new(TestFonts.OpenSansTtfData()); + using FontReader fontReaderWoff = new(TestFonts.OpensSansWoff1Data()); Assert.Equal(fontReaderTtf.Headers.Count, fontReaderWoff.Headers.Count); foreach (string key in fontReaderTtf.Headers.Keys) @@ -80,9 +80,9 @@ public void ReadFont_WithWoffFormat_EqualsTtf() [Fact] public void GlyphsCount_WithWoffFormat_EqualsTtf() { - using var fontReaderWoff = new FontReader(TestFonts.OpensSansWoff1Data()); + using FontReader fontReaderWoff = new(TestFonts.OpensSansWoff1Data()); GlyphTable glyphsWoff = fontReaderWoff.GetTable(); - using var fontReaderTtf = new FontReader(TestFonts.OpenSansTtfData()); + using FontReader fontReaderTtf = new(TestFonts.OpenSansTtfData()); GlyphTable glyphsTtf = fontReaderTtf.GetTable(); Assert.Equal(glyphsTtf.GlyphCount, glyphsWoff.GlyphCount); @@ -91,8 +91,8 @@ public void GlyphsCount_WithWoffFormat_EqualsTtf() [Fact] public void ReadFont_WithWoff2Format_EqualsTtf() { - using var fontReaderTtf = new FontReader(TestFonts.OpenSansTtfData()); - using var fontReaderWoff = new FontReader(TestFonts.OpensSansWoff2Data()); + using FontReader fontReaderTtf = new(TestFonts.OpenSansTtfData()); + using FontReader fontReaderWoff = new(TestFonts.OpensSansWoff2Data()); Assert.Equal(fontReaderTtf.Headers.Count, fontReaderWoff.Headers.Count); foreach (string key in fontReaderTtf.Headers.Keys) @@ -104,9 +104,9 @@ public void ReadFont_WithWoff2Format_EqualsTtf() [Fact] public void GlyphsCount_WithWoff2Format_EqualsTtf() { - using var fontReaderWoff = new FontReader(TestFonts.OpensSansWoff2Data()); + using FontReader fontReaderWoff = new(TestFonts.OpensSansWoff2Data()); GlyphTable glyphsWoff = fontReaderWoff.GetTable(); - using var fontReaderTtf = new FontReader(TestFonts.OpenSansTtfData()); + using FontReader fontReaderTtf = new(TestFonts.OpenSansTtfData()); GlyphTable glyphsTtf = fontReaderTtf.GetTable(); Assert.Equal(glyphsTtf.GlyphCount, glyphsWoff.GlyphCount); diff --git a/tests/SixLabors.Fonts.Tests/FontRectangleTests.cs b/tests/SixLabors.Fonts.Tests/FontRectangleTests.cs index 33a89263f..a6a05fc9b 100644 --- a/tests/SixLabors.Fonts.Tests/FontRectangleTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontRectangleTests.cs @@ -19,10 +19,10 @@ public void DefaultConstructorTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void NonDefaultConstructorTest(float x, float y, float width, float height) { - var rect1 = new FontRectangle(x, y, width, height); - var p = new Vector2(x, y); - var s = new Vector2(width, height); - var rect2 = new FontRectangle(p, s); + FontRectangle rect1 = new(x, y, width, height); + Vector2 p = new(x, y); + Vector2 s = new(width, height); + FontRectangle rect2 = new(p, s); Assert.Equal(rect1, rect2); } @@ -34,8 +34,8 @@ public void NonDefaultConstructorTest(float x, float y, float width, float heigh [InlineData(0, float.MinValue, float.MaxValue, 0)] public void FromLTRBTest(float left, float top, float right, float bottom) { - var expected = new FontRectangle(left, top, right - left, bottom - top); - var actual = FontRectangle.FromLTRB(left, top, right, bottom); + FontRectangle expected = new(left, top, right - left, bottom - top); + FontRectangle actual = FontRectangle.FromLTRB(left, top, right, bottom); Assert.Equal(expected, actual); } @@ -47,9 +47,9 @@ public void FromLTRBTest(float left, float top, float right, float bottom) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void DimensionsTest(float x, float y, float width, float height) { - var rect = new FontRectangle(x, y, width, height); - var p = new Vector2(x, y); - var s = new Vector2(width, height); + FontRectangle rect = new(x, y, width, height); + Vector2 p = new(x, y); + Vector2 s = new(width, height); Assert.Equal(p, rect.Location); Assert.Equal(s, rect.Size); @@ -80,8 +80,8 @@ public void IsEmptyTest() [InlineData(float.MaxValue, float.MinValue)] public void LocationSetTest(float x, float y) { - var point = new Vector2(x, y); - var rect = new FontRectangle(point.X, point.Y, 10, 10); + Vector2 point = new(x, y); + FontRectangle rect = new(point.X, point.Y, 10, 10); Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -92,8 +92,8 @@ public void LocationSetTest(float x, float y) [InlineData(float.MaxValue, float.MinValue)] public void SizeSetTest(float x, float y) { - var size = new Vector2(x, y); - var rect = new FontRectangle(10, 10, size.X, size.Y); + Vector2 size = new(x, y); + FontRectangle rect = new(10, 10, size.X, size.Y); Assert.Equal(size, rect.Size); Assert.Equal(size.X, rect.Width); Assert.Equal(size.Y, rect.Height); @@ -105,8 +105,8 @@ public void SizeSetTest(float x, float y) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void EqualityTest(float x, float y, float width, float height) { - var rect1 = new FontRectangle(x, y, width, height); - var rect2 = new FontRectangle(width, height, x, y); + FontRectangle rect1 = new(x, y, width, height); + FontRectangle rect2 = new(width, height, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -117,8 +117,8 @@ public void EqualityTest(float x, float y, float width, float height) [Fact] public void GetHashCodeTest() { - var rect1 = new FontRectangle(10, 10, 10, 10); - var rect2 = new FontRectangle(10, 10, 10, 10); + FontRectangle rect1 = new(10, 10, 10, 10); + FontRectangle rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new FontRectangle(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new FontRectangle(10, 20, 10, 10).GetHashCode()); @@ -131,11 +131,11 @@ public void GetHashCodeTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void ContainsTest(float x, float y, float width, float height) { - var rect = new FontRectangle(x, y, width, height); + FontRectangle rect = new(x, y, width, height); float x1 = (x + width) / 2; float y1 = (y + height) / 2; - var p = new Vector2(x1, y1); - var r = new FontRectangle(x1, y1, width / 2, height / 2); + Vector2 p = new(x1, y1); + FontRectangle r = new(x1, y1, width / 2, height / 2); Assert.False(rect.Contains(x1, y1)); Assert.False(rect.Contains(p)); @@ -148,13 +148,13 @@ public void ContainsTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { - var rect = new FontRectangle(x, y, width, height); - var inflatedRect = new FontRectangle(x - width, y - height, width + (2 * width), height + (2 * height)); + FontRectangle rect = new(x, y, width, height); + FontRectangle inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); rect = rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new Vector2(x, y); + Vector2 s = new(x, y); inflatedRect = FontRectangle.Inflate(rect, x, y); rect = rect.Inflate(s); @@ -166,9 +166,9 @@ public void InflateTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { - var rect1 = new FontRectangle(x, y, width, height); - var rect2 = new FontRectangle(y, x, width, height); - var expectedRect = FontRectangle.Intersect(rect1, rect2); + FontRectangle rect1 = new(x, y, width, height); + FontRectangle rect2 = new(y, x, width, height); + FontRectangle expectedRect = FontRectangle.Intersect(rect1, rect2); rect1 = rect1.Intersect(rect2); Assert.Equal(expectedRect, rect1); Assert.False(rect1.IntersectsWith(expectedRect)); @@ -177,9 +177,9 @@ public void IntersectTest(float x, float y, float width, float height) [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new FontRectangle(0, 0, 5, 5); - var rect2 = new FontRectangle(1, 1, 3, 3F); - var expected = new FontRectangle(1, 1, 3, 3F); + FontRectangle rect1 = new(0, 0, 5, 5); + FontRectangle rect2 = new(1, 1, 3, 3F); + FontRectangle expected = new(1, 1, 3, 3F); Assert.Equal(expected, FontRectangle.Intersect(rect1, rect2)); } @@ -191,15 +191,15 @@ public void IntersectIntersectingRectsTest() [InlineData(0, float.MinValue, float.MaxValue, 0)] public void UnionTest(float x, float y, float width, float height) { - var a = new FontRectangle(x, y, width, height); - var b = new FontRectangle(width, height, x, y); + FontRectangle a = new(x, y, width, height); + FontRectangle b = new(width, height, x, y); float x1 = Math.Min(a.X, b.X); float x2 = Math.Max(a.X + a.Width, b.X + b.Width); float y1 = Math.Min(a.Y, b.Y); float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new FontRectangle(x1, y1, x2 - x1, y2 - y1); + FontRectangle expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, FontRectangle.Union(a, b)); } @@ -211,9 +211,9 @@ public void UnionTest(float x, float y, float width, float height) [InlineData(0, float.MinValue, float.MaxValue, 0)] public void OffsetTest(float x, float y, float width, float height) { - var r1 = new FontRectangle(x, y, width, height); - var expectedRect = new FontRectangle(x + width, y + height, width, height); - var p = new Vector2(width, height); + FontRectangle r1 = new(x, y, width, height); + FontRectangle expectedRect = new(x + width, y + height, width, height); + Vector2 p = new(width, height); r1 = r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -226,7 +226,7 @@ public void OffsetTest(float x, float y, float width, float height) [Fact] public void ToStringTest() { - var r = new FontRectangle(5, 5.1F, 1.3F, 1F); + FontRectangle r = new(5, 5.1F, 1.3F, 1F); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "FontRectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } diff --git a/tests/SixLabors.Fonts.Tests/FontTests.cs b/tests/SixLabors.Fonts.Tests/FontTests.cs index af6df49e3..064c03a79 100644 --- a/tests/SixLabors.Fonts.Tests/FontTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontTests.cs @@ -44,9 +44,8 @@ public void FontClass_NullWithSizeFontThrowsException() [Fact] public void FontClassWithPath_SetProperties() { - var collection = new FontCollection(); - FontFamily family = collection.Add(TestFonts.CarterOneFile); - var font = new Font(family, 12); + FontFamily family = TestFonts.GetFontFamily(TestFonts.CarterOneFile); + Font font = new(family, 12); Assert.Equal("Carter One", font.Name); Assert.Equal(12, font.Size); @@ -60,10 +59,10 @@ public void FontClassWithPath_SetProperties() [Fact] public void FontClassNoPath_SetProperties() { - var collection = new FontCollection(); + FontCollection collection = new(); using Stream stream = TestFonts.CarterOneFileData(); FontFamily family = collection.Add(stream); - var font = new Font(family, 12); + Font font = new(family, 12); Assert.Equal("Carter One", font.Name); Assert.Equal(12, font.Size); diff --git a/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype-Subset.otf b/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype-Subset.otf deleted file mode 100644 index 5cc7279fc..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype-Subset.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype.ttf b/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype.ttf deleted file mode 100644 index 5a1c1f599..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/AdobeVFPrototype.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/AliceFrancesHMK-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/AliceFrancesHMK-Regular.ttf deleted file mode 100644 index ee61105ba..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/AliceFrancesHMK-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/BNazanin.ttf b/tests/SixLabors.Fonts.Tests/Fonts/BNazanin.ttf deleted file mode 100644 index eb227d7e2..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/BNazanin.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Carter_One/CarterOne.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Carter_One/CarterOne.ttf deleted file mode 100644 index 1f3c9270f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Carter_One/CarterOne.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/CharisSIL-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/CharisSIL-Regular.ttf deleted file mode 100644 index 38830fc50..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/CharisSIL-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Cousine-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Cousine-Regular.ttf deleted file mode 100644 index f67a6c8f8..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Cousine-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/DejaVuSans.ttf b/tests/SixLabors.Fonts.Tests/Fonts/DejaVuSans.ttf deleted file mode 100644 index e5f7eecce..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/DejaVuSans.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Dubai-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Dubai-Regular.ttf deleted file mode 100644 index 9d9cea18f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Dubai-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/EBGaramond-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/EBGaramond-Regular.ttf deleted file mode 100644 index 80a857b47..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/EBGaramond-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/FDArrayTest257.otf b/tests/SixLabors.Fonts.Tests/Fonts/FDArrayTest257.otf deleted file mode 100644 index a97b1f44c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/FDArrayTest257.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Font-Version1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Font-Version1.ttf deleted file mode 100644 index 1a3f94368..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Font-Version1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/FormalScript.ttf b/tests/SixLabors.Fonts.Tests/Fonts/FormalScript.ttf deleted file mode 100644 index 76327c86d..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/FormalScript.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format1.ttf deleted file mode 100644 index e8dfa6242..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format2.ttf deleted file mode 100644 index 4bffca234..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType1Format2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType2Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType2Format1.ttf deleted file mode 100644 index 1653e6e68..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType2Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType3Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType3Format1.ttf deleted file mode 100644 index 52f67c588..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType3Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType4Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType4Format1.ttf deleted file mode 100644 index 2caa763c7..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType4Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType5Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType5Format1.ttf deleted file mode 100644 index 76e79dfb7..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType5Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType6Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType6Format1.ttf deleted file mode 100644 index 889442eef..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType6Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format1.ttf deleted file mode 100644 index 3518fbaf3..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format2.ttf deleted file mode 100644 index 0b15b20c4..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format3.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format3.ttf deleted file mode 100644 index c0ba4e9cf..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType7Format3.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format1.ttf deleted file mode 100644 index c3b97e290..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format2.ttf deleted file mode 100644 index 4e88b8591..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format3.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format3.ttf deleted file mode 100644 index 1a8b6db42..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposLookupType8Format3.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GposTestFont.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GposTestFont.ttf deleted file mode 100644 index c4be5eaae..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GposTestFont.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format1.ttf deleted file mode 100644 index 90daf6a2f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format2.ttf deleted file mode 100644 index e341c2ac9..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format3.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format3.ttf deleted file mode 100644 index e40df6229..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType5Format3.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format1.ttf deleted file mode 100644 index 5083e1063..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format2.ttf deleted file mode 100644 index 1404af19b..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubLookupType6Format2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont1.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont1.ttf deleted file mode 100644 index ddaa95850..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont1.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont2.ttf b/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont2.ttf deleted file mode 100644 index 73b357a6f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/GsubTestFont2.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Helvetica.ttc b/tests/SixLabors.Fonts.Tests/Fonts/Helvetica.ttc deleted file mode 100644 index c143519a3..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Helvetica.ttc and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Hind-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Hind-Regular.ttf deleted file mode 100644 index d354dbbcd..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Hind-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Inconsolata-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Inconsolata-Regular.ttf deleted file mode 100644 index 94747bd08..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Inconsolata-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue96.fuzz b/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue96.fuzz deleted file mode 100644 index 2c7b086b8..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue96.fuzz and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue97.fuzz b/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue97.fuzz deleted file mode 100644 index ece142028..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Issues/Issue97.fuzz and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf b/tests/SixLabors.Fonts.Tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf deleted file mode 100644 index 56d809f4c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Issues/StreamFontMetri.CreateCffGlyphMetrics.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Issues/StyleScript.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Issues/StyleScript.ttf deleted file mode 100644 index 7cec38ff8..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Issues/StyleScript.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/KellySlab-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/KellySlab-Regular.ttf deleted file mode 100644 index dce51a97e..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/KellySlab-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Mada-VF.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Mada-VF.ttf deleted file mode 100644 index e6f44045c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Mada-VF.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NanumGothicCoding-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NanumGothicCoding-Regular.ttf deleted file mode 100644 index ba77a9da2..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NanumGothicCoding-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoColorEmoji-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoColorEmoji-Regular.ttf deleted file mode 100644 index 5d7a86f3c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoColorEmoji-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoEmoji-VariableFont_wght.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoEmoji-VariableFont_wght.ttf deleted file mode 100644 index 4c7d78e4f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoEmoji-VariableFont_wght.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoNaskhArabic-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoNaskhArabic-Regular.ttf deleted file mode 100644 index f69f25465..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoNaskhArabic-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSans-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSans-Regular.ttf deleted file mode 100644 index 4bac02f2f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSans-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansArabic-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansArabic-Regular.ttf deleted file mode 100644 index 3279938e1..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansArabic-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBalinese-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBalinese-Regular.ttf deleted file mode 100644 index 0b0f58f07..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBalinese-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBengali-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBengali-Regular.ttf deleted file mode 100644 index 320b43e3a..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansBengali-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansDevanagari-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansDevanagari-Regular.ttf deleted file mode 100644 index 19a50993a..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansDevanagari-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGujarati-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGujarati-Regular.ttf deleted file mode 100644 index 11fe8c7fd..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGujarati-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGurmukhi-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGurmukhi-Regular.ttf deleted file mode 100644 index 39a7ed393..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansGurmukhi-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHK-VariableFont_wght.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHK-VariableFont_wght.ttf deleted file mode 100644 index 8c0cd9c43..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHK-VariableFont_wght.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHebrew-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHebrew-Regular.ttf deleted file mode 100644 index b44a0db04..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansHebrew-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansJP-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansJP-Regular.ttf deleted file mode 100644 index cdd8f083c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansJP-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKR-Regular.otf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKR-Regular.otf deleted file mode 100644 index 7c5c2fae3..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKR-Regular.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKannada-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKannada-Regular.ttf deleted file mode 100644 index 7366f378c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKannada-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKhmer-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKhmer-Regular.ttf deleted file mode 100644 index e665ed785..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansKhmer-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMalayalam-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMalayalam-Regular.ttf deleted file mode 100644 index 14eb2d106..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMalayalam-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMyanmar-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMyanmar-Regular.ttf deleted file mode 100644 index f4552f2ee..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansMyanmar-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOgham-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOgham-Regular.ttf deleted file mode 100644 index 4ac99980c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOgham-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOriya-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOriya-Regular.ttf deleted file mode 100644 index ab57812ea..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansOriya-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansRunic-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansRunic-Regular.ttf deleted file mode 100644 index d99c098ae..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansRunic-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Regular.ttf deleted file mode 100644 index 176f1134e..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin-Bad.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin-Bad.ttf deleted file mode 100644 index d09c38891..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin-Bad.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin.ttf deleted file mode 100644 index 4c2831f7b..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSC-Thin.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSinhala-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSinhala-Regular.ttf deleted file mode 100644 index 60c85f4c9..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansSinhala-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTamil-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTamil-Regular.ttf deleted file mode 100644 index b8259eac7..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTamil-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTelugu-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTelugu-Regular.ttf deleted file mode 100644 index bba7e0c50..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSansTelugu-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifKannada-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifKannada-Regular.ttf deleted file mode 100644 index 30ca55090..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifKannada-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifLao-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifLao-Regular.ttf deleted file mode 100644 index 8b1cd0125..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifLao-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifTibetan-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifTibetan-Regular.ttf deleted file mode 100644 index 9422ef276..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/NotoSerifTibetan-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.ttf deleted file mode 100644 index a92a22b33..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff b/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff deleted file mode 100644 index 5505d8c84..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff2 b/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff2 deleted file mode 100644 index d962e3bd5..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.woff2 and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/PMINGLIU.ttf b/tests/SixLabors.Fonts.Tests/Fonts/PMINGLIU.ttf deleted file mode 100644 index 1a284f77c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/PMINGLIU.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.ttf deleted file mode 100644 index 6541e9d87..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.woff2 b/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.woff2 deleted file mode 100644 index 203ccaeb9..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/PermanentMarker-Regular.woff2 and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/PlantinStdRegular.otf b/tests/SixLabors.Fonts.Tests/Fonts/PlantinStdRegular.otf deleted file mode 100644 index 16b8d4f24..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/PlantinStdRegular.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Roboto-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Roboto-Regular.ttf deleted file mode 100644 index 3d6861b42..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Roboto-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/RobotoFlex.ttf b/tests/SixLabors.Fonts.Tests/Fonts/RobotoFlex.ttf deleted file mode 100644 index f7cda4783..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/RobotoFlex.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Sample.ttc b/tests/SixLabors.Fonts.Tests/Fonts/Sample.ttc deleted file mode 100644 index e16b78e77..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Sample.ttc and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Sarabun-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Sarabun-Regular.ttf deleted file mode 100644 index 161c9ac9a..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Sarabun-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Segoeui.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Segoeui.ttf deleted file mode 100644 index 0f52cbd9c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Segoeui.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff b/tests/SixLabors.Fonts.Tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff deleted file mode 100644 index ae3eef6d3..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/ServiceNow-Sans-Text-Bold-unmastered-1.1.woff and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.ttf b/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.ttf deleted file mode 100644 index 03c528945..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.woff b/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.woff deleted file mode 100644 index 277749dfb..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/SixLaborsSampleAB.woff and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf deleted file mode 100644 index 76a32e6c6..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/SofiaSansCondensed-ExtraLight-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/SourceSansPro-Regular.otf b/tests/SixLabors.Fonts.Tests/Fonts/SourceSansPro-Regular.otf deleted file mode 100644 index 55fc53397..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/SourceSansPro-Regular.otf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Sumana-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Sumana-Regular.ttf deleted file mode 100644 index 4e9a6d8a5..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Sumana-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Sunflower-Medium.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Sunflower-Medium.ttf deleted file mode 100644 index 9e44fe7dc..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Sunflower-Medium.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/THSarabun.ttf b/tests/SixLabors.Fonts.Tests/Fonts/THSarabun.ttf deleted file mode 100644 index 23dd82b13..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/THSarabun.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestGSUBThree.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestGSUBThree.ttf deleted file mode 100644 index ec27e0322..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestGSUBThree.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARFour.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestGVARFour.ttf deleted file mode 100644 index 3524f3741..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARFour.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestGVAROne.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestGVAROne.ttf deleted file mode 100644 index 17a481b6f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestGVAROne.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARThree.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestGVARThree.ttf deleted file mode 100644 index 17f5013dc..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARThree.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARTwo.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestGVARTwo.ttf deleted file mode 100644 index 6061a166d..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestGVARTwo.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestHVARTwo.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestHVARTwo.ttf deleted file mode 100644 index 2e81f94cb..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestHVARTwo.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TestShapeEthi.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TestShapeEthi.ttf deleted file mode 100644 index 391dddd70..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TestShapeEthi.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/TimesNewRoman.ttf b/tests/SixLabors.Fonts.Tests/Fonts/TimesNewRoman.ttf deleted file mode 100644 index f71d84abc..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/TimesNewRoman.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Twemoji Mozilla.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Twemoji Mozilla.ttf deleted file mode 100644 index 75ddc213f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Twemoji Mozilla.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/VeryBerryProRegular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/VeryBerryProRegular.ttf deleted file mode 100644 index 2c10e0705..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/VeryBerryProRegular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf b/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf deleted file mode 100644 index e5231bb2f..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf b/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf deleted file mode 100644 index 61c954602..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/VotoSerifGX-IUP-gvar-cvar_noshared.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/Wendy_One/WendyOne-Regular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/Wendy_One/WendyOne-Regular.ttf deleted file mode 100644 index 4a1aacc1b..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/Wendy_One/WendyOne-Regular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/arial.ttf b/tests/SixLabors.Fonts.Tests/Fonts/arial.ttf deleted file mode 100644 index 98b05d900..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/arial.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/consola.ttf b/tests/SixLabors.Fonts.Tests/Fonts/consola.ttf deleted file mode 100644 index e881ca4b5..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/consola.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/courier-prime.woff2 b/tests/SixLabors.Fonts.Tests/Fonts/courier-prime.woff2 deleted file mode 100644 index f7ee5b6af..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/courier-prime.woff2 and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/kaiu.ttf b/tests/SixLabors.Fonts.Tests/Fonts/kaiu.ttf deleted file mode 100644 index d8a755f8c..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/kaiu.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/me_quran_volt_newmet.ttf b/tests/SixLabors.Fonts.Tests/Fonts/me_quran_volt_newmet.ttf deleted file mode 100644 index c40fd0fcd..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/me_quran_volt_newmet.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/mgopencanonicaregular.ttf b/tests/SixLabors.Fonts.Tests/Fonts/mgopencanonicaregular.ttf deleted file mode 100644 index cc6e121ce..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/mgopencanonicaregular.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/seguiemj-win11.ttf b/tests/SixLabors.Fonts.Tests/Fonts/seguiemj-win11.ttf deleted file mode 100644 index 3c6485dbe..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/seguiemj-win11.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/tahoma.ttf b/tests/SixLabors.Fonts.Tests/Fonts/tahoma.ttf deleted file mode 100644 index 62148d268..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/tahoma.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/Fonts/whitney-book.ttf b/tests/SixLabors.Fonts.Tests/Fonts/whitney-book.ttf deleted file mode 100644 index cfdd3232d..000000000 Binary files a/tests/SixLabors.Fonts.Tests/Fonts/whitney-book.ttf and /dev/null differ diff --git a/tests/SixLabors.Fonts.Tests/GlyphRenderer.cs b/tests/SixLabors.Fonts.Tests/GlyphRenderer.cs index 38dec39da..3766046ca 100644 --- a/tests/SixLabors.Fonts.Tests/GlyphRenderer.cs +++ b/tests/SixLabors.Fonts.Tests/GlyphRenderer.cs @@ -8,16 +8,17 @@ namespace SixLabors.Fonts.Tests; public class GlyphRenderer : IGlyphRenderer { - private int figuresCount; private GlyphRendererParameters parameters; - public List ControlPoints { get; } = new(); + public List ControlPoints { get; } = []; - public List ControlPointsOnCurve { get; } = new(); + public List ControlPointsOnCurve { get; } = []; - public List GlyphRects { get; } = new(); + public List GlyphRects { get; } = []; - public List GlyphKeys { get; } = new(); + public List GlyphKeys { get; } = []; + + public int FiguresCount { get; set; } public bool BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters) { @@ -26,7 +27,7 @@ public bool BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters param return true; } - public void BeginFigure() => this.figuresCount++; + public void BeginFigure() => this.FiguresCount++; public void CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point) { diff --git a/tests/SixLabors.Fonts.Tests/GlyphTests.cs b/tests/SixLabors.Fonts.Tests/GlyphTests.cs index a827f94f4..5d744623b 100644 --- a/tests/SixLabors.Fonts.Tests/GlyphTests.cs +++ b/tests/SixLabors.Fonts.Tests/GlyphTests.cs @@ -21,7 +21,7 @@ public class GlyphTests public void RenderToPointAndSingleDPI() { const string text = "A"; - CodePoint codePoint = this.AsCodePoint(text); + CodePoint codePoint = AsCodePoint(text); Font font = CreateFont(text, 10); TextRun textRun = new() { Start = 0, End = 1, Font = font }; @@ -99,7 +99,7 @@ public static Font CreateFont(string text, float pointSize = 1) [Fact] public void LoadGlyph() { - Font font = new FontCollection().Add(TestFonts.SimpleFontFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); // Get letter A Assert.True(font.TryGetGlyphs(new CodePoint(41), ColorFontSupport.None, out Glyph? glyph)); @@ -111,7 +111,7 @@ public void LoadGlyph() [Fact] public void RenderColrGlyphTextRenderer() { - Font font = new FontCollection().Add(TestFonts.TwemojiMozillaData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.TwemojiMozillaFile, 12); ColorGlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, "😀", new TextOptions(font) @@ -125,7 +125,7 @@ public void RenderColrGlyphTextRenderer() [Fact] public void RenderColrGlyphWithVariationSelector() { - Font font = new FontCollection().Add(TestFonts.TwemojiMozillaData()).CreateFont(72); + Font font = TestFonts.GetFont(TestFonts.TwemojiMozillaFile, 72); const string text = "\u263A\uFE0F"; // Fully-qualified sequence for emoji 'smiling face' @@ -144,7 +144,7 @@ public void RenderColrGlyphWithVariationSelector() [Fact] public void EmojiWidthIsComputedCorrectlyWithSubstitutionOnZwj() { - Font font = new FontCollection().Add(TestFonts.SegoeuiEmojiData()).CreateFont(72); + Font font = TestFonts.GetFont(TestFonts.SegoeuiEmojiFile, 72); const string text = "\U0001F469\U0001F3FB\u200D\U0001F91D\u200D\U0001F469\U0001F3FC"; // women holding hands: light skin tone, medium-light skin tone const string text2 = "\U0001F46D\U0001F3FB"; // women holding hands: light skin tone @@ -163,8 +163,8 @@ public void EmojiWidthIsComputedCorrectlyWithSubstitutionOnZwj() [InlineData(true, true, 1238)] public void RenderWoffGlyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHinting, int expectedControlPoint) { - Font fontTtf = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(12); - Font fontWoff = new FontCollection().Add(TestFonts.OpenSansFileWoff1).CreateFont(12); + Font fontTtf = TestFonts.GetFont(TestFonts.OpenSansFile, 12); + Font fontWoff = TestFonts.GetFont(TestFonts.OpenSansFileWoff1, 12); string testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ColorGlyphRenderer rendererTtf = new(); @@ -194,8 +194,8 @@ public void RenderWoffGlyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHin [InlineData("\uFB04")] public void RenderWoff_CompositeGlyphs_IsEqualToTtfGlyphs(string testStr) { - Font fontTtf = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(12); - Font fontWoff = new FontCollection().Add(TestFonts.OpenSansFileWoff1).CreateFont(12); + Font fontTtf = TestFonts.GetFont(TestFonts.OpenSansFile, 12); + Font fontWoff = TestFonts.GetFont(TestFonts.OpenSansFileWoff1, 12); ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) @@ -221,8 +221,8 @@ public void RenderWoff_CompositeGlyphs_IsEqualToTtfGlyphs(string testStr) [InlineData(true, true, 1238)] public void RenderWoff2Glyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHinting, int expectedControlPoints) { - Font fontTtf = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(12); - Font fontWoff2 = new FontCollection().Add(TestFonts.OpenSansFileWoff2).CreateFont(12); + Font fontTtf = TestFonts.GetFont(TestFonts.OpenSansFile, 12); + Font fontWoff2 = TestFonts.GetFont(TestFonts.OpenSansFileWoff2, 12); string testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ColorGlyphRenderer rendererTtf = new(); @@ -252,8 +252,8 @@ public void RenderWoff2Glyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHi [InlineData("\uFB04")] public void RenderWoff2_CompositeGlyphs_IsEqualToTtfGlyphs(string testStr) { - Font fontTtf = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(12); - Font fontWoff2 = new FontCollection().Add(TestFonts.OpenSansFileWoff2).CreateFont(12); + Font fontTtf = TestFonts.GetFont(TestFonts.OpenSansFile, 12); + Font fontWoff2 = TestFonts.GetFont(TestFonts.OpenSansFileWoff2, 12); ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) @@ -294,5 +294,5 @@ public void RendererIsThreadsafe(string fontName) } #endif - private CodePoint AsCodePoint(string text) => CodePoint.DecodeFromUtf16At(text.AsSpan(), 0); + private static CodePoint AsCodePoint(string text) => CodePoint.DecodeFromUtf16At(text.AsSpan(), 0); } diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs index f321e849c..cb069f441 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs @@ -27,7 +27,7 @@ public override ImageSimilarityReport CompareImagesOrFrames differences = new(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs index a3253a8cf..17725c5ca 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/Exceptions/ImageDifferenceIsOverThresholdException.cs @@ -12,7 +12,7 @@ public class ImageDifferenceIsOverThresholdException : ImagesSimilarityException public ImageDifferenceIsOverThresholdException(params ImageSimilarityReport[] reports) : base("Image difference is over threshold!" + FormatReports(reports)) - => this.Reports = reports.ToArray(); + => this.Reports = [.. reports]; private static string FormatReports(IEnumerable reports) { diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/ImageComparer.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/ImageComparer.cs index ae3f68830..1d9a3dcd4 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/ImageComparer.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/ImageComparer.cs @@ -56,7 +56,7 @@ public static IEnumerable> CompareImages where TPixelA : unmanaged, IPixel where TPixelB : unmanaged, IPixel { - List> result = new(); + List> result = []; int expectedFrameCount = actual.Frames.Count; if (predicate != null) @@ -127,7 +127,7 @@ public static void VerifySimilarity( IEnumerable reports = comparer.CompareImages(expected, actual, predicate); if (reports.Any()) { - throw new ImageDifferenceIsOverThresholdException(reports.ToArray()); + throw new ImageDifferenceIsOverThresholdException([.. reports]); } } diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/ImageSimilarityReport.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/ImageSimilarityReport.cs index 9ad00120a..6bd9a98ef 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/ImageSimilarityReport.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/ImageSimilarityReport.cs @@ -21,7 +21,7 @@ protected ImageSimilarityReport( this.ExpectedImage = expectedImage; this.ActualImage = actualImage; this.TotalNormalizedDifference = totalNormalizedDifference; - this.Differences = differences.ToArray(); + this.Differences = [.. differences]; } public int Index { get; } diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/TestImageExtensions.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/TestImageExtensions.cs index 828bf1014..b95e31cab 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/TestImageExtensions.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/TestImageExtensions.cs @@ -74,7 +74,7 @@ public static void CompareToReference( private static string FormatTestDetails(params object[] properties) { - if (properties?.Any() != true) + if (properties is null || properties.Length == 0) { return "-"; } diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/TolerantImageComparer.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/TolerantImageComparer.cs index 58ae66e5c..ec43b052e 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/TolerantImageComparer.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/TolerantImageComparer.cs @@ -71,7 +71,7 @@ public override ImageSimilarityReport CompareImagesOrFrames differences = new(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_180.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_180.cs index 2ca56e944..78e56f265 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_180.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_180.cs @@ -9,7 +9,7 @@ public class Issues_180 public void CorrectlySetsHeightMetrics() { // Whitney-book has invalid hhea values. - Font font = new FontCollection().Add(TestFonts.WhitneyBookFile).CreateFont(25); + Font font = TestFonts.GetFont(TestFonts.WhitneyBookFile, 25); FontRectangle size = TextMeasurer.MeasureSize("H", new TextOptions(font)); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_203.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_203.cs index a416c7808..416c986b8 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_203.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_203.cs @@ -8,7 +8,7 @@ public class Issues_203 [Fact] public void CanParseVersion1Font() { - var font = FontDescription.LoadDescription(TestFonts.Version1Font); + FontDescription font = FontDescription.LoadDescription(TestFonts.Version1Font); Assert.NotNull(font); } } diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs index bf465fc29..0c5a34251 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs @@ -11,7 +11,7 @@ public class Issues_23 public void BleedingFonts() { // wendy one returns wrong points for 'o' - Font font = new FontCollection().Add(TestFonts.WendyOneFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.WendyOneFile, 12); GlyphRenderer r = new(); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_269.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_269.cs index a7a91585a..f08c15142 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_269.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_269.cs @@ -11,7 +11,7 @@ public class Issues_269 public void CorrectlySetsMetricsForFontsNotAdheringToSpec() { // AliceFrancesHMK has invalid subtables. - Font font = new FontCollection().Add(TestFonts.AliceFrancesHMKRegularFile).CreateFont(25); + Font font = TestFonts.GetFont(TestFonts.AliceFrancesHMKRegularFile, 25); FontRectangle size = TextMeasurer.MeasureSize("H", new TextOptions(font)); Assert.Equal(30.6000004F, size.Width, Comparer); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_27.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_27.cs index bf52e2381..d6c6e1a1b 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_27.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_27.cs @@ -9,7 +9,7 @@ public class Issues_27 public void ThrowsMeasuringWhitespace() { // wendy one returns wrong points for 'o' - Font font = new FontCollection().Add(TestFonts.WendyOneFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.WendyOneFile, 12); FontRectangle size = TextMeasurer.MeasureBounds(" ", new TextOptions(new Font(font, 30))); Assert.Equal(6, size.Width, 1F); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_298.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_298.cs index 79605260f..5d708517b 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_298.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_298.cs @@ -10,11 +10,7 @@ public void DoesNotThrowOutOfBounds() { const string content = "Please enter the text"; - FontCollection fontFamilies = new(); - - FontFamily fontFamily = fontFamilies.Add(TestFonts.Issues.Issue298File); - - Font font = fontFamily.CreateFont(16, FontStyle.Regular); + Font font = TestFonts.GetFont(TestFonts.Issues.Issue298File, 16); TextOptions renderOptions = new(font) { diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_33.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_33.cs index 8b2db2c75..6a82a728c 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_33.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_33.cs @@ -26,7 +26,7 @@ public void WhiteSpaceAtStartOfLineNotMeasured(string text, float width, float h public static Font CreateFont(string text) { - var fc = (IFontMetricsCollection)new FontCollection(); + IFontMetricsCollection fc = (IFontMetricsCollection)new FontCollection(); Font d = fc.AddMetrics(new FakeFontInstance(text), CultureInfo.InvariantCulture).CreateFont(12); return new Font(d, 1F); } diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_333.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_333.cs index a00a0c4c1..e207478e7 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_333.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_333.cs @@ -9,7 +9,7 @@ public class Issues_333 public void DoesNotThrowMissingTableException() { const string text = "文字測試文字測試文字測試文字測試文字測試"; - Font font = new FontCollection().Add(TestFonts.PMINGLIUFile).CreateFont(1024); + Font font = TestFonts.GetFont(TestFonts.PMINGLIUFile, 1024); TextMeasurer.MeasureSize(text, new TextOptions(font)); } } diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_334.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_334.cs index 446f4615f..aacbc318e 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_334.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_334.cs @@ -10,7 +10,7 @@ public class Issues_334 [Fact] public void DoesNotSkewCompositeGlyph() { - FontFamily family = new FontCollection().Add(TestFonts.SumanaRegularFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.SumanaRegularFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); Font font = family.CreateFont(metrics.UnitsPerEm); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_335.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_335.cs index 1da6c7fee..c5985ef27 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_335.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_335.cs @@ -11,7 +11,7 @@ public class Issues_335 [InlineData(TextAlignment.End)] public void HorizontalAlignmentWorksForSingleLineText(TextAlignment alignment) { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -38,7 +38,7 @@ public void HorizontalAlignmentWorksForSingleLineText(TextAlignment alignment) [InlineData(TextAlignment.End)] public void VerticalAlignmentWorksForSingleLineText(TextAlignment alignment) { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs index 692b47717..b0a19daca 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs @@ -10,7 +10,7 @@ public class Issues_337 [Fact] public void CanShapeCompositeGlyphs() { - Font font = new FontCollection().Add(TestFonts.DFKaiSBFile).CreateFont(1024); + Font font = TestFonts.GetFont(TestFonts.DFKaiSBFile, 1024); ColorGlyphRenderer renderer = new(); TextOptions options = new(font) { diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_353.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_353.cs index 184371501..020fd7e40 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_353.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_353.cs @@ -13,10 +13,7 @@ public class Issues_353 [Fact] public void Test_Issue_353() { - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.EbGaramond).Name; - FontFamily family = fontCollection.Get(name); - Font font = family.CreateFont(30, FontStyle.Regular); + Font font = TestFonts.GetFont(TestFonts.EbGaramond, 30); string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris."; TextOptions options = new(font) diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_363.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_363.cs index 1c56ff750..bf957f706 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_363.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_363.cs @@ -8,7 +8,7 @@ public class Issues_363 [Fact] public void GSubFormat2NUllReferenceException() { - Font font = new FontCollection().Add(TestFonts.BNazaninFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.BNazaninFile, 12); TextOptions textOptions = new(font); string text = "تست فونت 1234"; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_367.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_367.cs index aaa87cd24..c630ee156 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_367.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_367.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. namespace SixLabors.Fonts.Tests.Issues; + public class Issues_367 { private static readonly ApproximateFloatComparer Comparer = new(.1F); @@ -9,7 +10,7 @@ public class Issues_367 [Fact] public void ShouldMatchBrowserBreak() { - Font font = new FontCollection().Add(TestFonts.CourierPrimeFile).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.CourierPrimeFile, 12); TextOptions options = new(font) { diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_375.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_375.cs index 29c7e0191..467c51be4 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_375.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_375.cs @@ -2,12 +2,13 @@ // Licensed under the Six Labors Split License. namespace SixLabors.Fonts.Tests.Issues; + public class Issues_375 { [Fact] public void DiacriticsAreMeasuredCorrectly() { - Font font = new FontCollection().Add(TestFonts.PermanentMarkerRegularFile).CreateFont(142); + Font font = TestFonts.GetFont(TestFonts.PermanentMarkerRegularFile, 142); TextOptions options = new(font); @@ -15,7 +16,7 @@ public void DiacriticsAreMeasuredCorrectly() FontRectangle size = TextMeasurer.MeasureSize("È", options); FontRectangle advance = TextMeasurer.MeasureAdvance("È", options); - Font fontWoff = new FontCollection().Add(TestFonts.PermanentMarkerRegularWoff2File).CreateFont(142); + Font fontWoff = TestFonts.GetFont(TestFonts.PermanentMarkerRegularWoff2File, 142); TextOptions optionsWoff = new(fontWoff); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_378.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_378.cs index abddef92b..f8147c162 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_378.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_378.cs @@ -2,12 +2,13 @@ // Licensed under the Six Labors Split License. namespace SixLabors.Fonts.Tests.Issues; + public class Issues_378 { [Fact] public void DoesNotBreakIncorrectly() { - Font font = new FontCollection().Add(TestFonts.PlantinStdRegularFile).CreateFont(2048); + Font font = TestFonts.GetFont(TestFonts.PlantinStdRegularFile, 2048); TextOptions options = new(font) { WrappingLength = float.MaxValue }; FontRectangle size = TextMeasurer.MeasureSize("D\r\nD", options); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_403.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_403.cs index de5e2d605..645ccffee 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_403.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_403.cs @@ -9,7 +9,7 @@ public class Issues_403 [Fact] public void DoesNotKernIncorrectly() { - Font font = new FontCollection().Add(TestFonts.KellySlabFile).CreateFont(2048); + Font font = TestFonts.GetFont(TestFonts.KellySlabFile, 2048); TextOptions options = new(font) { KerningMode = KerningMode.Auto }; FontRectangle kerned = TextMeasurer.MeasureSize("AY", options); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_412.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_412.cs index 6a61ff686..692cde8b6 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_412.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_412.cs @@ -8,9 +8,7 @@ public class Issues_412 [Fact] public void ShouldCreateCorrectTextRunCount() { - FontCollection collection = new(); - FontFamily family = collection.Add(TestFonts.OpenSansFile); - Font font = family.CreateFont(24); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 24); TextOptions options = new(font) { diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_417.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_417.cs index 0d12f914f..01a9ebd88 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_417.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_417.cs @@ -10,7 +10,7 @@ public class Issues_417 [Fact] public void DoesNotThrow_InvalidAnchor() { - FontFamily family = new FontCollection().Add(TestFonts.NotoSansRegular); + FontFamily family = TestFonts.GetFontFamily(TestFonts.NotoSansRegular); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); Font font = family.CreateFont(metrics?.UnitsPerEm ?? 1000); @@ -30,7 +30,7 @@ public void DoesNotThrow_InvalidAnchor() GlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, "Text", new TextOptions(font)); - int[] expectedGlyphIndices = { 55, 72, 91, 87 }; + int[] expectedGlyphIndices = [55, 72, 91, 87]; Assert.Equal(expectedGlyphIndices.Length, renderer.GlyphKeys.Count); for (int i = 0; i < expectedGlyphIndices.Length; i++) { diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_444.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_444.cs index e4b63fad1..728572243 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_444.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_444.cs @@ -7,7 +7,7 @@ namespace SixLabors.Fonts.Tests.Issues; public class Issues_444 { - private readonly FontFamily charisSIL = new FontCollection().Add(TestFonts.CharisSILRegular); + private readonly FontFamily charisSIL = TestFonts.GetFontFamily(TestFonts.CharisSILRegular); [Fact] public void Issue_444_A() diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_446.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_446.cs index aa36ece58..691282bc8 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_446.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_446.cs @@ -7,7 +7,7 @@ namespace SixLabors.Fonts.Tests.Issues; public class Issues_446 { - private readonly FontFamily charisSIL = new FontCollection().Add(TestFonts.CharisSILRegular); + private readonly FontFamily charisSIL = TestFonts.GetFontFamily(TestFonts.CharisSILRegular); [Fact] public void Issue_446_A() diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_451.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_451.cs index 5e62bc717..526413757 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_451.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_451.cs @@ -1,13 +1,11 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Numerics; - namespace SixLabors.Fonts.Tests.Issues; public class Issues_451 { - private readonly FontFamily berry = new FontCollection().Add(TestFonts.VeryBerryProRegular); + private readonly FontFamily berry = TestFonts.GetFontFamily(TestFonts.VeryBerryProRegular); [Fact] public void Issue_451_A() diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_462.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_462.cs index 4a7a1de09..fe332e301 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_462.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_462.cs @@ -8,8 +8,8 @@ namespace SixLabors.Fonts.Tests.Issues; public class Issues_462 { - private readonly FontFamily emoji = new FontCollection().Add(TestFonts.NotoColorEmojiRegular); - private readonly FontFamily noto = new FontCollection().Add(TestFonts.NotoSansRegular); + private readonly FontFamily emoji = TestFonts.GetFontFamily(TestFonts.NotoColorEmojiRegular); + private readonly FontFamily noto = TestFonts.GetFontFamily(TestFonts.NotoSansRegular); [Fact] public void CanRenderEmojiFont_With_COLRv1() diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_468.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_468.cs index 3243933b8..6ec88d0df 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_468.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_468.cs @@ -18,17 +18,15 @@ public void TestIssue_468() string text = stringBuilder.ToString(); FontCollection fontCollection = new(); - string consola = fontCollection.Add(TestFonts.Consola).Name; - string arabic = fontCollection.Add(TestFonts.NotoSansArabicRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(consola); - Font mainFont = mainFontFamily.CreateFont(50, FontStyle.Regular); + FontFamily consola = TestFonts.GetFontFamily(fontCollection, TestFonts.Consola); + FontFamily arabic = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansArabicRegular); + Font mainFont = consola.CreateFont(50, FontStyle.Regular); TextOptions options = new(mainFont) { FallbackFontFamilies = [ - fontCollection.Get(arabic), + arabic, ], }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_469.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_469.cs index 4f3476112..7ce2a9120 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_469.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_469.cs @@ -25,31 +25,30 @@ public void Test_Issue_469() string text = stringBuilder.ToString(); FontCollection fontCollection = new(); - string arial = fontCollection.Add(TestFonts.Arial).Name; - string cousine = fontCollection.Add(TestFonts.CousineRegular).Name; - string hind = fontCollection.Add(TestFonts.HindRegular).Name; - string nanumGothicCoding = fontCollection.Add(TestFonts.NanumGothicCodingRegular).Name; - string inconsolata = fontCollection.Add(TestFonts.InconsolataRegular).Name; - string notoNaskhArabic = fontCollection.Add(TestFonts.NotoNaskhArabicRegular).Name; - string notoSansJpThin = fontCollection.Add(TestFonts.NotoSansJPRegular).Name; - string notoSansScThin = fontCollection.Add(TestFonts.NotoSansSCThin).Name; - string sarabun = fontCollection.Add(TestFonts.SarabunRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(arial); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + FontFamily arial = TestFonts.GetFontFamily(fontCollection, TestFonts.Arial); + FontFamily cousine = TestFonts.GetFontFamily(fontCollection, TestFonts.CousineRegular); + FontFamily hind = TestFonts.GetFontFamily(fontCollection, TestFonts.HindRegular); + FontFamily nanumGothicCoding = TestFonts.GetFontFamily(fontCollection, TestFonts.NanumGothicCodingRegular); + FontFamily inconsolata = TestFonts.GetFontFamily(fontCollection, TestFonts.InconsolataRegular); + FontFamily notoNaskhArabic = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoNaskhArabicRegular); + FontFamily notoSansJpThin = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansJPRegular); + FontFamily notoSansScThin = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansSCThin); + FontFamily sarabun = TestFonts.GetFontFamily(fontCollection, TestFonts.SarabunRegular); + + Font mainFont = arial.CreateFont(30, FontStyle.Regular); TextOptions options = new(mainFont) { FallbackFontFamilies = [ - fontCollection.Get(inconsolata), - fontCollection.Get(nanumGothicCoding), - fontCollection.Get(cousine), - fontCollection.Get(notoSansScThin), - fontCollection.Get(notoSansJpThin), - fontCollection.Get(notoNaskhArabic), - fontCollection.Get(sarabun), - fontCollection.Get(hind), + inconsolata, + nanumGothicCoding, + cousine, + notoSansScThin, + notoSansJpThin, + notoNaskhArabic, + sarabun, + hind, ], }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_47.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_47.cs index 283dfd5c9..82e40a593 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_47.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_47.cs @@ -14,7 +14,7 @@ public void LeftAlignedTextNewLineShouldNotStartWithWhiteSpace(string text) { Font font = CreateFont("\t x"); - var r = new GlyphRenderer(); + GlyphRenderer r = new(); IReadOnlyList layout = TextLayout.GenerateLayout(text.AsSpan(), new TextOptions(new Font(font, 30)) { @@ -42,7 +42,7 @@ public void NewWrappedLinesShouldNotStartOrEndWithWhiteSpace(string text, Horizo { Font font = CreateFont("\t x"); - var r = new GlyphRenderer(); + GlyphRenderer r = new(); IReadOnlyList layout = TextLayout.GenerateLayout(text.AsSpan(), new TextOptions(new Font(font, 30)) { @@ -69,7 +69,7 @@ public void WhiteSpaceAtStartOfTextShouldNotBeTrimmed() Font font = CreateFont("\t x"); string text = " hello world hello world hello world"; - var r = new GlyphRenderer(); + GlyphRenderer r = new(); IReadOnlyList layout = TextLayout.GenerateLayout(text.AsSpan(), new TextOptions(new Font(font, 30)) { @@ -87,7 +87,7 @@ public void WhiteSpaceAtTheEndOfTextShouldBeTrimmed() Font font = CreateFont("\t x"); string text = "hello world hello world hello world "; - var r = new GlyphRenderer(); + GlyphRenderer r = new(); IReadOnlyList layout = TextLayout.GenerateLayout(text.AsSpan(), new TextOptions(new Font(font, 30)) { @@ -101,7 +101,7 @@ public void WhiteSpaceAtTheEndOfTextShouldBeTrimmed() public static Font CreateFont(string text) { - var fc = (IFontMetricsCollection)new FontCollection(); + IFontMetricsCollection fc = (IFontMetricsCollection)new FontCollection(); Font d = fc.AddMetrics(new FakeFontInstance(text), CultureInfo.InvariantCulture).CreateFont(12); return new Font(d, 1F); } diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_470.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_470.cs index 6f8d0859c..fc94ea829 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_470.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_470.cs @@ -25,17 +25,15 @@ public void Test_Issue_470() string text = stringBuilder.ToString(); FontCollection fontCollection = new(); - string arial = fontCollection.Add(TestFonts.Arial).Name; - string sofia = fontCollection.Add(TestFonts.SofiaSansCondensedLight).Name; - - FontFamily mainFontFamily = fontCollection.Get(arial); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + FontFamily arial = TestFonts.GetFontFamily(fontCollection, TestFonts.Arial); + FontFamily sofia = TestFonts.GetFontFamily(fontCollection, TestFonts.SofiaSansCondensedLight); + Font mainFont = arial.CreateFont(30, FontStyle.Regular); TextOptions options = new(mainFont) { FallbackFontFamilies = [ - fontCollection.Get(sofia), + sofia, ], }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_474.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_474.cs index 78359e5b3..8267f976f 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_474.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_474.cs @@ -14,11 +14,7 @@ public void Test_Issue_474() stringBuilder.AppendLine("Latin: The quick brown fox jumps over the lazy dog."); string text = stringBuilder.ToString(); - FontCollection fontCollection = new(); - string serviceNow = fontCollection.Add(TestFonts.ServiceNowWoff2).Name; - - FontFamily mainFontFamily = fontCollection.Get(serviceNow); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.ServiceNowWoff2, 30); // There are too many metrics to validate here so we just ensure no exceptions are thrown // and the rendering looks correct by inspecting the snapshot. diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_475.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_475.cs index 2659f6f73..6d3901c75 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_475.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_475.cs @@ -13,17 +13,15 @@ public void Test_Issue_475() const string text = "වේගවත් දුඹුරු හිවලා කම්මැලි බල්ලා උඩින් පනී"; FontCollection fontCollection = new(); - string noto = fontCollection.Add(TestFonts.NotoSansRegular).Name; - string sc = fontCollection.Add(TestFonts.NotoSansSCRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(noto); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + FontFamily noto = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansRegular); + FontFamily sc = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansSCRegular); + Font mainFont = noto.CreateFont(30, FontStyle.Regular); TextOptions options = new(mainFont) { FallbackFontFamilies = [ - fontCollection.Get(sc), + sc, ], }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_483.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_483.cs index 7065c602d..fe3e60326 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_483.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_483.cs @@ -11,17 +11,15 @@ public void Test_Issue_483() const string text = "Kannada: ವೇಗವುಳ್ಳ ಕಂದು ನರಿ ಸೋಮಾರಿ ನಾಯಿಯ ಮೇಲೆ ಹಾರುತ್ತದೆ"; FontCollection fontCollection = new(); - string noto = fontCollection.Add(TestFonts.NotoSansRegular).Name; - string kannada = fontCollection.Add(TestFonts.NotoSansKannadaRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(noto); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + FontFamily noto = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansRegular); + FontFamily kannada = TestFonts.GetFontFamily(fontCollection, TestFonts.NotoSansKannadaRegular); + Font mainFont = noto.CreateFont(30, FontStyle.Regular); TextOptions options = new(mainFont) { FallbackFontFamilies = [ - fontCollection.Get(kannada), + kannada, ], }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_484.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_484.cs index 58cd44115..90f6e38b8 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_484.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_484.cs @@ -11,11 +11,7 @@ public void Test_Issue_484() private static void Test_Issue_484_Core() { - FontCollection fontCollection = new(); - string arial = fontCollection.Add(TestFonts.Arial).Name; - - FontFamily arialFamily = fontCollection.Get(arial); - Font arialFont = arialFamily.CreateFont(12, FontStyle.Regular); + Font arialFont = TestFonts.GetFont(TestFonts.Arial, 12); TextOptions textOptions = new(arialFont) { @@ -29,11 +25,7 @@ private static void Test_Issue_484_Core() [Fact] public void Test_Issue_484_B() { - FontCollection fontCollection = new(); - string arial = fontCollection.Add(TestFonts.Arial).Name; - - FontFamily arialFamily = fontCollection.Get(arial); - Font arialFont = arialFamily.CreateFont(12, FontStyle.Regular); + Font arialFont = TestFonts.GetFont(TestFonts.Arial, 12); Parallel.For(0, 10, _ => Test_Issue_484_Core_B(arialFont)); } diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_488.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_488.cs index 3ba02b08e..0e971bfa0 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_488.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_488.cs @@ -10,11 +10,7 @@ public void Test_Issue_488_Sinhala() { const string text = "වේගවත් දුඹුරු හිවලා කම්මැලි බල්ලා උඩින් පනිනවා। සංයුක්ත: ක්‍ෂ ඥ්‍ඤ"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.SinhalaSansRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.SinhalaSansRegular, 30); TextOptions options = new(mainFont); @@ -26,11 +22,7 @@ public void Test_Issue_488_Bengali() { const string text = "দ্রুত বাদামী শিয়াল অলস কুকুরের ওপর লাফ দেয়। সংযুক্ত: ক্ক ত্ত"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.BengaliSansRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.BengaliSansRegular, 30); TextOptions options = new(mainFont); @@ -42,11 +34,7 @@ public void Test_Issue_488_Tibetan() { const string text = "བོད་ཡིག་གི་དཔེ་མཚོན། རྐ རྒ རྔ སྐ"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.TibetanSerifRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.TibetanSerifRegular, 30); TextOptions options = new(mainFont); @@ -58,11 +46,7 @@ public void Test_Issue_488_Myanmar() { const string text = "မြန်မာစာ စမ်းသပ်မှု။ ဗျည်းပေါင်းစုံ က ခ ဂ ဃ င စ ဆ ည့် န့်"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.MyanmarSansRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.MyanmarSansRegular, 30); TextOptions options = new(mainFont); @@ -74,11 +58,7 @@ public void Test_Issue_488_Lao() { const string text = "ໝາຈິ້ງຈອກສີນ້ຳຕານທີ່ວ່ອງໄວກະໂດດຂ້າມໝາຂີ້ຄ້ານ ສະຫຼັບ: ກ່ ງ່ ຍ່"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.LaoSerifRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.LaoSerifRegular, 30); TextOptions options = new(mainFont); @@ -92,11 +72,7 @@ public void Test_Issue_488_Hebrew() // hataf vowels (אֱ), holam (לֹ), hiriq (הִ), meteg with vowels (בָֽ). const string text = "בְּרֵאשִׁית בָּרָא אֱלֹהִים שָׁלוֹם שָׂרָה כָּבוֹד בָֽרְכוּ"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansHebrewRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansHebrewRegular, 30); TextOptions options = new(mainFont); diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_493.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_493.cs index 62451b7fe..61f23d6ad 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_493.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_493.cs @@ -14,11 +14,7 @@ public void Test_Issue_493_Ogham() ᚛ᚐᚅᚋᚐᚇᚐᚅᚈᚐ᚜ """; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansOghamRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansOghamRegular, 30); TextOptions options = new(mainFont) { HintingMode = HintingMode.Standard }; @@ -34,11 +30,7 @@ public void Test_Issue_493_Runic() ᚦᛖᚱᛅᛈᛁᛑᛒᚱᚢᚾᚠᛅᚢᛋ """; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansRunicRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansRunicRegular, 30); TextOptions options = new(mainFont) { HintingMode = HintingMode.Standard }; @@ -50,11 +42,7 @@ public void Test_Issue_493_MgOpenCanonic() { const string text = "the quick brown fox jumps over the lazy dog"; - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.MgOpenCanonicRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.MgOpenCanonicRegular, 30); TextOptions hintOptions = new(mainFont) { HintingMode = HintingMode.Standard }; diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_512.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_512.cs index f508bac6a..f7970b41e 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_512.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_512.cs @@ -10,7 +10,7 @@ public void MissingCffTableThrowsInvalidFontFileExceptionInsteadOfNullReferenceE { const string text = "Hello"; - FontFamily family = new FontCollection().Add(TestFonts.Issues.Issue512_CreateCffGlyphMetrics); + FontFamily family = TestFonts.GetFontFamily(TestFonts.Issues.Issue512_CreateCffGlyphMetrics); Font font = family.CreateFont(12); diff --git a/tests/SixLabors.Fonts.Tests/Native/MacSystemFontsEnumeratorTests.cs b/tests/SixLabors.Fonts.Tests/Native/MacSystemFontsEnumeratorTests.cs index 4b486c6ea..75e367bbf 100644 --- a/tests/SixLabors.Fonts.Tests/Native/MacSystemFontsEnumeratorTests.cs +++ b/tests/SixLabors.Fonts.Tests/Native/MacSystemFontsEnumeratorTests.cs @@ -16,12 +16,12 @@ public void TestReset() return; } - using var enumerator = new MacSystemFontsEnumerator(); - var fonts1 = new HashSet(enumerator); + using MacSystemFontsEnumerator enumerator = new(); + HashSet fonts1 = new(enumerator); Assert.NotEmpty(fonts1); enumerator.Reset(); - var fonts2 = new HashSet(enumerator); + HashSet fonts2 = new(enumerator); Assert.Empty(fonts1.Except(fonts2)); } } diff --git a/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs b/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs index c58627abe..fa1a0514a 100644 --- a/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs +++ b/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Collections; using System.Runtime.InteropServices; namespace SixLabors.Fonts.Tests; @@ -84,7 +85,7 @@ public void CanEnumerateSystemFontMetrics() [Fact] public void CanEnumerateNonGenericSystemFontMetrics() { - System.Collections.IEnumerator enumerator = ((IReadOnlyFontMetricsCollection)SysFontCollection).GetEnumerator(); + IEnumerator enumerator = ((IReadOnlyFontMetricsCollection)SysFontCollection).GetEnumerator(); int count = 0; while (enumerator.MoveNext()) @@ -99,7 +100,7 @@ public void CanEnumerateNonGenericSystemFontMetrics() [Fact] public void CanGetAllMetricsByCulture() { - var collection = (IReadOnlyFontMetricsCollection)SysFontCollection; + IReadOnlyFontMetricsCollection collection = SysFontCollection; FontFamily family = SysFontCollection.Families.First(); IEnumerable metrics = collection.GetAllMetrics(family.Name, family.Culture); @@ -140,22 +141,22 @@ public void SystemFonts_FontFamilyNotFound_ThrowsWithSearchDirectories() if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Assert.Contains(@"Windows\Fonts", exception.Message, StringComparison.OrdinalIgnoreCase); - Assert.Contains(exception.SearchDirectories, e => e.IndexOf(@"Windows\Fonts", StringComparison.OrdinalIgnoreCase) != -1); + Assert.Contains(exception.SearchDirectories, e => e.Contains(@"Windows\Fonts", StringComparison.OrdinalIgnoreCase)); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Assert.Contains(@"/share/fonts/", exception.Message, StringComparison.OrdinalIgnoreCase); - Assert.Contains(exception.SearchDirectories, e => e.IndexOf("share/fonts", StringComparison.OrdinalIgnoreCase) != -1); + Assert.Contains(exception.SearchDirectories, e => e.Contains("share/fonts", StringComparison.OrdinalIgnoreCase)); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Assert.Contains(@"/Library/Fonts/", exception.Message, StringComparison.OrdinalIgnoreCase); - Assert.Contains(exception.SearchDirectories, e => e.IndexOf("Library/Fonts", StringComparison.OrdinalIgnoreCase) != -1); + Assert.Contains(exception.SearchDirectories, e => e.Contains("Library/Fonts", StringComparison.OrdinalIgnoreCase)); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("Android"))) { Assert.Contains(@"/system/fonts/", exception.Message, StringComparison.OrdinalIgnoreCase); - Assert.Contains(exception.SearchDirectories, e => e.IndexOf("/system/fonts/", StringComparison.OrdinalIgnoreCase) != -1); + Assert.Contains(exception.SearchDirectories, e => e.Contains("/system/fonts/", StringComparison.OrdinalIgnoreCase)); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs index 3c20a2318..2b3bf2735 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs @@ -16,14 +16,14 @@ public void SingleAdjustmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType1Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0012\u0014"; // XPlacement should be adjusted by minus 200 for both glyphs. - int[] expectedGlyphIndices = { 20, 22 }; + int[] expectedGlyphIndices = [20, 22]; FontRectangle[] expectedFontRectangles = - { + [ new(275, 1085.9999F, 825, 719), new(1622, 1084.9999F, 978, 704), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -51,14 +51,14 @@ public void SingleAdjustmentPositioning_Format2_Works() string fontFile = TestFonts.GposLookupType1Format2; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0015\u0014"; // second character XPlacement should be adjusted by minus 200 - int[] expectedGlyphIndices = { 23, 22 }; + int[] expectedGlyphIndices = [23, 22]; FontRectangle[] expectedFontRectangles = - { + [ new(322, 1085.9999F, 978, 708), new(1522, 1084.9999F, 978, 704), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -86,15 +86,15 @@ public void PairAdjustmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType2Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0017\u0012\u0014"; // "\u0012\u0014" first XPlacement minus 300 and second YPlacement minus 400. - int[] expectedGlyphIndices = { 25, 20, 22 }; + int[] expectedGlyphIndices = [25, 20, 22]; FontRectangle[] expectedFontRectangles = - { + [ new(322, 1104.9999F, 978, 671), new(1675, 1085.9999F, 825, 719), new(3322, 1484.9999F, 978, 704), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -122,14 +122,14 @@ public void CursiveAttachmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType3Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0012\u0012"; // "\u0012\u0012" characters should overlap. - int[] expectedGlyphIndices = { 20, 20 }; + int[] expectedGlyphIndices = [20, 20]; FontRectangle[] expectedFontRectangles = - { + [ new(475, 1185.9999F, 825, 719), new(575, 1085.9999F, 825, 719), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -157,14 +157,14 @@ public void MarkToBaseAttachmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType4Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0012\u0013"; // "\u0012\u0013" characters should overlap. - int[] expectedGlyphIndices = { 20, 21 }; + int[] expectedGlyphIndices = [20, 21]; FontRectangle[] expectedFontRectangles = - { + [ new(475, 1085.9999F, 825, 719), new(375, 1164.9999F, 825, 709), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -192,14 +192,14 @@ public void MarkToLigatureAttachmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType5Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0012\u0013"; // "\u0012\u0013" characters should overlap. - int[] expectedGlyphIndices = { 20, 21 }; + int[] expectedGlyphIndices = [20, 21]; FontRectangle[] expectedFontRectangles = - { + [ new(475, 1085.9999F, 825, 719), new(375, 1164.9999F, 825, 709), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -227,14 +227,14 @@ public void MarkToMarkAttachmentPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType6Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0012\u0013"; // "\u0012\u0013" characters should overlap. - int[] expectedGlyphIndices = { 20, 21 }; + int[] expectedGlyphIndices = [20, 21]; FontRectangle[] expectedFontRectangles = - { + [ new(475, 1085.9999F, 825, 719), new(375, 1164.9999F, 825, 709), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -262,15 +262,15 @@ public void ContextualPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType7Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016"; // "\u0014\u0015\u0016" XPlacement plus 20. - int[] expectedGlyphIndices = { 22, 23, 24 }; + int[] expectedGlyphIndices = [22, 23, 24]; FontRectangle[] expectedFontRectangles = - { + [ new(342, 1084.9999F, 978, 704), new(1842, 1085.9999F, 978, 708), new(3342, 1108.9999F, 978, 667), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -298,15 +298,15 @@ public void ContextualPositioning_Format2_Works() string fontFile = TestFonts.GposLookupType7Format2; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016"; // "\u0014\u0015\u0016" XPlacement plus 20. - int[] expectedGlyphIndices = { 22, 23, 24 }; + int[] expectedGlyphIndices = [22, 23, 24]; FontRectangle[] expectedFontRectangles = - { + [ new(342, 1084.9999F, 978, 704), new(1842, 1085.9999F, 978, 708), new(3342, 1108.9999F, 978, 667), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -334,16 +334,16 @@ public void ContextualPositioning_Format3_Works() string fontFile = TestFonts.GposLookupType7Format3; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016"; // "\u0014\u0015\u0016" XPlacement plus 20. - int[] expectedGlyphIndices = { 22, 23, 24 }; + int[] expectedGlyphIndices = [22, 23, 24]; FontRectangle[] expectedFontRectangles = - { + [ new(342, 1084.9999F, 978, 704), new(1842, 1085.9999F, 978, 708), new(3342, 1108.9999F, 978, 667), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -371,18 +371,18 @@ public void ChainedContextsPositioning_Format1_Works() string fontFile = TestFonts.GposLookupType8Format1; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); // "\u0014\u0015\u0016\u0017" backtrack:\u0014, input:\u0015\u0016, lookahead:u0017 -> XPlacement plus 200. string testStr = "\u0014\u0015\u0016\u0017"; - int[] expectedGlyphIndices = { 22, 23, 24, 25 }; + int[] expectedGlyphIndices = [22, 23, 24, 25]; FontRectangle[] expectedFontRectangles = - { + [ new(322, 1084.9999F, 978, 704), new(2022, 1085.9999F, 978, 708), new(3522, 1108.9999F, 978, 667), new(4822, 1104.9999F, 978, 671), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -410,18 +410,18 @@ public void ChainedContextsPositioning_Format2_Works() string fontFile = TestFonts.GposLookupType8Format2; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); // "\u0014\u0015\u0016\u0017" backtrack:\u0014, input:\u0015\u0016, lookahead:u0017 -> XPlacement plus 200. string testStr = "\u0014\u0015\u0016\u0017"; - int[] expectedGlyphIndices = { 22, 23, 24, 25 }; + int[] expectedGlyphIndices = [22, 23, 24, 25]; FontRectangle[] expectedFontRectangles = - { + [ new(322, 1084.9999F, 978, 704), new(2022, 1085.9999F, 978, 708), new(3522, 1108.9999F, 978, 667), new(4822, 1104.9999F, 978, 671), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -449,18 +449,18 @@ public void ChainedContextsPositioning_Format3_Works() string fontFile = TestFonts.GposLookupType8Format3; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); // "\u0014\u0015\u0016\u0017" backtrack:\u0014, input:\u0015\u0016, lookahead:u0017 -> XPlacement plus 200. string testStr = "\u0014\u0015\u0016\u0017"; - int[] expectedGlyphIndices = { 22, 23, 24, 25 }; + int[] expectedGlyphIndices = [22, 23, 24, 25]; FontRectangle[] expectedFontRectangles = - { + [ new(322, 1084.9999F, 978, 704), new(2022, 1085.9999F, 978, 708), new(3522, 1108.9999F, 978, 667), new(4822, 1104.9999F, 978, 671), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -486,15 +486,15 @@ public void MarkAnchoring_Works() string fontFile = TestFonts.TimesNewRomanFile; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0644\u0651"; // /lam-arab/arabicshaddacomb - int[] expectedGlyphIndices = { 759, 989 }; + int[] expectedGlyphIndices = [759, 989]; FontRectangle[] expectedFontRectangles = - { + [ new(246, 23.5F, 363, 322), new(71, 84.5F, 966, 1573), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -521,16 +521,16 @@ public void MarkToMarkAttachment_Works() string fontFile = TestFonts.MeQuranFile; ushort upem = ReadFontUpem(fontFile); Font font = new FontCollection().Add(fontFile).CreateFont(upem); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0631\u0651\u064E"; - int[] expectedGlyphIndices = { 47, 50, 23 }; + int[] expectedGlyphIndices = [47, 50, 23]; FontRectangle[] expectedFontRectangles = - { + [ new(345, 182, 561, 461), new(420, 621, 447, 414), new(40, 1298, 1002, 986), - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); diff --git a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs index 78fb7173d..4f51697ae 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs @@ -13,12 +13,7 @@ public partial class GSubTableTests { private readonly Font hangulFontCFF = CreateHangulFont(); - private static Font CreateHangulFont() - { - var collection = new FontCollection(); - FontFamily family = collection.Add(TestFonts.NotoSansKRRegular); - return family.CreateFont(12); - } + private static Font CreateHangulFont() => TestFonts.GetFont(TestFonts.NotoSansKRRegular, 12); [Fact] public void ShouldUseComposedSyllablesCFF() @@ -26,7 +21,7 @@ public void ShouldUseComposedSyllablesCFF() // arrange const string input = "\uD734\uAC00\u0020\uAC00\u002D\u002D\u0020\u0028\uC624\u002D\u002D\u0029"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 21324, 10264, 1, 10264, 14, 14, 1, 9, 16956, 14, 14, 10 }; + int[] expectedGlyphIndices = [21324, 10264, 1, 10264, 14, 14, 1, 9, 16956, 14, 14, 10]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontCFF)); @@ -45,7 +40,7 @@ public void ShouldComposeDecomposedSyllablesCFF() // arrange const string input = "\u1112\u1172\u1100\u1161\u0020\u1100\u1161\u002D\u002D\u0020\u0028\u110B\u1169\u002D\u002D\u0029"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 21324, 10264, 1, 10264, 14, 14, 1, 9, 16956, 14, 14, 10 }; + int[] expectedGlyphIndices = [21324, 10264, 1, 10264, 14, 14, 1, 9, 16956, 14, 14, 10]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontCFF)); @@ -64,7 +59,7 @@ public void ShouldUseOTFeaturesForNonCombining_L_V_T_CFF() // arrange const string input = "\ua960\ud7b0\ud7cb"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 23511, 23860, 24202 }; + int[] expectedGlyphIndices = [23511, 23860, 24202]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontCFF)); @@ -86,7 +81,7 @@ public void ShouldDecompose_LV_T_To_L_V_T_If_LVT_IsNotSupportedCFF() // arrange const string input = "\u1100\u1161\ud7cb"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 23168, 23789, 24065 }; + int[] expectedGlyphIndices = [23168, 23789, 24065]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontCFF)); @@ -105,7 +100,7 @@ public void ShouldReorderToneMarksToBeginningOf_L_V_SyllablesCFF() // arrange const string input = "\ua960\ud7b0\u302f"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 1443, 23759, 23954 }; + int[] expectedGlyphIndices = [1443, 23759, 23954]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontCFF)); @@ -127,7 +122,7 @@ public void ShouldUseComposedSyllablesTTF() // arrange const string input = "\uD734\uAC00\u0020\uAC00\u002D\u002D\u0020\u0028\uC624\u002D\u002D\u0029"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 2953, 636, 3, 636, 16, 16, 3, 11, 2077, 16, 16, 12 }; + int[] expectedGlyphIndices = [2953, 636, 3, 636, 16, 16, 3, 11, 2077, 16, 16, 12]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -146,7 +141,7 @@ public void ShouldComposeDecomposedSyllablesTTF() // arrange const string input = "\u1112\u1172\u1100\u1161\u0020\u1100\u1161\u002D\u002D\u0020\u0028\u110B\u1169\u002D\u002D\u0029"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 2953, 636, 3, 636, 16, 16, 3, 11, 2077, 16, 16, 12 }; + int[] expectedGlyphIndices = [2953, 636, 3, 636, 16, 16, 3, 11, 2077, 16, 16, 12]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -165,7 +160,7 @@ public void ShouldUseOTFeaturesForNonCombining_L_V_T_TTF() // arrange const string input = "\ua960\ud7b0\ud7cb"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 21150, 21436, 21569 }; + int[] expectedGlyphIndices = [21150, 21436, 21569]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -187,7 +182,7 @@ public void ShouldDecompose_LV_T_To_L_V_T_If_LVT_IsNotSupportedTTF() // arrange const string input = "\u1100\u1161\ud7cb"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 20667, 21294, 21569 }; + int[] expectedGlyphIndices = [20667, 21294, 21569]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -206,7 +201,7 @@ public void ShouldReorderToneMarksToBeginningOf_L_V_SyllablesTTF() // arrange const string input = "\ua960\ud7b0\u302f"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 20665, 21150, 21435 }; + int[] expectedGlyphIndices = [20665, 21150, 21435]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -225,7 +220,7 @@ public void ShouldReorderToneMarksToBeginningOf_L_V_T_Syllables() // arrange const string input = "\ua960\ud7b0\ud7cb\u302f"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 20665, 21150, 21436, 21569 }; + int[] expectedGlyphIndices = [20665, 21150, 21436, 21569]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -244,7 +239,7 @@ public void ShouldReorderToneMarksToBeginningOf_LV_Syllables() // arrange const string input = "\uac00\u302f"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 20665, 636 }; + int[] expectedGlyphIndices = [20665, 636]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -263,7 +258,7 @@ public void ShouldReorderToneMarksToBeginningOf_LVT_Syllables() // arrange const string input = "\uac01\u302f"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 20665, 637 }; + int[] expectedGlyphIndices = [20665, 637]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); @@ -282,7 +277,7 @@ public void ShouldInsertDottedCircleForInvalidToneMarks() // arrange const string input = "\u1100\u302f\u1161"; ColorGlyphRenderer renderer = new(); - int[] expectedGlyphIndices = { 2986, 20665, 21620, 3078 }; + int[] expectedGlyphIndices = [2986, 20665, 21620, 3078]; // act TextRenderer.RenderTextTo(renderer, input, new TextOptions(this.hangulFontTTF)); diff --git a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs index 495cc21c2..ac5f2cc22 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs @@ -41,8 +41,8 @@ public partial class GSubTableTests public void RenderArabicCharacters_WithIsolatedForm_Works(string testStr, int expectedGlyphIndex) { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + Font arabicFont = TestFonts.GetFont(TestFonts.ArabicFontFile, 8); + ColorGlyphRenderer renderer = new(); // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -58,8 +58,8 @@ public void RenderArabicCharacters_WithIsolatedForm_Works(string testStr, int ex public void SingleSubstitution_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "A"; int expectedGlyphIndex = 38; // we expect A to be mapped to B. @@ -75,10 +75,10 @@ public void SingleSubstitution_Works() public void ContextualFractions_WithFractionSlash_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.RobotoRegular).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.RobotoRegular, 12); + ColorGlyphRenderer renderer = new(); string testStr = "9⁄2"; - int[] expectedGlyphIndices = { 580, 404, 453 }; + int[] expectedGlyphIndices = [580, 404, 453]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { FeatureTags.Numerators, FeatureTags.Denominators } }); @@ -95,10 +95,10 @@ public void ContextualFractions_WithFractionSlash_Works() public void ContextualFractions_WithSlash_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.RobotoRegular).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.RobotoRegular, 12); + ColorGlyphRenderer renderer = new(); string testStr = "9/2"; - int[] expectedGlyphIndices = { 580, 404, 453 }; + int[] expectedGlyphIndices = [580, 404, 453]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) { FeatureTags = new Tag[] { FeatureTags.Fractions } }); @@ -117,8 +117,8 @@ public void ContextualFractions_WithSlash_Works() public void MultipleSubstitution_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "C"; int expectedGlyphIndex = 40; // we expect C to be mapped to D. @@ -136,8 +136,8 @@ public void MultipleSubstitution_Works() public void AlternateSubstitution_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "E"; int expectedGlyphIndex = 42; // we expect E to be mapped to F. @@ -155,8 +155,8 @@ public void AlternateSubstitution_Works() public void LigatureSubstitution_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "ffi"; int expectedGlyphIndex = 229; @@ -174,10 +174,10 @@ public void LigatureSubstitution_Works() public void ContextualSubstitution_Format1_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType5Format1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042"; // "6566" (\u0041\u0042) -> "6576" - int[] expectedGlyphIndices = { 3, 7 }; + int[] expectedGlyphIndices = [3, 7]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -196,10 +196,10 @@ public void ContextualSubstitution_Format1_Works() public void ContextualSubstitution_Format2_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType5Format2, 12); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042"; // "6566" (\u0041\u0042) -> "6576" - int[] expectedGlyphIndices = { 3, 7 }; + int[] expectedGlyphIndices = [3, 7]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -218,10 +218,10 @@ public void ContextualSubstitution_Format2_Works() public void ContextualSubstitution_Format3_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format3).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType5Format3, 12); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042\u0043\u0044"; // "65666768" -> "657678" - int[] expectedGlyphIndices = { 67, 78, 80 }; + int[] expectedGlyphIndices = [67, 78, 80]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -240,10 +240,10 @@ public void ContextualSubstitution_Format3_Works() public void ChainedContextsSubstitution_Format1_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType6Format1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType6Format1, 12); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016\u0017"; // "20212223" -> "20636423" - int[] expectedGlyphIndices = { 22, 63, 64, 25 }; + int[] expectedGlyphIndices = [22, 63, 64, 25]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -262,10 +262,10 @@ public void ChainedContextsSubstitution_Format1_Works() public void ChainedContextsSubstitution_Format2_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType6Format2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType6Format2, 12); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016\u0017"; // "20212223" -> "20216423" - int[] expectedGlyphIndices = { 22, 23, 64, 25 }; + int[] expectedGlyphIndices = [22, 23, 64, 25]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -284,10 +284,10 @@ public void ChainedContextsSubstitution_Format2_Works() public void ChainedContextsSubstitution_Format3_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile2, 12); + ColorGlyphRenderer renderer = new(); string testStr = "x=y"; // This should be replaced with "x>y". - int[] expectedGlyphIndices = { 89, 31, 90 }; + int[] expectedGlyphIndices = [89, 31, 90]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -306,10 +306,10 @@ public void ChainedContextsSubstitution_Format3_Works() public void ChainedContextsSubstitution_Format3_WithCursiveScript_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.FormalScript).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.FormalScript, 12); + ColorGlyphRenderer renderer = new(); string testStr = "ba"; // Characters following b should have a special form and should be replaced. - int[] expectedGlyphIndices = { 69, 102 }; + int[] expectedGlyphIndices = [69, 102]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -328,10 +328,10 @@ public void ChainedContextsSubstitution_Format3_WithCursiveScript_Works() public void ReverseChainingContextualSingleSubstitution_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.GSubTestFontFile2, 12); + ColorGlyphRenderer renderer = new(); string testStr = "X89"; // X89 -> XYZ - int[] expectedGlyphIndices = { 57, 58, 59 }; + int[] expectedGlyphIndices = [57, 58, 59]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font)); @@ -349,10 +349,10 @@ public void ReverseChainingContextualSingleSubstitution_Works() public void OldStyleFiguresFeature_Works() { // arrange - Font font = new FontCollection().Add(TestFonts.EbGaramond).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font font = TestFonts.GetFont(TestFonts.EbGaramond, 12); + ColorGlyphRenderer renderer = new(); string testStr = "123456"; - int[] expectedGlyphIndices = { 2242, 2243, 2244, 2245, 2246, 2247 }; + int[] expectedGlyphIndices = [2242, 2243, 2244, 2245, 2246, 2247]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(font) @@ -372,7 +372,7 @@ public void OldStyleFiguresFeature_Works() public void BillionLaughsAttackDoesNotThrowException() { // Arrange - Font font = new FontCollection().Add(TestFonts.GSubLookupType2BillionLaughs).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.GSubLookupType2BillionLaughs, 12); // Act TextMeasurer.MeasureSize("lol", new TextOptions(font)); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs index a96f873a7..0f17fb987 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs @@ -12,7 +12,7 @@ public class Format0SubTableTests [Fact] public void LoadFormat0() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); // int subtableCount = 1; writer.WriteCMapSubTable( @@ -20,7 +20,7 @@ public void LoadFormat0() 0, PlatformIDs.Windows, 2, - new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 })); + [1, 2, 3, 4, 5, 6, 7, 8])); BigEndianBinaryReader reader = writer.GetReader(); ushort format = reader.ReadUInt16(); // read format before we pass along as that's what the cmap table does @@ -39,7 +39,7 @@ public void LoadFormat0() [Fact] public void GetCharacter() { - var format = new Format0SubTable(0, PlatformIDs.Windows, 2, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }); + Format0SubTable format = new(0, PlatformIDs.Windows, 2, [1, 2, 3, 4, 5, 6, 7, 8]); bool found = format.TryGetGlyphId(new CodePoint(4), out ushort id); @@ -50,7 +50,7 @@ public void GetCharacter() [Fact] public void GetCharacter_missing() { - var format = new Format0SubTable(0, PlatformIDs.Windows, 2, new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }); + Format0SubTable format = new(0, PlatformIDs.Windows, 2, [1, 2, 3, 4, 5, 6, 7, 8]); bool found = format.TryGetGlyphId(new CodePoint(99), out ushort id); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format4SubTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format4SubTableTests.cs index 1cdcb16c1..fca14f0f0 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format4SubTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format4SubTableTests.cs @@ -12,7 +12,7 @@ public class Format4SubTableTests [Fact] public void LoadFormat4() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); // int subtableCount = 1; writer.WriteCMapSubTable( @@ -20,8 +20,8 @@ public void LoadFormat4() 0, PlatformIDs.Windows, 2, - new[] { new Format4SubTable.Segment(0, 1, 2, 3, 4) }, - new ushort[] { 1, 2, 3, 4, 5, 6, 7, 8 })); + [new Format4SubTable.Segment(0, 1, 2, 3, 4)], + [1, 2, 3, 4, 5, 6, 7, 8])); BigEndianBinaryReader reader = writer.GetReader(); ushort format = reader.ReadUInt16(); // read format before we pass along as that's what the cmap table does @@ -62,16 +62,16 @@ public void GetCharacter(int src, int expected, bool expectedFound) // startCode: 10 30 153 0xffff // dDelta: -9 -18 -27 1 // idRangeOffset: 0 0 0 0 - ushort[] glyphs = Enumerable.Range(0, expected).Select(x => (ushort)x).ToArray(); + ushort[] glyphs = [.. Enumerable.Range(0, expected).Select(x => (ushort)x)]; - Format4SubTable.Segment[] segments = new[] - { + Format4SubTable.Segment[] segments = + [ new Format4SubTable.Segment(0, 20, 10, -9, 0), new Format4SubTable.Segment(1, 90, 30, -18, 0), new Format4SubTable.Segment(2, 480, 153, -27, 0), - }; + ]; - var table = new Format4SubTable( + Format4SubTable table = new( 0, PlatformIDs.Windows, 0, diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs index b7e351d6e..fb94270b9 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs @@ -12,32 +12,32 @@ public class CMapTableTests [Fact] public void LoadFormat0() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteCMapTable(new[] { - new Format0SubTable(0, PlatformIDs.Windows, 9, new byte[] { 0, 1, 2 }) + new Format0SubTable(0, PlatformIDs.Windows, 9, [0, 1, 2]) }); - var table = CMapTable.Load(writer.GetReader()); + CMapTable table = CMapTable.Load(writer.GetReader()); Assert.Single(table.Tables.Where(x => x != null)); - Format0SubTable[] format0Tables = table.Tables.OfType().ToArray(); + Format0SubTable[] format0Tables = [.. table.Tables.OfType()]; Assert.Single(format0Tables); } [Fact] public void ShouldThrowExceptionWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (System.IO.MemoryStream stream = writer.GetStream()) { InvalidFontTableException exception = Assert.Throws(() => { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); CMapTable.Load(reader); }); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/ColrTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/ColrTableTests.cs index 7f60b602a..8d74078bb 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/ColrTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/ColrTableTests.cs @@ -11,12 +11,12 @@ public class ColrTableTests [Fact] public void ShouldReturnNullWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); Assert.Null(ColrTable.Load(reader)); } } @@ -24,10 +24,10 @@ public void ShouldReturnNullWhenTableCouldNotBeFound() [Fact] public void ShouldReturnTableValues() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); - writer.WriteColrTable(new[] - { + writer.WriteColrTable( + [ new ColrGlyphRecord { Glyph = 1, @@ -46,11 +46,11 @@ public void ShouldReturnTableValues() new ColrLayerRecord { Glyph = 13, Palette = 2 } } } - }); + ]); using (Stream stream = TestFonts.TwemojiMozillaData()) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); ColrTable tbl = reader.GetTable(); Span layers = tbl.GetLayers(15); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/CompositeGlyphLoaderTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/CompositeGlyphLoaderTests.cs index 087951bbd..8926661f1 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/CompositeGlyphLoaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/CompositeGlyphLoaderTests.cs @@ -11,7 +11,7 @@ public class CompositeGlyphLoaderTests [Fact] public void LoadSingleGlyphWithUInt16Offset_unsigned_short() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteUInt16((ushort)CompositeGlyphFlags.Args1And2AreWords); // 16bit unsigned writer.WriteUInt16(1); // glyph id @@ -19,13 +19,13 @@ public void LoadSingleGlyphWithUInt16Offset_unsigned_short() writer.WriteUInt16(short.MaxValue + 2); // dy writer.GetReader(); - var bounds = new Bounds(0, 0, 100, 100); - var glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); + Bounds bounds = new(0, 0, 100, 100); + CompositeGlyphLoader glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); - var tbl = new GlyphTable(new[] + GlyphTable tbl = new(new[] { new SimpleGlyphLoader(bounds), // padding - new SimpleGlyphLoader(new ControlPoint[] { new(new Vector2(20, 21), true) }, new ushort[] { 1 }, bounds, Array.Empty()) + new SimpleGlyphLoader([new(new Vector2(20, 21), true)], [1], bounds, Array.Empty()) }); GlyphVector finalGlyph = glyph.CreateGlyph(tbl); @@ -37,7 +37,7 @@ public void LoadSingleGlyphWithUInt16Offset_unsigned_short() [Fact] public void LoadSingleGlyphWithInt16Offset_signed_short() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteUInt16((ushort)(CompositeGlyphFlags.Args1And2AreWords /* 16bit */ | CompositeGlyphFlags.ArgsAreXYValues /* signed */)); // flags writer.WriteUInt16(1); // glyph id @@ -45,13 +45,13 @@ public void LoadSingleGlyphWithInt16Offset_signed_short() writer.WriteInt16(short.MinValue + 2); // dy writer.GetReader(); - var bounds = new Bounds(0, 0, 100, 100); - var glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); + Bounds bounds = new(0, 0, 100, 100); + CompositeGlyphLoader glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); - var tbl = new GlyphTable(new[] + GlyphTable tbl = new(new[] { new SimpleGlyphLoader(bounds), // padding - new SimpleGlyphLoader(new ControlPoint[] { new(new Vector2(20, 21), true) }, new ushort[] { 1 }, bounds, Array.Empty()) + new SimpleGlyphLoader([new(new Vector2(20, 21), true)], [1], bounds, Array.Empty()) }); GlyphVector finalGlyph = glyph.CreateGlyph(tbl); @@ -63,7 +63,7 @@ public void LoadSingleGlyphWithInt16Offset_signed_short() [Fact] public void LoadSingleGlyphWithUInt8Offset_unsigned_byte() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteUInt16(0); // 8bit unsigned writer.WriteUInt16(1); // glyph id @@ -71,13 +71,13 @@ public void LoadSingleGlyphWithUInt8Offset_unsigned_byte() writer.WriteUInt8(sbyte.MaxValue + 2); // dy writer.GetReader(); - var bounds = new Bounds(0, 0, 100, 100); - var glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); + Bounds bounds = new(0, 0, 100, 100); + CompositeGlyphLoader glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); - var tbl = new GlyphTable(new[] + GlyphTable tbl = new(new[] { new SimpleGlyphLoader(bounds), // padding - new SimpleGlyphLoader(new ControlPoint[] { new(new Vector2(20, 21), true) }, new ushort[] { 1 }, bounds, Array.Empty()) + new SimpleGlyphLoader([new(new Vector2(20, 21), true)], [1], bounds, Array.Empty()) }); GlyphVector finalGlyph = glyph.CreateGlyph(tbl); @@ -89,7 +89,7 @@ public void LoadSingleGlyphWithUInt8Offset_unsigned_byte() [Fact] public void LoadSingleGlyphWithInt8Offset_signed_byte() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteUInt16((ushort)CompositeGlyphFlags.ArgsAreXYValues); // signed byte writer.WriteUInt16(1); // glyph id @@ -97,13 +97,13 @@ public void LoadSingleGlyphWithInt8Offset_signed_byte() writer.WriteInt8(sbyte.MinValue + 2); // dy writer.GetReader(); - var bounds = new Bounds(0, 0, 100, 100); - var glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); + Bounds bounds = new(0, 0, 100, 100); + CompositeGlyphLoader glyph = CompositeGlyphLoader.LoadCompositeGlyph(writer.GetReader(), in bounds); - var tbl = new GlyphTable(new[] + GlyphTable tbl = new(new[] { new SimpleGlyphLoader(bounds), // padding - new SimpleGlyphLoader(new ControlPoint[] { new(new Vector2(20, 21), true) }, new ushort[] { 1 }, bounds, Array.Empty()) + new SimpleGlyphLoader([new(new Vector2(20, 21), true)], [1], bounds, Array.Empty()) }); GlyphVector finalGlyph = glyph.CreateGlyph(tbl); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs index 15ecd0085..62363f749 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs @@ -12,13 +12,13 @@ public class GlyphVectorTests public void CloneIsDeep() { // arrange - ControlPoint[] controlPoints = { new(new Vector2(1.0f), true), new(new Vector2(2.0f), false) }; - ushort[] endPoints = { 1, 2, 3 }; - var bounds = new Bounds(1.0f, 2.0f, 3.0f, 4.0f); - var outline = new GlyphVector(controlPoints, endPoints, bounds, Array.Empty(), false); + ControlPoint[] controlPoints = [new(new Vector2(1.0f), true), new(new Vector2(2.0f), false)]; + ushort[] endPoints = [1, 2, 3]; + Bounds bounds = new(1.0f, 2.0f, 3.0f, 4.0f); + GlyphVector outline = new(controlPoints, endPoints, bounds, Array.Empty(), false); // act - var clone = GlyphVector.DeepClone(outline); + GlyphVector clone = GlyphVector.DeepClone(outline); // assert Assert.False(outline.ControlPoints.Equals(clone.ControlPoints)); @@ -31,11 +31,11 @@ public void CloneIsDeep() public void TtfOffsetXy_Works() { // arrange - ControlPoint[] controlPoints = { new(new Vector2(1.0f), true), new(new Vector2(2.0f), false) }; - ushort[] endPoints = { 1, 2, 3 }; - var bounds = new Bounds(1.0f, 2.0f, 3.0f, 4.0f); - var expectedBounds = new Bounds(11.0f, 12.0f, 13.0f, 14.0f); - var glyphVector = new GlyphVector(controlPoints, endPoints, bounds, Array.Empty(), false); + ControlPoint[] controlPoints = [new(new Vector2(1.0f), true), new(new Vector2(2.0f), false)]; + ushort[] endPoints = [1, 2, 3]; + Bounds bounds = new(1.0f, 2.0f, 3.0f, 4.0f); + Bounds expectedBounds = new(11.0f, 12.0f, 13.0f, 14.0f); + GlyphVector glyphVector = new(controlPoints, endPoints, bounds, Array.Empty(), false); // act Matrix3x2 matrix = Matrix3x2.Identity; @@ -52,7 +52,7 @@ public void TtfTransformWith2x2Matrix_Works() // arrange const float precision = 2F; ControlPoint[] controlPoints = - { + [ new(new Vector2(653.0f, 791.0f), true), new(new Vector2(1065.0f, 791.0f), false), new(new Vector2(1065.0f, 653.0f), true), @@ -69,12 +69,12 @@ public void TtfTransformWith2x2Matrix_Works() new(new Vector2(104.0f, 139.0f), false), new(new Vector2(1065.0f, 139.0f), true), new(new Vector2(1065.0f, 1.0f), false), - }; + ]; - ushort[] endPoints = { 1, 2, 3 }; - var bounds = new Bounds(16130.0f, 260.0f, 26624.0f, 28928.0f); - var expectedBounds = new Bounds(19876f, 013684f, 89804.8f, 108083.2f); - var glyphVector = new GlyphVector(controlPoints, endPoints, bounds, Array.Empty(), false); + ushort[] endPoints = [1, 2, 3]; + Bounds bounds = new(16130.0f, 260.0f, 26624.0f, 28928.0f); + Bounds expectedBounds = new(19876f, 013684f, 89804.8f, 108083.2f); + GlyphVector glyphVector = new(controlPoints, endPoints, bounds, Array.Empty(), false); // act Matrix3x2 matrix = Matrix3x2.Identity; diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/HeadTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/HeadTableTests.cs index a6027be1a..c93b3b5c0 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/HeadTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/HeadTableTests.cs @@ -10,7 +10,7 @@ public class HeadTableTests [Fact] public void LoadHead() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteHeadTable(new HeadTable( HeadTable.HeadFlags.None, @@ -22,7 +22,7 @@ public void LoadHead() 0, HeadTable.IndexLocationFormats.Offset16)); - var head = HeadTable.Load(writer.GetReader()); + HeadTable head = HeadTable.Load(writer.GetReader()); Assert.Equal(HeadTable.HeadFlags.None, head.Flags); Assert.Equal(HeadTable.HeadMacStyle.Italic | HeadTable.HeadMacStyle.Bold, head.MacStyle); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/HorizontalHeadTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/HorizontalHeadTableTests.cs index 95d55403a..0458447e3 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/HorizontalHeadTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/HorizontalHeadTableTests.cs @@ -10,11 +10,11 @@ public class HorizontalHeadTableTests [Fact] public void LoadHorizontalHeadTable() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteHorizontalHeadTable(new HorizontalHeadTable(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); - var tbl = HorizontalHeadTable.Load(writer.GetReader()); + HorizontalHeadTable tbl = HorizontalHeadTable.Load(writer.GetReader()); Assert.Equal(1, tbl.Ascender); Assert.Equal(2, tbl.Descender); @@ -32,12 +32,12 @@ public void LoadHorizontalHeadTable() [Fact] public void ShouldReturnNullWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); Assert.Null(HorizontalHeadTable.Load(reader)); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/IndexLocationTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/IndexLocationTableTests.cs index 1052cc059..33d21535b 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/IndexLocationTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/IndexLocationTableTests.cs @@ -12,14 +12,14 @@ public class IndexLocationTableTests [Fact] public void ShouldThrowExceptionWhenHeadTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { MissingFontTableException exception = Assert.Throws(() => { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); IndexLocationTable.Load(reader); }); @@ -30,7 +30,7 @@ public void ShouldThrowExceptionWhenHeadTableCouldNotBeFound() [Fact] public void ShouldThrowExceptionWhenMaximumProfileTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(new TableHeader("head", 0, 0, 0)); writer.WriteHeadTable(new HeadTable( @@ -47,7 +47,7 @@ public void ShouldThrowExceptionWhenMaximumProfileTableCouldNotBeFound() { InvalidFontTableException exception = Assert.Throws(() => { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); IndexLocationTable.Load(reader); }); @@ -58,7 +58,7 @@ public void ShouldThrowExceptionWhenMaximumProfileTableCouldNotBeFound() [Fact] public void ShouldReturnNullWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(new TableHeader("head", 0, 0, 0), new TableHeader("maxp", 0, 0, 0)); writer.WriteHeadTable(new HeadTable( @@ -73,7 +73,7 @@ public void ShouldReturnNullWhenTableCouldNotBeFound() using (MemoryStream stream = writer.GetStream()) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); Assert.Null(IndexLocationTable.Load(reader)); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/KerningTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/KerningTableTests.cs index b0183591a..566a6ec99 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/KerningTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/KerningTableTests.cs @@ -10,13 +10,13 @@ public class KerningTableTests [Fact] public void ShouldReturnDefaultValueWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { - using var reader = new FontReader(stream); - var table = KerningTable.Load(reader); + using FontReader reader = new(stream); + KerningTable table = KerningTable.Load(reader); Assert.NotNull(table); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/MaximumProfileTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/MaximumProfileTableTests.cs index 54f123d68..fae3a0f45 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/MaximumProfileTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/MaximumProfileTableTests.cs @@ -10,14 +10,14 @@ public class MaximumProfileTableTests [Fact] public void ShouldThrowExceptionWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { InvalidFontTableException exception = Assert.Throws(() => { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); MaximumProfileTable.Load(reader); }); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/NameTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/NameTableTests.cs index 25cec2c70..334fb2500 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/NameTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/NameTableTests.cs @@ -12,7 +12,7 @@ public class NameTableTests [Fact] public void LoadFormat0() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteNameTable( new Dictionary @@ -26,7 +26,7 @@ public void LoadFormat0() { (KnownNameIds)91, "other2" } }); - var table = NameTable.Load(writer.GetReader()); + NameTable table = NameTable.Load(writer.GetReader()); Assert.Equal("fullname", table.FontName(CultureInfo.InvariantCulture)); Assert.Equal("family", table.FontFamilyName(CultureInfo.InvariantCulture)); @@ -40,7 +40,7 @@ public void LoadFormat0() [Fact] public void LoadFormat1() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteNameTable( new Dictionary @@ -53,13 +53,12 @@ public void LoadFormat1() { (KnownNameIds)90, "other1" }, { (KnownNameIds)91, "other2" } }, - new List - { + [ "lang1", "lang2" - }); + ]); - var table = NameTable.Load(writer.GetReader()); + NameTable table = NameTable.Load(writer.GetReader()); Assert.Equal("fullname", table.FontName(CultureInfo.InvariantCulture)); Assert.Equal("family", table.FontFamilyName(CultureInfo.InvariantCulture)); @@ -73,14 +72,14 @@ public void LoadFormat1() [Fact] public void ShouldThrowExceptionWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { InvalidFontTableException exception = Assert.Throws(() => { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); NameTable.Load(reader); }); diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/Os2TableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/Os2TableTests.cs index cfa4a2f00..137e02155 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/Os2TableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/Os2TableTests.cs @@ -10,12 +10,12 @@ public class OS2TableTests [Fact] public void ShouldReturnNullWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using (MemoryStream stream = writer.GetStream()) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); Assert.Null(OS2Table.Load(reader)); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/VerticalHeadTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/VerticalHeadTableTests.cs index 5ea44e76a..6c2714d3f 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/VerticalHeadTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/VerticalHeadTableTests.cs @@ -10,11 +10,11 @@ public class VerticalHeadTableTests [Fact] public void LoadVerticalHeadTable() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteVerticalHeadTable(new VerticalHeadTable(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); - var tbl = VerticalHeadTable.Load(writer.GetReader()); + VerticalHeadTable tbl = VerticalHeadTable.Load(writer.GetReader()); Assert.Equal(1, tbl.Ascender); Assert.Equal(2, tbl.Descender); @@ -32,11 +32,11 @@ public void LoadVerticalHeadTable() [Fact] public void ShouldReturnNullWhenTableCouldNotBeFound() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); using MemoryStream stream = writer.GetStream(); - using var reader = new FontReader(stream); + using FontReader reader = new(stream); Assert.Null(VerticalHeadTable.Load(reader)); } } diff --git a/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs b/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs index 9e815ff1e..365b7a231 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs @@ -18,10 +18,10 @@ public class TableHeaderTests [MemberData(nameof(ReadAllValuesData))] public void ReadAllValues(string tag, uint checksum, uint offset, uint length) { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTableHeader(tag, checksum, offset, length); - var header = TableHeader.Read(writer.GetReader()); + TableHeader header = TableHeader.Read(writer.GetReader()); Assert.Equal(checksum, header.CheckSum); Assert.Equal(length, header.Length); diff --git a/tests/SixLabors.Fonts.Tests/Tables/TableLoaderTests.cs b/tests/SixLabors.Fonts.Tests/Tables/TableLoaderTests.cs index 5682e0b8b..3dbe0c313 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/TableLoaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/TableLoaderTests.cs @@ -27,7 +27,7 @@ public static IEnumerable RegisterableTableTypes [MemberData(nameof(RegisterableTableTypes))] public void AllNamedTablesAreRegistered(Type type, string name) { - var tl = new TableLoader(); + TableLoader tl = new(); Assert.Contains(type, tl.RegisteredTypes()); Assert.Equal(name, tl.GetTag(type)); } @@ -38,7 +38,7 @@ public void AllNamedTablesAreRegistered(Type type, string name) [Fact] public void TryingToLoadUnregisteredTagReturnsUnknownTable() { - var loader = new TableLoader(); + TableLoader loader = new(); string tag = Guid.NewGuid().ToString(); Table result = loader.Load(tag, null); @@ -50,7 +50,7 @@ public void TryingToLoadUnregisteredTagReturnsUnknownTable() [Fact] public void NullForUnknownTypes() { - var loader = new TableLoader(); + TableLoader loader = new(); string tag = loader.GetTag(typeof(TableLoaderTests)); Assert.Null(tag); } diff --git a/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationFontTests.cs b/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationFontTests.cs index c2d9458ae..6041767a1 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationFontTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationFontTests.cs @@ -30,12 +30,12 @@ public void FontVariation_InvalidTagLength_ThrowsArgumentException() [Fact] public void FontVariation_NullTag_ThrowsArgumentException() - => Assert.ThrowsAny(() => new FontVariation(null!, 700)); + => Assert.ThrowsAny(() => new FontVariation(null, 700)); [Fact] public void CanCreateFontWithVariations() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font baseFont = family.CreateFont(12); Font variedFont = new(baseFont, new FontVariation("wght", 700)); @@ -48,7 +48,7 @@ public void CanCreateFontWithVariations() [Fact] public void CanCreateFontWithVariationsViaFontFamily() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font variedFont = family.CreateFont(12, new FontVariation("wght", 700)); Assert.Single(variedFont.Variations.ToArray()); @@ -57,7 +57,7 @@ public void CanCreateFontWithVariationsViaFontFamily() [Fact] public void BaseFontHasEmptyVariations() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font baseFont = family.CreateFont(12); Assert.True(baseFont.Variations.IsEmpty); @@ -67,7 +67,7 @@ public void BaseFontHasEmptyVariations() public void VariationsDoNotAffectNonVariableFont() { // OpenSans is not a variable font; variations should be silently ignored. - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); Font baseFont = family.CreateFont(12); Font variedFont = new(baseFont, new FontVariation("wght", 700)); @@ -78,11 +78,11 @@ public void VariationsDoNotAffectNonVariableFont() [Fact] public void CanLoadVariationAxes_RobotoFlex() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font font = family.CreateFont(12); - Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - Assert.Equal(13, axes!.Length); + Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + Assert.Equal(13, axes.Length); Assert.Equal("wght", axes[0].Tag); Assert.Equal(100, axes[0].Min); @@ -93,11 +93,11 @@ public void CanLoadVariationAxes_RobotoFlex() [Fact] public void CanLoadVariationAxes_AdobeVFPrototype() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font font = family.CreateFont(12); - Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - Assert.Equal(2, axes!.Length); + Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + Assert.Equal(2, axes.Length); Assert.Equal("wght", axes[0].Tag); Assert.Equal(200, axes[0].Min); @@ -110,7 +110,7 @@ public void CanLoadVariationAxes_AdobeVFPrototype() public void GVar_VariedGlyphDiffersFromDefault() { // Verify that applying a weight variation actually changes glyph outlines. - FontFamily family = new FontCollection().Add(TestFonts.TestGVAROne); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVAROne); Font defaultFont = family.CreateFont(12); Font variedFont = family.CreateFont(12, new FontVariation("wght", 300)); @@ -142,7 +142,7 @@ public void GVar_AllPointShareModes_ProduceSameResult(string fontName) _ => throw new ArgumentException(fontName) }; - FontFamily family = new FontCollection().Add(fontPath); + FontFamily family = TestFonts.GetFontFamily(fontPath); Font variedFont = family.CreateFont(12, new FontVariation("wght", 300)); CodePoint cp = new('彌'); @@ -157,9 +157,9 @@ public void GVar_AllThreeFontsProduceIdenticalBounds() { // All three TestGVAR fonts encode the same variation data differently. // They should produce identical glyph bounds at the same axis value. - Font font1 = new FontCollection().Add(TestFonts.TestGVAROne).CreateFont(12, new FontVariation("wght", 300)); - Font font2 = new FontCollection().Add(TestFonts.TestGVARTwo).CreateFont(12, new FontVariation("wght", 300)); - Font font3 = new FontCollection().Add(TestFonts.TestGVARThree).CreateFont(12, new FontVariation("wght", 300)); + Font font1 = TestFonts.GetFontFamily(TestFonts.TestGVAROne).CreateFont(12, new FontVariation("wght", 300)); + Font font2 = TestFonts.GetFontFamily(TestFonts.TestGVARTwo).CreateFont(12, new FontVariation("wght", 300)); + Font font3 = TestFonts.GetFontFamily(TestFonts.TestGVARThree).CreateFont(12, new FontVariation("wght", 300)); CodePoint cp = new('彌'); font1.TryGetGlyphs(cp, out Glyph? g1); @@ -177,7 +177,7 @@ public void GVar_AllThreeFontsProduceIdenticalBounds() public void HVAR_AdvanceWidthVariesWithWeight() { // fontkit: TestGVARFour at wght=150, glyph 'O' should have advanceWidth=706 - FontFamily family = new FontCollection().Add(TestFonts.TestGVARFour); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVARFour); Font variedFont = family.CreateFont(12, new FontVariation("wght", 150)); CodePoint cp = new('O'); @@ -190,7 +190,7 @@ public void HVAR_AdvanceWidthVariesWithWeight() public void HVAR_FallsBackToLastEntry() { // fontkit: TestHVARTwo at wght=400, glyph 'A' should have advanceWidth=584 - FontFamily family = new FontCollection().Add(TestFonts.TestHVARTwo); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestHVARTwo); Font variedFont = family.CreateFont(12, new FontVariation("wght", 400)); CodePoint cp = new('A'); @@ -204,11 +204,11 @@ public void HVAR_DefaultWeightPreservesOriginalWidth() { // fontkit: TestGVARFour at default wght (1000), glyph 'O' advanceWidth=700 // At default axis value the HVAR delta should be zero. - FontFamily family = new FontCollection().Add(TestFonts.TestGVARFour); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVARFour); Font defaultFont = family.CreateFont(12); - Assert.True(defaultFont.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - VariationAxis wghtAxis = Assert.Single(axes!, a => a.Tag == "wght"); + Assert.True(defaultFont.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + VariationAxis wghtAxis = Assert.Single(axes, a => a.Tag == "wght"); Font variedFont = family.CreateFont(12, new FontVariation("wght", wghtAxis.Default)); @@ -223,7 +223,7 @@ public void HVAR_DefaultWeightPreservesOriginalWidth() public void HVAR_AdvanceWidthAtSpecificWeight() { // fontkit: TestGVARFour at wght=150, glyph 'O' should have advanceWidth=706 - FontFamily family = new FontCollection().Add(TestFonts.TestGVARFour); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVARFour); Font variedFont = family.CreateFont(12, new FontVariation("wght", 150)); CodePoint cp = new('O'); @@ -235,7 +235,7 @@ public void HVAR_AdvanceWidthAtSpecificWeight() [Fact] public void GVar_AdobeVFPrototype_VariedGlyphDiffersFromDefault() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font defaultFont = family.CreateFont(12); Font lightFont = family.CreateFont(12, new FontVariation("wght", 200)); Font boldFont = family.CreateFont(12, new FontVariation("wght", 900)); @@ -252,7 +252,7 @@ public void GVar_AdobeVFPrototype_VariedGlyphDiffersFromDefault() [Fact] public void GVar_AdobeVFPrototype_DifferentWeightsProduceDifferentBounds() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font font200 = family.CreateFont(12, new FontVariation("wght", 200)); Font font900 = family.CreateFont(12, new FontVariation("wght", 900)); @@ -270,7 +270,7 @@ public void GVar_AdobeVFPrototype_GSUB_SubstitutesGlyphAtHeavyWeight() // fontkit: AdobeVFPrototype at wght=900, '$' substitutes to 'dollar.nostroke' (glyphId 2). // GSUB FeatureVariations activate alternate glyphs based on axis values. // Must use TextRenderer to trigger GSUB. - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font defaultFont = family.CreateFont(12); Font heavyFont = family.CreateFont(12, new FontVariation("wght", 900)); @@ -289,7 +289,7 @@ public void CFF2_CanLoadFont() { // AdobeVFPrototype-Subset.otf is the only CFF2 font in the test suite. // It contains 3 glyphs: .notdef, '$' (glyph 1), and 'dollar.nostroke' (glyph 2). - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font font = family.CreateFont(12); Assert.NotNull(font.FontMetrics); @@ -298,18 +298,18 @@ public void CFF2_CanLoadFont() [Fact] public void CFF2_CanLoadVariationAxes() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font font = family.CreateFont(12); - Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - Assert.Equal(2, axes!.Length); + Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + Assert.Equal(2, axes.Length); Assert.Equal("wght", axes[0].Tag); } [Fact] public void CFF2_CanCreateFontWithVariation() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font variedFont = family.CreateFont(12, new FontVariation("wght", 900)); Assert.Single(variedFont.Variations.ToArray()); @@ -318,7 +318,7 @@ public void CFF2_CanCreateFontWithVariation() [Fact] public void CFF2_RendersGlyphAtDefaultWeight() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font font = family.CreateFont(48); GlyphRenderer renderer = new(); @@ -331,7 +331,7 @@ public void CFF2_RendersGlyphAtDefaultWeight() [Fact] public void CFF2_RendersGlyphAtVariedWeight() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font font = family.CreateFont(48, new FontVariation("wght", 900)); GlyphRenderer renderer = new(); @@ -345,7 +345,7 @@ public void CFF2_RendersGlyphAtVariedWeight() public void CFF2_MultipleWeightsRenderSuccessfully() { // Verify the CFF2 parser handles charstrings at multiple weight values. - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototypeSubset); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototypeSubset); Font lightFont = family.CreateFont(48, new FontVariation("wght", 0)); Font heavyFont = family.CreateFont(48, new FontVariation("wght", 900)); @@ -363,7 +363,7 @@ public void CFF2_MultipleWeightsRenderSuccessfully() public void MVAR_MetricsVaryWithAxisValues() { // RobotoFlex has MVAR table. Global metrics should change with weight. - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font defaultFont = family.CreateFont(12); Font heavyFont = family.CreateFont(12, new FontVariation("wght", 1000)); @@ -381,7 +381,7 @@ public void GPOS_MarkAnchorPositionsVaryWithWeight() { // fontkit: Mada-VF at wght=900, layout 'ف', positions[0] xOffset≈639, yOffset≈542. // The mark positioning should differ between default and heavy weights. - FontFamily family = new FontCollection().Add(TestFonts.MadaVF); + FontFamily family = TestFonts.GetFontFamily(TestFonts.MadaVF); Font defaultFont = family.CreateFont(72); Font heavyFont = family.CreateFont(72, new FontVariation("wght", 900)); @@ -403,7 +403,7 @@ public void MultipleVariationInstances_DoNotInterfere() { // Create two different variation instances from the same base font. // They should produce different results without corrupting each other. - FontFamily family = new FontCollection().Add(TestFonts.TestGVARFour); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVARFour); Font lightFont = family.CreateFont(12, new FontVariation("wght", 150)); Font heavyFont = family.CreateFont(12, new FontVariation("wght", 900)); @@ -427,7 +427,7 @@ public void VariationInstance_DoesNotCorruptBaseFont() // Get a glyph from the default font, then create a variation, // then get the same glyph from the default font again. // The default font should not be affected. - FontFamily family = new FontCollection().Add(TestFonts.TestGVARFour); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVARFour); Font defaultFont = family.CreateFont(12); CodePoint cp = new('O'); @@ -446,7 +446,7 @@ public void VariationInstance_DoesNotCorruptBaseFont() [Fact] public void TextMeasurer_AdvanceChangesWithVariation() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font thinFont = family.CreateFont(72, new FontVariation("wght", 100)); Font heavyFont = family.CreateFont(72, new FontVariation("wght", 1000)); @@ -465,7 +465,7 @@ public void TextMeasurer_AdvanceChangesWithVariation() [Fact] public void TextMeasurer_MultipleAxesWork() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font font = family.CreateFont( 72, new FontVariation("wght", 700), @@ -482,7 +482,7 @@ public void TextMeasurer_MultipleAxesWork() [Fact] public void Renderer_VariedFontProducesGlyphs() { - FontFamily family = new FontCollection().Add(TestFonts.TestGVAROne); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVAROne); Font variedFont = family.CreateFont(12, new FontVariation("wght", 300)); GlyphRenderer renderer = new(); @@ -495,7 +495,7 @@ public void Renderer_VariedFontProducesGlyphs() [Fact] public void Renderer_DifferentVariationsProduceDifferentControlPoints() { - FontFamily family = new FontCollection().Add(TestFonts.TestGVAROne); + FontFamily family = TestFonts.GetFontFamily(TestFonts.TestGVAROne); Font defaultFont = family.CreateFont(72); Font variedFont = family.CreateFont(72, new FontVariation("wght", 300)); @@ -527,7 +527,7 @@ public void Renderer_DifferentVariationsProduceDifferentControlPoints() [Fact] public void Renderer_GVar_AdobeVFPrototype_VariedFontProducesGlyphs() { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font variedFont = family.CreateFont(12, new FontVariation("wght", 900)); GlyphRenderer renderer = new(); @@ -539,7 +539,7 @@ public void Renderer_GVar_AdobeVFPrototype_VariedFontProducesGlyphs() [Fact] public void NotoSansHK_VariableWeight_LoadsSuccessfully() { - FontFamily family = new FontCollection().Add(TestFonts.NotoSansHKVariableFontWght); + FontFamily family = TestFonts.GetFontFamily(TestFonts.NotoSansHKVariableFontWght); Font thinFont = family.CreateFont(12, new FontVariation("wght", 100)); Font boldFont = family.CreateFont(12, new FontVariation("wght", 900)); @@ -554,7 +554,7 @@ public void NotoEmoji_GVar_OutlinesVaryWithWeight() // Advance width stays constant at 2600 across weights, but glyph outlines change. // Verified against fontkit: star U+2B50 glyphId=184, advance=2600 at all weights, // light bbox={233,-320,2367,1720}, bold bbox={203,-350,2397,1750}. - FontFamily family = new FontCollection().Add(TestFonts.NotoEmojiVariableFont); + FontFamily family = TestFonts.GetFontFamily(TestFonts.NotoEmojiVariableFont); Font lightFont = family.CreateFont(12, new FontVariation("wght", 300)); Font boldFont = family.CreateFont(12, new FontVariation("wght", 700)); @@ -596,7 +596,7 @@ public void NotoEmoji_GVar_OutlinesVaryWithWeight() [InlineData(700, "Bold")] public void VisualTest_NotoEmoji_WeightVariations(float weight, string label) { - FontFamily family = new FontCollection().Add(TestFonts.NotoEmojiVariableFont); + FontFamily family = TestFonts.GetFontFamily(TestFonts.NotoEmojiVariableFont); Font font = family.CreateFont(48, new FontVariation("wght", weight)); TextOptions options = new(font); @@ -614,7 +614,7 @@ public void VisualTest_NotoEmoji_WeightVariations(float weight, string label) [InlineData(1000, "Heavy")] public void VisualTest_RobotoFlex_WeightVariations(float weight, string label) { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font font = family.CreateFont(36, new FontVariation("wght", weight)); TextOptions options = new(font); @@ -630,7 +630,7 @@ public void VisualTest_RobotoFlex_WeightVariations(float weight, string label) [InlineData(900, "Black")] public void VisualTest_AdobeVFPrototype_GVar_WeightVariations(float weight, string label) { - FontFamily family = new FontCollection().Add(TestFonts.AdobeVFPrototype); + FontFamily family = TestFonts.GetFontFamily(TestFonts.AdobeVFPrototype); Font font = family.CreateFont(48, new FontVariation("wght", weight)); TextOptions options = new(font); @@ -644,7 +644,7 @@ public void VisualTest_AdobeVFPrototype_GVar_WeightVariations(float weight, stri [Fact] public void VisualTest_RobotoFlex_MultipleAxes() { - FontFamily family = new FontCollection().Add(TestFonts.RobotoFlex); + FontFamily family = TestFonts.GetFontFamily(TestFonts.RobotoFlex); Font font = family.CreateFont( 36, new FontVariation("wght", 700), @@ -662,12 +662,12 @@ public void CVar_CanLoadFontWithCvarTable() { // VotoSerif has cvar, cvt, fpgm, prep, fvar, gvar tables. // Axes: wght (28–194, default 94), wdth (70–100), opsz (12–72). - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvar); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvar); Font font = family.CreateFont(12); Assert.NotNull(font.FontMetrics); - Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - Assert.Equal(3, axes!.Length); + Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + Assert.Equal(3, axes.Length); Assert.Equal("wght", axes[0].Tag); Assert.Equal("wdth", axes[1].Tag); Assert.Equal("opsz", axes[2].Tag); @@ -677,12 +677,12 @@ public void CVar_CanLoadFontWithCvarTable() public void CVar_NoShared_CanLoadFontWithCvarTable() { // Same font but cvar uses no shared point numbers. - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvarNoShared); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvarNoShared); Font font = family.CreateFont(12); Assert.NotNull(font.FontMetrics); - Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[]? axes)); - Assert.Equal(3, axes!.Length); + Assert.True(font.FontMetrics.TryGetVariationAxes(out VariationAxis[] axes)); + Assert.Equal(3, axes.Length); } [Fact] @@ -690,7 +690,7 @@ public void CVar_HintedRenderingWithVariation() { // Exercise the cvar code path: hinting enabled + variation applied. // cvar deltas modify CVT values before TrueType hinting instructions run. - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvar); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvar); Font defaultFont = family.CreateFont(48); Font variedFont = family.CreateFont(48, new FontVariation("wght", 194)); @@ -711,7 +711,7 @@ public void CVar_HintedRenderingWithVariation() public void CVar_NoShared_HintedRenderingWithVariation() { // Same test with the no-shared-points variant of the cvar font. - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvarNoShared); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvarNoShared); Font variedFont = family.CreateFont(48, new FontVariation("wght", 194)); TextOptions options = new(variedFont) { HintingMode = HintingMode.Standard }; @@ -727,7 +727,7 @@ public void CVar_HintedRenderingAtSmallSize() { // At small sizes, TrueType hinting with cvar-adjusted CVT values // has a greater effect on grid-fitting. Verify both paths render successfully. - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvar); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvar); Font font = family.CreateFont(12, new FontVariation("wght", 28)); TextOptions hintedOptions = new(font) { HintingMode = HintingMode.Standard }; @@ -752,7 +752,7 @@ public void CVar_HintedRenderingAtSmallSize() [InlineData(194, "Heavy", HintingMode.Standard)] public void VisualTest_VotoSerif_CVar_WeightVariations(float weight, string label, HintingMode hintingMode) { - FontFamily family = new FontCollection().Add(TestFonts.VotoSerifCvar); + FontFamily family = TestFonts.GetFontFamily(TestFonts.VotoSerifCvar); Font font = family.CreateFont(48, new FontVariation("wght", weight)); TextOptions options = new(font) { HintingMode = hintingMode }; diff --git a/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationsTests.cs b/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationsTests.cs index ab731b13f..8b5bf4e54 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationsTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/Variations/VariationsTests.cs @@ -12,10 +12,7 @@ public class VariationsTests private static readonly Font AdobeVFPrototype = CreateFont(TestFonts.AdobeVFPrototype); private static Font CreateFont(string testFont) - { - FontFamily family = TestFontCollection.Add(testFont); - return family.CreateFont(12); - } + => TestFonts.GetFont(TestFontCollection, testFont, 12); [Fact] public void CanLoadVariationTables_RobotoFlex() diff --git a/tests/SixLabors.Fonts.Tests/TestEnvironment.cs b/tests/SixLabors.Fonts.Tests/TestEnvironment.cs index a45315301..43f7fc287 100644 --- a/tests/SixLabors.Fonts.Tests/TestEnvironment.cs +++ b/tests/SixLabors.Fonts.Tests/TestEnvironment.cs @@ -18,6 +18,8 @@ internal static class TestEnvironment private const string UnicodeTestDataRelativePath = @"tests\UnicodeTestData\"; + private const string FontTestDataRelativePath = @"tests\Fonts\"; + private static readonly Lazy SolutionDirectoryFullPathLazy = new(GetSolutionDirectoryFullPathImpl); internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; @@ -37,6 +39,11 @@ internal static class TestEnvironment /// internal static string ReferenceOutputDirectoryFullPath => GetFullPath(ReferenceOutputDirectoryRelativePath); + /// + /// Gets the absolute file path to the font test data used for internal testing purposes. + /// + internal static string FontTestDataFullPath => GetFullPath(FontTestDataRelativePath); + internal static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); internal static bool IsMacOS => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); @@ -49,7 +56,6 @@ internal static class TestEnvironment internal static Architecture ProcessArchitecture => RuntimeInformation.ProcessArchitecture; - /// /// Gets a value indicating whether test execution runs on CI. /// diff --git a/tests/SixLabors.Fonts.Tests/TestFonts.cs b/tests/SixLabors.Fonts.Tests/TestFonts.cs index fa1cdb56e..838d9da64 100644 --- a/tests/SixLabors.Fonts.Tests/TestFonts.cs +++ b/tests/SixLabors.Fonts.Tests/TestFonts.cs @@ -2,13 +2,12 @@ // Licensed under the Six Labors Split License. using System.Collections.Concurrent; -using System.Reflection; namespace SixLabors.Fonts.Tests; public static class TestFonts { - private static readonly ConcurrentDictionary Cache = new(); + private static readonly ConcurrentDictionary FontStreamCache = new(); public static string TwemojiMozillaFile => GetFullPath("Twemoji Mozilla.ttf"); @@ -406,17 +405,53 @@ public static class TestFonts public static class Issues { - public static string Issue96File => GetFullPath("Issues/Issue96.fuzz"); + public static string Issue96File => GetFullPath("Issues/Issue96.ttf"); - public static string Issue97File => GetFullPath("Issues/Issue97.fuzz"); + public static string Issue97File => GetFullPath("Issues/Issue97.ttf"); public static string Issue298File => GetFullPath("Issues/StyleScript.ttf"); public static string Issue512_CreateCffGlyphMetrics => GetFullPath("Issues/StreamFontMetri.CreateCffGlyphMetrics.otf"); } - private static Stream OpenStream(string path) => - Cache.GetOrAdd( + /// + /// Gets a font with the given name and size. + /// + /// The name of the font. + /// The font size. + /// The + public static Font GetFont(string name, float size) + => GetFontFamily(name).CreateFont(size); + + /// + /// Gets a font family with the given name. + /// + /// The name of the font. + /// The + public static FontFamily GetFontFamily(string name) + => GetFontFamily(new FontCollection(), name); + + /// + /// Gets a font with the given name and size. + /// + /// The collection to add the font to + /// The name of the font. + /// The font size. + /// The + public static Font GetFont(FontCollection collection, string name, float size) + => GetFontFamily(collection, name).CreateFont(size); + + /// + /// Gets a font family with the given name + /// + /// The collection to add the font to + /// The name of the font. + /// The + public static FontFamily GetFontFamily(FontCollection collection, string name) + => collection.Add(name); + + private static MemoryStream OpenStream(string path) => + FontStreamCache.GetOrAdd( path, p => { @@ -424,32 +459,14 @@ private static Stream OpenStream(string path) => return fs.Clone(); }).Clone(); - private static Stream Clone(this Stream src) + private static MemoryStream Clone(this Stream src) { - var ms = new MemoryStream(); + MemoryStream ms = new(); src.Position = 0; src.CopyTo(ms); ms.Position = 0; return ms; } - public static string GetFullPath(string path) - { - string root = Path.GetDirectoryName(new Uri(typeof(TestFonts).GetTypeInfo().Assembly.CodeBase).LocalPath); - - string[] paths = new[] - { - "Fonts", - @"..\..\Fonts", - @"..\..\..\..\Fonts", - @"..\..\..\..\..\Fonts" - }; - - IEnumerable fullPaths = paths.Select(x => Path.GetFullPath(Path.Combine(root, x))); - string rootPath = fullPaths.FirstOrDefault(Directory.Exists); - - Assert.True(rootPath != null, $"could not find the font folder in any of these location, \n{string.Join("\n", fullPaths)}"); - - return Path.Combine(rootPath, path); - } + private static string GetFullPath(string file) => Path.Combine(TestEnvironment.FontTestDataFullPath, file); } diff --git a/tests/SixLabors.Fonts.Tests/TextAlignmentTests.cs b/tests/SixLabors.Fonts.Tests/TextAlignmentTests.cs new file mode 100644 index 000000000..6e2c9dbee --- /dev/null +++ b/tests/SixLabors.Fonts.Tests/TextAlignmentTests.cs @@ -0,0 +1,224 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Numerics; +using SixLabors.Fonts.Rendering; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Drawing; +using SixLabors.ImageSharp.Drawing.Processing; +using SixLabors.ImageSharp.Drawing.Text; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; + +namespace SixLabors.Fonts.Tests; + +#if SUPPORTS_DRAWING +public class TextAlignmentTests +{ + private const int Padding = 20; + private const int UnwrappedCellSize = 320; + private const int WrappedCellSize = 520; + private static readonly HorizontalAlignment[] HorizontalAlignments = Enum.GetValues(); + private static readonly VerticalAlignment[] VerticalAlignments = Enum.GetValues(); + + [Fact] + public void TextAlignmentSample_RendersReferenceImage() + => TextLayoutTestUtilities.TestImage( + 1000, + 1000, + image => RenderAlignmentSample(image, TestFonts.GetFont(TestFonts.OpenSansFile, 50))); + + [Fact] + public void TextAlignmentWrapped_RendersReferenceImage() + => TextLayoutTestUtilities.TestImage( + 1600, + 1600, + image => RenderAlignmentWrapped(image, TestFonts.GetFont(TestFonts.OpenSansFile, 50))); + + private static void RenderAlignmentSample(Image image, Font font) + { + for (int row = 0; row < VerticalAlignments.Length; row++) + { + for (int column = 0; column < HorizontalAlignments.Length; column++) + { + VerticalAlignment vertical = VerticalAlignments[row]; + HorizontalAlignment horizontal = HorizontalAlignments[column]; + + using Image cell = RenderCell( + UnwrappedCellSize, + UnwrappedCellSize, + font, + vertical, + horizontal, + 0, + $"{horizontal} x y z\n{vertical} x y z"); + + DrawCell(image, cell, row, column, UnwrappedCellSize); + } + } + } + + private static void RenderAlignmentWrapped(Image image, Font font) + { + const int wrappingWidth = 400; + + for (int row = 0; row < VerticalAlignments.Length; row++) + { + for (int column = 0; column < HorizontalAlignments.Length; column++) + { + VerticalAlignment vertical = VerticalAlignments[row]; + HorizontalAlignment horizontal = HorizontalAlignments[column]; + + using Image cell = RenderCell( + WrappedCellSize, + WrappedCellSize, + font, + vertical, + horizontal, + wrappingWidth, + $" {horizontal} {vertical} {horizontal} {vertical} {horizontal} {vertical} "); + + DrawCell(image, cell, row, column, WrappedCellSize); + } + } + } + + private static Image RenderCell( + int width, + int height, + Font font, + VerticalAlignment vertical, + HorizontalAlignment horizontal, + float wrappingWidth, + string text) + { + Image image = new(width, height); + image.Mutate(x => x.Fill(Color.White)); + + Draw(image, font, vertical, horizontal, wrappingWidth, text); + image.Mutate(x => x.Draw(Color.LightGray, 1, new RectangularPolygon(0, 0, width - 1, height - 1))); + + return image; + } + + private static void DrawCell(Image image, Image cell, int row, int column, int cellSize) + { + Point location = new(column * (cellSize + Padding), row * (cellSize + Padding)); + image.Mutate(x => x.DrawImage(cell, location, 1F)); + } + + private static void Draw( + Image image, + Font font, + VerticalAlignment vertical, + HorizontalAlignment horizontal, + float wrappingWidth, + string text) + { + float x = horizontal switch + { + HorizontalAlignment.Left => 0, + HorizontalAlignment.Center => image.Width / 2F, + HorizontalAlignment.Right => image.Width, + _ => 0, + }; + + float y = vertical switch + { + VerticalAlignment.Top => 0, + VerticalAlignment.Center => image.Height / 2F, + VerticalAlignment.Bottom => image.Height, + _ => 0, + }; + + Vector2 location = new(x, y); + + BoundsRenderer boundsRenderer = new(); + + TextOptions textOptions = new(font) + { + TabWidth = 4, + WrappingLength = wrappingWidth, + HorizontalAlignment = horizontal, + VerticalAlignment = vertical, + Origin = location, + }; + + IReadOnlyList glyphPaths = TextBuilder.GenerateGlyphs(text, textOptions); + TextRenderer.RenderTextTo(boundsRenderer, text, textOptions); + + image.Mutate(x => x.Fill(Color.Black, glyphPaths)); + Color boundsColor = Color.Fuchsia.WithAlpha(.5F); + image.Mutate(x => x.Draw(boundsColor, 1, boundsRenderer.Boxes)); + image.Mutate(x => x.Draw(Color.Lime, 1, boundsRenderer.TextBox)); + } + + private sealed class BoundsRenderer : IGlyphRenderer + { + private readonly List glyphBounds = []; + + public IPathCollection Boxes => new PathCollection(this.glyphBounds.Select(x => new RectangularPolygon(x.X, x.Y, x.Width, x.Height))); + + public IPath TextBox { get; private set; } + + public void BeginText(in FontRectangle bounds) + => this.TextBox = new RectangularPolygon(bounds.X, bounds.Y, bounds.Width, bounds.Height); + + public bool BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters) + { + this.glyphBounds.Add(bounds); + return true; + } + + public void BeginFigure() + { + } + + public void MoveTo(Vector2 point) + { + } + + public void ArcTo(float radiusX, float radiusY, float rotation, bool largeArc, bool sweep, Vector2 point) + { + } + + public void QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point) + { + } + + public void CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point) + { + } + + public void LineTo(Vector2 point) + { + } + + public void EndFigure() + { + } + + public void EndGlyph() + { + } + + public void EndText() + { + } + + public TextDecorations EnabledDecorations() => TextDecorations.None; + + public void SetDecoration(TextDecorations textDecorations, Vector2 start, Vector2 end, float thickness) + { + } + + public void BeginLayer(Paint paint, FillRule fillRule, ClipQuad? clipBounds) + { + } + + public void EndLayer() + { + } + } +} +#endif diff --git a/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs b/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs index d76fdfa07..9f6ad8139 100644 --- a/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs +++ b/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs @@ -17,6 +17,22 @@ namespace SixLabors.Fonts.Tests; internal static class TextLayoutTestUtilities { +#if SUPPORTS_DRAWING + public static void TestImage( + int imageWidth, + int imageHeight, + Action> renderAction, + float percentageTolerance = 0.05F, + [CallerMemberName] string test = "", + params object[] properties) + { + using Image image = new(Configuration.Default, imageWidth, imageHeight, Color.White.ToPixel()); + renderAction(image); + image.DebugSave("png", test, properties: properties); + image.CompareToReference(percentageTolerance: percentageTolerance, test: test, properties: properties); + } +#endif + public static void TestLayout( string text, TextOptions options, diff --git a/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs b/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs index d17b83f63..dc6bc66e9 100644 --- a/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs +++ b/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs @@ -198,21 +198,13 @@ public void CanAlignWithWrapping( } [Fact] - public unsafe void MeasureTextWithSpan() + public void MeasureTextWithSpan() { - Font font = CreateFont("hello"); - - Span text = stackalloc char[] - { - 'h', - 'e', - 'l', - 'l', - 'o' - }; + string text = "hello"; + Font font = CreateFont(text); // 72 * emSize means 1pt = 1px - FontRectangle size = TextMeasurer.MeasureBounds(text, new TextOptions(font) { Dpi = font.FontMetrics.ScaleFactor }); + FontRectangle size = TextMeasurer.MeasureBounds(text.AsSpan(), new TextOptions(font) { Dpi = font.FontMetrics.ScaleFactor }); Assert.Equal(10, size.Height, 4F); Assert.Equal(130, size.Width, 4F); @@ -240,12 +232,12 @@ public void TryMeasureCharacterBounds() { const string text = "a b\nc"; GlyphBounds[] expectedGlyphMetrics = - { + [ new(new CodePoint('a'), new FontRectangle(10, 0, 10, 10), 0, 0), new(new CodePoint(' '), new FontRectangle(40, 0, 30, 10), 1, 1), new(new CodePoint('b'), new FontRectangle(70, 0, 10, 10), 2, 2), new(new CodePoint('c'), new FontRectangle(10, 30, 10, 10), 3, 3), - }; + ]; Font font = CreateFont(text); Assert.True(TextMeasurer.TryMeasureCharacterBounds( @@ -464,8 +456,7 @@ public void MeasureTextWordBreak(string text, LayoutMode layoutMode, WordBreakin [InlineData("AB", 465, 654, true)] public void MeasureTextWithKerning(string text, float height, float width, bool applyKerning) { - var c = new FontCollection(); - Font font = c.Add(TestFonts.SimpleFontFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); FontRectangle size = TextMeasurer.MeasureBounds( text, new TextOptions(new Font(font, 1)) @@ -482,11 +473,10 @@ public void MeasureTextWithKerning(string text, float height, float width, bool [InlineData("a", 100, 100, 125, 396)] public void LayoutWithLocation(string text, float x, float y, float expectedX, float expectedY) { - var c = new FontCollection(); - Font font = c.Add(TestFonts.SimpleFontFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); - var glyphRenderer = new GlyphRenderer(); - var renderer = new TextRenderer(glyphRenderer); + GlyphRenderer glyphRenderer = new(); + TextRenderer renderer = new(glyphRenderer); renderer.RenderText( text, new TextOptions(new Font(font, 1)) @@ -503,8 +493,7 @@ public void LayoutWithLocation(string text, float x, float y, float expectedX, f [Fact] public void MeasureTextLeadingFraction() { - FontCollection c = new(); - Font font = c.Add(TestFonts.SimpleFontFileData()).CreateFont(12); + Font font = TestFonts.GetFont(TestFonts.SimpleFontFile, 12); TextOptions textOptions = new(font); FontRectangle measurement = TextMeasurer.MeasureSize("/ This will fail", textOptions); @@ -528,8 +517,8 @@ public void CountLinesWithSpan() { Font font = CreateFont("hello\n!"); - Span text = stackalloc char[] - { + Span text = + [ 'h', 'e', 'l', @@ -537,7 +526,7 @@ public void CountLinesWithSpan() 'o', '\n', '!' - }; + ]; int count = TextMeasurer.CountLines(text, new TextOptions(font) { Dpi = font.FontMetrics.ScaleFactor }); Assert.Equal(2, count); @@ -571,7 +560,7 @@ public void BuildTextRuns_EmptyReturnsDefaultRun() IReadOnlyList runs = TextLayout.BuildTextRuns(text.AsSpan(), options); - Assert.True(runs.Count == 1); + Assert.Single(runs); Assert.Equal(font, runs[0].Font); Assert.Equal(0, runs[0].Start); Assert.Equal(CodePoint.GetCodePointCount(text.AsSpan()), runs[0].End); @@ -587,15 +576,15 @@ public void BuildTextRuns_ReturnsCreatesInterimRuns() { TextRuns = new List() { - new TextRun() { Start = 9, End = 23, Font = font2 }, - new TextRun() { Start = 35, End = 54, Font = font2 }, - new TextRun() { Start = 68, End = 70, Font = font2 }, + new() { Start = 9, End = 23, Font = font2 }, + new() { Start = 35, End = 54, Font = font2 }, + new() { Start = 68, End = 70, Font = font2 }, } }; IReadOnlyList runs = TextLayout.BuildTextRuns(text.AsSpan(), options); - Assert.True(runs.Count == 7); + Assert.Equal(7, runs.Count); Assert.Equal(0, runs[0].Start); Assert.Equal(9, runs[0].End); @@ -642,8 +631,8 @@ public void BuildTextRuns_PreventsOverlappingRun() { TextRuns = new List() { - new TextRun() { Start = 0, End = 23 }, - new TextRun() { Start = 1, End = 76 }, + new() { Start = 0, End = 23 }, + new() { Start = 1, End = 76 }, } }; @@ -845,7 +834,7 @@ public void TextJustification_InterWord_Vertical(TextDirection direction) } } - public static TheoryData OpenSans_Data + public static TheoryData OpenSans_Data { get; } = new() { { '!', new(0F, 0F, 1.1621094F, 7.2753906F) }, @@ -967,7 +956,7 @@ public void TrueTypeHinting_CanHintSmallOpenSans(char c, FontRectangle expected) Assert.Equal(expected, actual, Comparer); } - public static TheoryData FontTrackingHorizontalData + public static TheoryData FontTrackingHorizontalData { get; } = new() { { "aaaa", 0.0f, 134.0f, [2.9f, 38.5f, 74.0f, 109.6f] }, @@ -982,7 +971,7 @@ public static TheoryData FontTrackingHorizontalDa [MemberData(nameof(FontTrackingHorizontalData))] public void FontTracking_SpaceCharacters_WithHorizontalLayout(string text, float tracking, float width, float[] characterPosition) { - Font font = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(64); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 64); TextOptions options = new(font) { Tracking = tracking, @@ -995,7 +984,7 @@ public void FontTracking_SpaceCharacters_WithHorizontalLayout(string text, float Assert.Equal(characterPosition, bounds.ToArray().Select(x => x.Bounds.X), Comparer); } - public static TheoryData FontTrackingVerticalData + public static TheoryData FontTrackingVerticalData { get; } = new() { { "aaaa", 0.0f, 296.9f, [33.5f, 120.7f, 207.9f, 295.0f] }, @@ -1010,7 +999,7 @@ public static TheoryData FontTrackingVerticalData [MemberData(nameof(FontTrackingVerticalData))] public void FontTracking_SpaceCharacters_WithVerticalLayout(string text, float tracking, float width, float[] characterPosition) { - Font font = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(64); + Font font = TestFonts.GetFont(TestFonts.OpenSansFile, 64); TextOptions options = new(font) { Tracking = tracking, @@ -1029,7 +1018,7 @@ public void FontTracking_SpaceCharacters_WithVerticalLayout(string text, float t [InlineData("\u1B3C\u1B3C", 1, 83.8)] public void FontTracking_DoNotAddSpacingAfterCharacterThatDidNotAdvance(string text, float tracking, float width) { - Font font = new FontCollection().Add(TestFonts.NotoSansBalineseRegular).CreateFont(64); + Font font = TestFonts.GetFont(TestFonts.NotoSansBalineseRegular, 64); TextOptions options = new(font) { Tracking = tracking, @@ -1046,7 +1035,7 @@ public void FontTracking_DoNotAddSpacingAfterCharacterThatDidNotAdvance(string t [InlineData("\u093fa", 1, 145.5f)] public void FontTracking_CorrectlyAddSpacingForComposedCharacter(string text, float tracking, float width) { - Font font = new FontCollection().Add(TestFonts.NotoSansDevanagariRegular).CreateFont(64); + Font font = TestFonts.GetFont(TestFonts.NotoSansDevanagariRegular, 64); TextOptions options = new(font) { Tracking = tracking, @@ -1063,11 +1052,7 @@ public void FontTracking_CorrectlyAddSpacingForComposedCharacter(string text, fl [InlineData("\u093fa", 1)] public void FontTracking_CorrectlyAddSpacingForComposedCharacterHRef(string text, float tracking) { - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansDevanagariRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansDevanagariRegular, 30); TextOptions options = new(mainFont) { @@ -1084,11 +1069,7 @@ public void FontTracking_CorrectlyAddSpacingForComposedCharacterHRef(string text [InlineData("\u093fa", 1)] public void FontTracking_CorrectlyAddSpacingForComposedCharacterVRef(string text, float tracking) { - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansDevanagariRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansDevanagariRegular, 30); TextOptions options = new(mainFont) { @@ -1106,11 +1087,7 @@ public void FontTracking_CorrectlyAddSpacingForComposedCharacterVRef(string text [InlineData("\u093fa", 1)] public void FontTracking_CorrectlyAddSpacingForComposedCharacterVMRef(string text, float tracking) { - FontCollection fontCollection = new(); - string name = fontCollection.Add(TestFonts.NotoSansDevanagariRegular).Name; - - FontFamily mainFontFamily = fontCollection.Get(name); - Font mainFont = mainFontFamily.CreateFont(30, FontStyle.Regular); + Font mainFont = TestFonts.GetFont(TestFonts.NotoSansDevanagariRegular, 30); TextOptions options = new(mainFont) { @@ -1124,7 +1101,7 @@ public void FontTracking_CorrectlyAddSpacingForComposedCharacterVMRef(string tex [Fact] public void CanMeasureTextAdvance() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1145,7 +1122,7 @@ public void CanMeasureTextAdvance() [Fact] public void CanMeasureCharacterLayouts() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1181,7 +1158,7 @@ public void CanMeasureCharacterLayouts() [Fact] public void CanMeasureMultilineCharacterLayouts() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1220,7 +1197,7 @@ public void CanMeasureMultilineCharacterLayouts() [Fact] public void DoesMeasureCharacterLayoutIncludeStringIndex() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1253,7 +1230,7 @@ public void DoesMeasureCharacterLayoutIncludeStringIndex() if (bound.Codepoint == new CodePoint("k"[0])) { - stringIndex = text.IndexOf("k", StringComparison.InvariantCulture); + stringIndex = text.IndexOf('k'); Assert.Equal(stringIndex, bound.StringIndex); Assert.Equal(stringIndex, bound.GraphemeIndex); } @@ -1261,7 +1238,7 @@ public void DoesMeasureCharacterLayoutIncludeStringIndex() // after emoji if (bound.Codepoint == new CodePoint("b"[0])) { - stringIndex = text.IndexOf("b", StringComparison.InvariantCulture); + stringIndex = text.IndexOf('b'); Assert.NotEqual(bound.StringIndex, bound.GraphemeIndex); Assert.Equal(stringIndex, bound.StringIndex); Assert.Equal(11, bound.GraphemeIndex); @@ -1287,7 +1264,7 @@ public void DoesMeasureCharacterLayoutIncludeStringIndex() [Fact] public void DoesMeasureCharacterBoundsExtendForAdvanceMultipliers() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1297,17 +1274,17 @@ public void DoesMeasureCharacterBoundsExtendForAdvanceMultipliers() const string text = "H\tH"; - IReadOnlyList glyphsToRender = CaptureGlyphBoundBuilder.GenerateGlyphsBoxes(text, options); + List glyphs = CaptureGlyphBoundBuilder.GenerateGlyphsBoxes(text, options); TextMeasurer.TryMeasureCharacterBounds(text, options, out ReadOnlySpan bounds); IReadOnlyList glyphLayouts = TextLayout.GenerateLayout(text, options); - Assert.Equal(glyphsToRender.Count, bounds.Length); - Assert.Equal(glyphsToRender.Count, glyphsToRender.Count); + Assert.Equal(glyphs.Count, bounds.Length); + Assert.Equal(glyphs.Count, glyphs.Count); - for (int glyphIndex = 0; glyphIndex < glyphsToRender.Count; glyphIndex++) + for (int glyphIndex = 0; glyphIndex < glyphs.Count; glyphIndex++) { - FontRectangle renderGlyph = glyphsToRender[glyphIndex]; + FontRectangle renderGlyph = glyphs[glyphIndex]; FontRectangle measureGlyph = bounds[glyphIndex].Bounds; GlyphLayout glyphLayout = glyphLayouts[glyphIndex]; @@ -1328,7 +1305,7 @@ public void DoesMeasureCharacterBoundsExtendForAdvanceMultipliers() [Fact] public void IsMeasureCharacterBoundsSameAsRenderBounds() { - FontFamily family = new FontCollection().Add(TestFonts.OpenSansFile); + FontFamily family = TestFonts.GetFontFamily(TestFonts.OpenSansFile); family.TryGetMetrics(FontStyle.Regular, out FontMetrics metrics); TextOptions options = new(family.CreateFont(metrics.UnitsPerEm)) @@ -1337,14 +1314,14 @@ public void IsMeasureCharacterBoundsSameAsRenderBounds() const string text = "Hello WorLLd"; - IReadOnlyList glyphsToRender = CaptureGlyphBoundBuilder.GenerateGlyphsBoxes(text, options); + List glyphs = CaptureGlyphBoundBuilder.GenerateGlyphsBoxes(text, options); TextMeasurer.TryMeasureCharacterBounds(text, options, out ReadOnlySpan bounds); - Assert.Equal(glyphsToRender.Count, bounds.Length); + Assert.Equal(glyphs.Count, bounds.Length); - for (int glyphIndex = 0; glyphIndex < glyphsToRender.Count; glyphIndex++) + for (int glyphIndex = 0; glyphIndex < glyphs.Count; glyphIndex++) { - FontRectangle renderGlyph = glyphsToRender[glyphIndex]; + FontRectangle renderGlyph = glyphs[glyphIndex]; FontRectangle measureGlyph = bounds[glyphIndex].Bounds; Assert.Equal(renderGlyph.X, measureGlyph.X); @@ -1384,7 +1361,7 @@ public static List GenerateGlyphsBoxes(string text, TextOptions o return glyphBuilder.GlyphBounds; } - public readonly List GlyphBounds = new(); + public readonly List GlyphBounds = []; public CaptureGlyphBoundBuilder() { @@ -1451,11 +1428,11 @@ public void EndLayer() } } - private static readonly Font OpenSansTTF = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(10); - private static readonly Font OpenSansWoff = new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(10); + private static readonly Font OpenSansTTF = TestFonts.GetFont(TestFonts.OpenSansFile, 10); + private static readonly Font OpenSansWoff = TestFonts.GetFont(TestFonts.OpenSansFile, 10); #if OS_WINDOWS - public static TheoryData SegoeUi_Data + public static TheoryData SegoeUi_Data { get; } = new() { { '!', new(0F, 0F, 1.0839844F, 7.0898438F) }, @@ -1551,8 +1528,7 @@ public static TheoryData SegoeUi_Data { '{', new(0F, 0F, 2.2607422F, 8.59375F) }, { '|', new(0F, 0F, 0.72265625F, 10F) }, { '}', new(0F, 0F, 2.2558594F, 8.59375F) }, - { '~', new(0F, 0F, 4.8095703F, 1.5136719F) }, - + { '~', new(0F, 0F, 4.8095703F, 1.5136719F) } }; [Theory] @@ -1573,12 +1549,12 @@ public void TrueTypeHinting_CanHintSmallSegoeUi(char c, FontRectangle expected) private static readonly Font SegoeUi = SystemFonts.CreateFont("Segoe Ui", 10); #endif - private static IReadOnlyList CollectFirstLine(IReadOnlyList glyphs) + private static List CollectFirstLine(IReadOnlyList glyphs) { - List line = new() - { + List line = + [ glyphs[0] - }; + ]; for (int i = 1; i < glyphs.Count; i++) { @@ -1595,28 +1571,28 @@ private static IReadOnlyList CollectFirstLine(IReadOnlyList new FontCollection().Add(TestFonts.OpenSansFile).CreateFont(pointSize); + => TestFonts.GetFont(TestFonts.OpenSansFile, pointSize); public static Font CreateFont(string text) { - var fc = (IFontMetricsCollection)new FontCollection(); + IFontMetricsCollection fc = new FontCollection(); Font d = fc.AddMetrics(new FakeFontInstance(text), CultureInfo.InvariantCulture).CreateFont(12); return new Font(d, 1F); } public static Font CreateFont(string text, float pointSize) { - var fc = (IFontMetricsCollection)new FontCollection(); + IFontMetricsCollection fc = new FontCollection(); Font d = fc.AddMetrics(new FakeFontInstance(text), CultureInfo.InvariantCulture).CreateFont(12); return new Font(d, pointSize); } diff --git a/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs b/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs index ed72e046a..db0226436 100644 --- a/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs +++ b/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs @@ -216,7 +216,7 @@ public void GetGlyphFromFirstAvailableInstance(char character, string instance) ColorFontSupport = ColorFontSupport.None }; - ReadOnlySpan text = new[] { character }; + ReadOnlySpan text = [character]; GlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, text, options); GlyphRendererParameters glyph = Assert.Single(renderer.GlyphKeys); diff --git a/tests/SixLabors.Fonts.Tests/TrueTypeCollectionTests.cs b/tests/SixLabors.Fonts.Tests/TrueTypeCollectionTests.cs index 9edcccef4..17a86838c 100644 --- a/tests/SixLabors.Fonts.Tests/TrueTypeCollectionTests.cs +++ b/tests/SixLabors.Fonts.Tests/TrueTypeCollectionTests.cs @@ -10,7 +10,7 @@ public class TrueTypeCollectionTests [Fact] public void AddViaPathReturnsDescription() { - var suit = new FontCollection(); + FontCollection suit = new(); IEnumerable collectionFromPath = suit.AddCollection(TestFonts.SimpleTrueTypeCollection, out IEnumerable descriptions); Assert.Equal(2, descriptions.Count()); @@ -25,7 +25,7 @@ public void AddViaPathReturnsDescription() [Fact] public void AddViaPathAddFontFileInstances() { - var sut = new FontCollection(); + FontCollection sut = new(); IEnumerable collectionFromPath = sut.AddCollection(TestFonts.SimpleTrueTypeCollection, out IEnumerable descriptions); IEnumerable allInstances = sut.Families.SelectMany(x => ((IReadOnlyFontMetricsCollection)sut).GetAllMetrics(x.Name, CultureInfo.InvariantCulture)); @@ -39,7 +39,7 @@ public void AddViaPathAddFontFileInstances() [Fact] public void AddViaStreamReturnsDescription() { - var suit = new FontCollection(); + FontCollection suit = new(); IEnumerable collectionFromPath = suit.AddCollection(TestFonts.SSimpleTrueTypeCollectionData(), out IEnumerable descriptions); Assert.Equal(2, collectionFromPath.Count()); diff --git a/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs index d5764783d..057efa609 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Globalization; using SixLabors.Fonts.Rendering; using SixLabors.Fonts.Unicode; using Xunit.Abstractions; @@ -17,14 +18,14 @@ public class BidiAlgorithmTests public void RendersKurdishTextCorrect() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); + Font arabicFont = TestFonts.GetFont(TestFonts.ArabicFontFile, 8); ColorGlyphRenderer renderer = new(); const string testStr = "نەما خانی هەتا چیڕۆکی عیشقی ئێمە داڕێژێ"; int[] expectedGlyphIndices = - { + [ 0, 214, 0, 0, 139, 197, 3, 0, 289, 0, 333, 3, 336, 266, 221, 337, 242, 3, 336, 276, 0, 0, 337, 188, 3, 140, 170, 0, 301, 3, 336, 294, 140, 196, 3, 140, 290, 0, 294 - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -41,14 +42,14 @@ public void RendersKurdishTextCorrect() public void RendersFarsiTextCorrect() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + Font arabicFont = TestFonts.GetFont(TestFonts.ArabicFontFile, 8); + ColorGlyphRenderer renderer = new(); const string testStr = "زناب فارسی را تک کمی سخت است"; int[] expectedGlyphIndices = - { + [ 168, 218, 139, 3, 168, 195, 218, 3, 336, 289, 276, 3, 274, 170, 3, 139, 203, 3, 336, 218, 203, 140, 250, 3, 157, 140, 294, 207 - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -65,15 +66,15 @@ public void RendersFarsiTextCorrect() public void RendersArabicTextWithPunctuationCorrectly() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.TimesNewRomanFile).CreateFont(12); + Font arabicFont = TestFonts.GetFont(TestFonts.TimesNewRomanFile, 12); ColorGlyphRenderer renderer = new(); const string testStr = "زۆرمان باس کرد؛ باسی ئاو، کەش، هەوای کوردستان."; int[] expectedGlyphIndices = - { + [ 17, 997, 910, 920, 947, 937, 941, 1006, 815, 3, 821, 909, 1005, 1002, 1003, 3, 748, 949, 1002, 815, 3, 748, 1005, 910, 907, 3, 822, 947, 910, 913, 3, 749, 937, 942, 815, 3, 945, 910, 913, 3, 997, 910, 995, 941, 1574, 943 - }; + ]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -90,10 +91,10 @@ public void RendersArabicTextWithPunctuationCorrectly() public void RendersArabicNumbersFromLeftToRight() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + Font arabicFont = TestFonts.GetFont(TestFonts.ArabicFontFile, 12); + ColorGlyphRenderer renderer = new(); string testStr = "٠١٢٣٤٥٦٧٨٩"; - int[] expectedGlyphIndices = { 403, 405, 407, 409, 411, 413, 415, 417, 419, 421 }; + int[] expectedGlyphIndices = [403, 405, 407, 409, 411, 413, 415, 417, 419, 421]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -110,10 +111,10 @@ public void RendersArabicNumbersFromLeftToRight() public void MixingArabicWordsWithNumbers_Works() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.SegeouiFontFile).CreateFont(12); + Font arabicFont = TestFonts.GetFont(TestFonts.SegeouiFontFile, 12); ColorGlyphRenderer renderer = new(); const string testStr = "لە ساڵی ١٢٣٤ ڕوویدا"; - int[] expectedGlyphIndices = { 2317, 3631, 2380, 2345, 2345, 2485, 3, 2264, 2265, 2266, 2267, 3, 2379, 2540, 2247, 2260, 3, 2842, 2286 }; + int[] expectedGlyphIndices = [2317, 3631, 2380, 2345, 2345, 2485, 3, 2264, 2265, 2266, 2267, 3, 2379, 2540, 2247, 2260, 3, 2842, 2286]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -130,10 +131,10 @@ public void MixingArabicWordsWithNumbers_Works() public void MathematicalFormulasWithArabicText_Works() { // arrange - Font arabicFont = new FontCollection().Add(TestFonts.SegeouiFontFile).CreateFont(12); + Font arabicFont = TestFonts.GetFont(TestFonts.SegeouiFontFile, 12); ColorGlyphRenderer renderer = new(); const string testStr = "١١س + ٨ج = ٨٥١"; - int[] expectedGlyphIndices = { 2271, 2268, 2264, 3, 32, 3, 2322, 2271, 3, 14, 3, 2329, 2264, 2264 }; + int[] expectedGlyphIndices = [2271, 2268, 2264, 3, 32, 3, 2322, 2271, 3, 14, 3, 2329, 2264, 2264]; // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -157,9 +158,9 @@ private bool ICUTestsImpl() // Read the test file string[] lines = File.ReadAllLines(Path.Combine(TestEnvironment.UnicodeTestDataFullPath, "BidiTest.txt")); - var bidi = new BidiAlgorithm(); + BidiAlgorithm bidi = new(); - var tests = new List(); + List tests = []; // Process each line int[] levels = null; @@ -175,11 +176,11 @@ private bool ICUTestsImpl() } // Directive? - if (line.StartsWith("@")) + if (line.StartsWith('@')) { - if (line.StartsWith("@Levels:")) + if (line.StartsWith("@Levels:", StringComparison.InvariantCulture)) { - levels = line.Substring(8).Trim().Split(' ').Where(x => x.Length > 0).Select(x => + levels = [.. line[8..].Trim().Split(' ').Where(x => x.Length > 0).Select(x => { if (x == "x") { @@ -187,9 +188,9 @@ private bool ICUTestsImpl() } else { - return int.Parse(x); + return int.Parse(x, CultureInfo.InvariantCulture); } - }).ToArray(); + })]; } continue; @@ -199,17 +200,17 @@ private bool ICUTestsImpl() string[] parts = line.Split(';'); // Get the directions - BidiCharacterType[] directions = parts[0].Split(' ').Select(x => + BidiCharacterType[] directions = [.. parts[0].Split(' ').Select(x => { UnicodeTypeMaps.BidiCharacterTypeMap.TryGetValue(x, out BidiCharacterType cls); return cls; - }).ToArray(); + })]; // Get the bit set int bitset = Convert.ToInt32(parts[1].Trim(), 16); - BidiPairedBracketType[] pairTypes = Enumerable.Repeat(BidiPairedBracketType.None, directions.Length).ToArray(); - int[] pairValues = Enumerable.Repeat(0, directions.Length).ToArray(); + BidiPairedBracketType[] pairTypes = [.. Enumerable.Repeat(BidiPairedBracketType.None, directions.Length)]; + int[] pairValues = [.. Enumerable.Repeat(0, directions.Length)]; for (int bit = 1; bit < 8; bit <<= 1) { @@ -218,25 +219,13 @@ private bool ICUTestsImpl() continue; } - sbyte paragraphEmbeddingLevel; - switch (bit) + sbyte paragraphEmbeddingLevel = bit switch { - case 1: - paragraphEmbeddingLevel = 2; // Auto - break; - - case 2: - paragraphEmbeddingLevel = 0; // LTR - break; - - case 4: - paragraphEmbeddingLevel = 1; // RTL - break; - - default: - throw new NotSupportedException(); - } - + 1 => 2, // Auto + 2 => 0, // LTR + 4 => 1, // RTL + _ => throw new NotSupportedException(), + }; tests.Add(new Test(directions, paragraphEmbeddingLevel, levels, lineNumber)); } } diff --git a/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs index d0a348489..b77c9be37 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs @@ -26,7 +26,7 @@ private bool ICUTestsImpl() string[] lines = File.ReadAllLines(Path.Combine(TestEnvironment.UnicodeTestDataFullPath, "BidiCharacterTest.txt")); // Parse lines - var tests = new List(); + List tests = new(); for (int lineNumber = 1; lineNumber < lines.Length + 1; lineNumber++) { // Get the line, remove comments @@ -42,7 +42,7 @@ private bool ICUTestsImpl() string[] fields = line.Split(';'); // Parse field 0 - code points - int[] codePoints = fields[0].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x, 16)).ToArray(); + int[] codePoints = [.. fields[0].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x, 16))]; // Parse field 1 - paragraph level sbyte paragraphLevel = sbyte.Parse(fields[1]); @@ -51,19 +51,19 @@ private bool ICUTestsImpl() sbyte resolvedParagraphLevel = sbyte.Parse(fields[2]); // Parse field 3 - resolved levels - sbyte[] resolvedLevels = fields[3].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => x == "x" ? (sbyte)-1 : Convert.ToSByte(x)).ToArray(); + sbyte[] resolvedLevels = [.. fields[3].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => x == "x" ? (sbyte)-1 : Convert.ToSByte(x))]; // Parse field 4 - resolved levels - int[] resolvedOrder = fields[4].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToArray(); + int[] resolvedOrder = [.. fields[4].Split(' ').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x))]; - var test = new Test(lineNumber, codePoints, paragraphLevel, resolvedParagraphLevel, resolvedLevels, resolvedOrder); + Test test = new(lineNumber, codePoints, paragraphLevel, resolvedParagraphLevel, resolvedLevels, resolvedOrder); tests.Add(test); } this.output.WriteLine($"Test data loaded: {tests.Count} test cases"); - var bidi = new BidiAlgorithm(); - var bidiData = new BidiData(); + BidiAlgorithm bidi = new(); + BidiData bidiData = new(); // Run tests... for (int testNumber = 0; testNumber < tests.Count; testNumber++) diff --git a/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.cs index 96b9faaf5..087c9231f 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.cs @@ -11,8 +11,8 @@ public partial class CodePointTests [MemberData(nameof(GeneralTestData_BmpCodePoints_NoSurrogates))] public static void Ctor_Cast_Char_Valid(GeneralTestData testData) { - var codePoint = new CodePoint(checked((char)testData.ScalarValue)); - var codePointFromCast = (CodePoint)(char)testData.ScalarValue; + CodePoint codePoint = new(checked((char)testData.ScalarValue)); + CodePoint codePointFromCast = (CodePoint)(char)testData.ScalarValue; Assert.Equal(codePoint, codePointFromCast); Assert.Equal(testData.ScalarValue, codePoint.Value); @@ -34,8 +34,8 @@ public static void Ctor_Cast_Char_Invalid_Throws(char value) [MemberData(nameof(GeneralTestData_SupplementaryCodePoints_ValidOnly))] public static void Ctor_Cast_Int32_Valid(GeneralTestData testData) { - var codePoint = new CodePoint(testData.ScalarValue); - var codePointFromCast = (CodePoint)testData.ScalarValue; + CodePoint codePoint = new(testData.ScalarValue); + CodePoint codePointFromCast = (CodePoint)testData.ScalarValue; Assert.Equal(codePoint, codePointFromCast); Assert.Equal(testData.ScalarValue, codePoint.Value); @@ -57,8 +57,8 @@ public static void Ctor_Cast_Int32_Invalid_Throws(int value) [MemberData(nameof(GeneralTestData_SupplementaryCodePoints_ValidOnly))] public static void Ctor_Cast_UInt32_Valid(GeneralTestData testData) { - var codePoint = new CodePoint((uint)testData.ScalarValue); - var codePointFromCast = (CodePoint)(uint)testData.ScalarValue; + CodePoint codePoint = new((uint)testData.ScalarValue); + CodePoint codePointFromCast = (CodePoint)(uint)testData.ScalarValue; Assert.Equal(codePoint, codePointFromCast); Assert.Equal(testData.ScalarValue, codePoint.Value); @@ -168,7 +168,7 @@ public void CodePointIsValid() [MemberData(nameof(GeneralTestData_SupplementaryCodePoints_ValidOnly))] public static void Utf16SequenceLengthIsCorrect(GeneralTestData testData) { - var codePoint = new CodePoint(testData.ScalarValue); + CodePoint codePoint = new(testData.ScalarValue); Assert.Equal(testData.Utf16Sequence.Length, codePoint.Utf16SequenceLength); } @@ -177,7 +177,7 @@ public static void Utf16SequenceLengthIsCorrect(GeneralTestData testData) [MemberData(nameof(GeneralTestData_SupplementaryCodePoints_ValidOnly))] public static void Utf8SequenceLengthIsCorrect(GeneralTestData testData) { - var codePoint = new CodePoint(testData.ScalarValue); + CodePoint codePoint = new(testData.ScalarValue); Assert.Equal(testData.Utf8Sequence.Length, codePoint.Utf8SequenceLength); } @@ -251,7 +251,7 @@ public void CodePointIsControl() { for (uint i = 0; i <= 0x10FFFFu; i++) { - var cp = new CodePoint(i); + CodePoint cp = new(i); if (cp.IsBmp) { Assert.Equal(CodePoint.IsControl(new CodePoint(i)), char.IsControl((char)i)); @@ -301,8 +301,8 @@ static bool IsLineBreakClassBreak(uint value) [InlineData(0x100, 0x80)] public static void Operators_And_CompareTo(uint scalarValueLeft, uint scalarValueRight) { - var left = new CodePoint(scalarValueLeft); - var right = new CodePoint(scalarValueRight); + CodePoint left = new(scalarValueLeft); + CodePoint right = new(scalarValueRight); Assert.Equal(scalarValueLeft == scalarValueRight, left == right); Assert.Equal(scalarValueLeft != scalarValueRight, left != right); diff --git a/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs index 8acd35c37..324bb330f 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs @@ -11,13 +11,13 @@ public class DfaTests public void CanCompileWithSingleLiteral() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 0, EndIndex = 0 }, - new StateMatch() { StartIndex = 1, EndIndex = 1 }, - new StateMatch() { StartIndex = 3, EndIndex = 3 } + new() { StartIndex = 0, EndIndex = 0 }, + new() { StartIndex = 1, EndIndex = 1 }, + new() { StartIndex = 3, EndIndex = 3 } }; Assert.True(expected.SequenceEqual(matches)); @@ -27,12 +27,12 @@ public void CanCompileWithSingleLiteral() public void CanCompileWithConcatenation() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a b;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 1, 0, 1, 0 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 1, 0, 1, 0])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 1, EndIndex = 2 }, - new StateMatch() { StartIndex = 4, EndIndex = 5 } + new() { StartIndex = 1, EndIndex = 2 }, + new() { StartIndex = 4, EndIndex = 5 } }; Assert.True(expected.SequenceEqual(matches)); @@ -42,13 +42,13 @@ public void CanCompileWithConcatenation() public void CanCompileWithAlternation() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = (a b) | (b a);"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 1, 0, 1, 0 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 1, 0, 1, 0])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 1, EndIndex = 2 }, - new StateMatch() { StartIndex = 3, EndIndex = 4 }, - new StateMatch() { StartIndex = 5, EndIndex = 6 } + new() { StartIndex = 1, EndIndex = 2 }, + new() { StartIndex = 3, EndIndex = 4 }, + new() { StartIndex = 5, EndIndex = 6 } }; Assert.True(expected.SequenceEqual(matches)); @@ -58,12 +58,12 @@ public void CanCompileWithAlternation() public void CanCompileWithRepeat() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = (a b)+;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 1, 1, 0, 1 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 1, 1, 0, 1])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 1, EndIndex = 4 }, - new StateMatch() { StartIndex = 6, EndIndex = 7 } + new() { StartIndex = 1, EndIndex = 4 }, + new() { StartIndex = 6, EndIndex = 7 } }; Assert.True(expected.SequenceEqual(matches)); @@ -73,12 +73,12 @@ public void CanCompileWithRepeat() public void CanCompileWithOptionalRepeat() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = b a (a b)*;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 2, EndIndex = 7 }, - new StateMatch() { StartIndex = 9, EndIndex = 10 } + new() { StartIndex = 2, EndIndex = 7 }, + new() { StartIndex = 9, EndIndex = 10 } }; Assert.True(expected.SequenceEqual(matches)); @@ -88,11 +88,11 @@ public void CanCompileWithOptionalRepeat() public void CanCompileWithExactRepetition() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a{3} b;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 3, EndIndex = 6 } + new() { StartIndex = 3, EndIndex = 6 } }; Assert.True(expected.SequenceEqual(matches)); @@ -102,12 +102,12 @@ public void CanCompileWithExactRepetition() public void CanCompileWithMinimumRepetition() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a{3,} b;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 3, EndIndex = 6 }, - new StateMatch() { StartIndex = 7, EndIndex = 11 } + new() { StartIndex = 3, EndIndex = 6 }, + new() { StartIndex = 7, EndIndex = 11 } }; Assert.True(expected.SequenceEqual(matches)); @@ -117,14 +117,14 @@ public void CanCompileWithMinimumRepetition() public void CanCompileWithMaximumRepetition() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a{,3} b;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 0, EndIndex = 2 }, - new StateMatch() { StartIndex = 3, EndIndex = 6 }, - new StateMatch() { StartIndex = 10, EndIndex = 11 }, - new StateMatch() { StartIndex = 12, EndIndex = 12 } + new() { StartIndex = 0, EndIndex = 2 }, + new() { StartIndex = 3, EndIndex = 6 }, + new() { StartIndex = 10, EndIndex = 11 }, + new() { StartIndex = 12, EndIndex = 12 } }; Assert.True(expected.SequenceEqual(matches)); @@ -134,12 +134,12 @@ public void CanCompileWithMaximumRepetition() public void CanCompileWithMinimumAndMaximumRepetition() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a{3,5} b;"); - StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 }).ToArray(); + StateMatch[] matches = [.. stateMachine.Match([0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 3, EndIndex = 6 }, - new StateMatch() { StartIndex = 7, EndIndex = 11 } + new() { StartIndex = 3, EndIndex = 6 }, + new() { StartIndex = 7, EndIndex = 11 } }; Assert.True(expected.SequenceEqual(matches)); @@ -150,20 +150,20 @@ public void CanCompileWithTags() { StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = x:(b a) | y:(a b);"); - int[] input = { 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0 }; - StateMatch[] matches = stateMachine.Match(new[] { 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0 }).ToArray(); + int[] input = [1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0]; + StateMatch[] matches = [.. stateMachine.Match([1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0])]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 2, EndIndex = 3, Tags = new string[] { "x" } }, - new StateMatch() { StartIndex = 4, EndIndex = 5, Tags = new string[] { "y" } }, - new StateMatch() { StartIndex = 6, EndIndex = 7, Tags = new string[] { "y" } }, - new StateMatch() { StartIndex = 9, EndIndex = 10, Tags = new string[] { "x" } }, + new() { StartIndex = 2, EndIndex = 3, Tags = new string[] { "x" } }, + new() { StartIndex = 4, EndIndex = 5, Tags = new string[] { "y" } }, + new() { StartIndex = 6, EndIndex = 7, Tags = new string[] { "y" } }, + new() { StartIndex = 9, EndIndex = 10, Tags = new string[] { "x" } }, }; Assert.True(expected.SequenceEqual(matches)); - List<(string Tag, int Start, int End, ArraySlice Slice)> applied = new(); + List<(string Tag, int Start, int End, ArraySlice Slice)> applied = []; Dictionary>> actions = new() { { "x", (start, end, slice) => applied.Add(("x", start, end, slice)) }, @@ -174,13 +174,13 @@ public void CanCompileWithTags() Assert.True(applied.Count == 4); - List<(string Tag, int Start, int End, ArraySlice Slice)> expectedApply = new() - { + List<(string Tag, int Start, int End, ArraySlice Slice)> expectedApply = + [ ("x", 2, 3, new int[] { 1, 0 }), ("y", 4, 5, new int[] { 0, 1 }), ("y", 6, 7, new int[] { 0, 1 }), ("x", 9, 10, new int[] { 1, 0 }), - }; + ]; for (int i = 0; i < expectedApply.Count; i++) { @@ -197,15 +197,15 @@ public void CanCompileWithTags() [Fact] public void CanCompileWithExternalSymbols() { - var externalSymbols = new Dictionary() { { "a", 0 }, { "b", 1 } }; + Dictionary externalSymbols = new() { { "a", 0 }, { "b", 1 } }; StateMachine stateMachine = Compile.Build("Main = a b;", externalSymbols); - int[] input = { 0, 0, 1, 1, 0, 1, 0 }; - StateMatch[] matches = stateMachine.Match(input).ToArray(); + int[] input = [0, 0, 1, 1, 0, 1, 0]; + StateMatch[] matches = [.. stateMachine.Match(input)]; - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 1, EndIndex = 2 }, - new StateMatch() { StartIndex = 4, EndIndex = 5 }, + new() { StartIndex = 1, EndIndex = 2 }, + new() { StartIndex = 4, EndIndex = 5 }, }; Assert.True(expected.SequenceEqual(matches)); diff --git a/tests/SixLabors.Fonts.Tests/Unicode/GraphemeEnumeratorTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/GraphemeEnumeratorTests.cs index b4f50c9a3..2485d4130 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/GraphemeEnumeratorTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/GraphemeEnumeratorTests.cs @@ -110,7 +110,7 @@ public bool ICUTestsImpl() string[] lines = File.ReadAllLines(Path.Combine(TestEnvironment.UnicodeTestDataFullPath, "GraphemeBreakTest.txt")); // Process each line - var tests = new List(); + List tests = new(); for (int lineNumber = 1; lineNumber < lines.Length + 1; lineNumber++) { // Get the line, remove comments @@ -122,8 +122,8 @@ public bool ICUTestsImpl() continue; } - var codePoints = new List(); - var breakPoints = new List(); + List codePoints = new(); + List breakPoints = new(); // Parse the test int p = 0; @@ -155,16 +155,16 @@ public bool ICUTestsImpl() p++; } - string codePointStr = line.Substring(codePointPos, p - codePointPos); + string codePointStr = line[codePointPos..p]; uint codePoint = Convert.ToUInt32(codePointStr, 16); codePoints.Add(codePoint); } // Create test - tests.Add(new Test(lineNumber, codePoints.ToArray(), breakPoints.ToArray())); + tests.Add(new Test(lineNumber, [.. codePoints], [.. breakPoints])); } - var foundBreaks = new List + List foundBreaks = new() { Capacity = 100 }; diff --git a/tests/SixLabors.Fonts.Tests/Unicode/LineBreakEnumeratorTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/LineBreakEnumeratorTests.cs index c013797a9..ca7a4fcc2 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/LineBreakEnumeratorTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/LineBreakEnumeratorTests.cs @@ -17,7 +17,7 @@ public class LineBreakEnumeratorTests [Fact] public void BasicLatinTest() { - var lineBreaker = new LineBreakEnumerator("Hello World\r\nThis is a test.".AsSpan()); + LineBreakEnumerator lineBreaker = new("Hello World\r\nThis is a test.".AsSpan()); Assert.True(lineBreaker.MoveNext()); Assert.Equal(6, lineBreaker.Current.PositionWrap); @@ -51,12 +51,7 @@ public void NumericTests() { const string text1 = "Super Smash Bros (1999)"; const string text2 = "Super, Smash Bros (1999)"; - List breaks1 = new(); - - foreach (LineBreak lineBreak in new LineBreakEnumerator(text1.AsSpan())) - { - breaks1.Add(lineBreak); - } + List breaks1 = [.. new LineBreakEnumerator(text1.AsSpan())]; Assert.Equal(5, breaks1[0].PositionMeasure); Assert.Equal(6, breaks1[0].PositionWrap); @@ -67,11 +62,7 @@ public void NumericTests() Assert.Equal(23, breaks1[3].PositionMeasure); Assert.Equal(23, breaks1[3].PositionWrap); - List breaks2 = new(); - foreach (LineBreak lineBreak in new LineBreakEnumerator(text2.AsSpan())) - { - breaks2.Add(lineBreak); - } + List breaks2 = [.. new LineBreakEnumerator(text2.AsSpan())]; Assert.Equal(6, breaks2[0].PositionMeasure); Assert.Equal(7, breaks2[0].PositionWrap); @@ -87,7 +78,7 @@ public void NumericTests() public void ForwardTextWithOuterWhitespace() { string text = " Apples Pears Bananas "; - var breaks = new List(); + List breaks = new(); foreach (LineBreak lineBreak in new LineBreakEnumerator(text.AsSpan())) { @@ -108,7 +99,7 @@ public void ForwardTextWithOuterWhitespace() public void ForwardTest() { string text = "Apples Pears Bananas"; - var breaks = new List(); + List breaks = new(); foreach (LineBreak lineBreak in new LineBreakEnumerator(text.AsSpan())) { @@ -137,7 +128,7 @@ public bool ICUTestsImpl() string[] lines = File.ReadAllLines(Path.Combine(TestEnvironment.UnicodeTestDataFullPath, "LineBreakTest.txt")); // Process each line - var tests = new List(); + List tests = new(); for (int lineNumber = 1; lineNumber < lines.Length + 1; lineNumber++) { // Get the line, remove comments @@ -149,8 +140,8 @@ public bool ICUTestsImpl() continue; } - var codePoints = new List(); - var breakPoints = new List(); + List codePoints = new(); + List breakPoints = new(); // Parse the test int p = 0; @@ -182,17 +173,17 @@ public bool ICUTestsImpl() p++; } - string codePointStr = line.Substring(codePointPos, p - codePointPos); + string codePointStr = line[codePointPos..p]; uint codePoint = Convert.ToUInt32(codePointStr, 16); codePoints.Add(codePoint); } // Create test - var test = new Test(lineNumber, codePoints.ToArray(), breakPoints.ToArray()); + Test test = new(lineNumber, [.. codePoints], [.. breakPoints]); tests.Add(test); } - var foundBreaks = new List(); + List foundBreaks = new(); for (int testNumber = 0; testNumber < tests.Count; testNumber++) { @@ -203,7 +194,7 @@ public bool ICUTestsImpl() // Run the line breaker and build a list of break points string text = Encoding.UTF32.GetString(MemoryMarshal.Cast(t.CodePoints).ToArray()); - var enumerator = new LineBreakEnumerator(text.AsSpan()); + LineBreakEnumerator enumerator = new(text.AsSpan()); while (enumerator.MoveNext()) { foundBreaks.Add(enumerator.Current.PositionWrap); @@ -228,7 +219,7 @@ public bool ICUTestsImpl() if (!pass) { - LineBreakClass[] classes = t.CodePoints.Select(x => UnicodeData.GetLineBreakClass(x)).ToArray(); + LineBreakClass[] classes = [.. t.CodePoints.Select(x => UnicodeData.GetLineBreakClass(x))]; this.output.WriteLine($"Failed test on line {t.LineNumber}"); this.output.WriteLine($" Code Points: {string.Join(" ", t.CodePoints)}"); diff --git a/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs index aca9c65d2..9bd0b4842 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs @@ -11,8 +11,8 @@ namespace SixLabors.Fonts.Tests.Unicode; /// public class UnicodeTrieBuilderTests { - private static readonly TestRange[] TestRanges1 = new TestRange[] - { + private static readonly TestRange[] TestRanges1 = + [ new TestRange(0, 0, 0, false), new TestRange(0, 0x40, 0, false), new TestRange(0x40, 0xe7, 0x1234, false), @@ -28,10 +28,10 @@ public class UnicodeTrieBuilderTests new TestRange(0xf0006, 0xf0007, 0x11, false), new TestRange(0xf0007, 0xf0040, 0x12, false), new TestRange(0xf0040, 0x110000, 0, false) - }; + ]; - private static readonly CheckValue[] CheckValues1 = new CheckValue[] - { + private static readonly CheckValue[] CheckValues1 = + [ new CheckValue(0, 0), new CheckValue(0x40, 0), new CheckValue(0xe7, 0x1234), @@ -48,10 +48,10 @@ public class UnicodeTrieBuilderTests new CheckValue(0xf0007, 0x11), new CheckValue(0xf0040, 0x12), new CheckValue(0x110000, 0), - }; + ]; - private static readonly TestRange[] TestRanges2 = new TestRange[] - { + private static readonly TestRange[] TestRanges2 = + [ new TestRange(0, 0, 0, false), new TestRange(0x21, 0x7f, 0x5555, true), new TestRange(0x2f800, 0x2fedc, 0x7a, true), @@ -65,10 +65,10 @@ public class UnicodeTrieBuilderTests new TestRange(0x2f900, 0x2ffaa, 1, false), new TestRange(0x2ffaa, 0x2ffab, 2, true), new TestRange(0x2ffbb, 0x2ffc0, 7, true), - }; + ]; - private static readonly CheckValue[] CheckValues2 = new CheckValue[] - { + private static readonly CheckValue[] CheckValues2 = + [ new CheckValue(0, 0), new CheckValue(0x21, 0), new CheckValue(0x72, 0x5555), @@ -89,10 +89,10 @@ public class UnicodeTrieBuilderTests new CheckValue(0x2ffbb, 0), new CheckValue(0x2ffc0, 7), new CheckValue(0x110000, 0), - }; + ]; - private static readonly TestRange[] TestRanges3 = new TestRange[] - { + private static readonly TestRange[] TestRanges3 = + [ new TestRange(0, 0, 9, false), // non-zero initial value. new TestRange(0x31, 0xa4, 1, false), new TestRange(0x3400, 0x6789, 2, false), @@ -101,10 +101,10 @@ public class UnicodeTrieBuilderTests new TestRange(0xabcd, 0xbcde, 3, true), new TestRange(0x55555, 0x110000, 6, true), // highStart(); + List offsets = []; foreach ((KnownNameIds name, string value, CultureInfo culture) in names) { writer.WriteUInt16((ushort)PlatformIDs.Windows); // hard code platform @@ -477,7 +477,7 @@ public static void WriteHeadTable(this BigEndianBinaryWriter writer, HeadTable t writer.WriteUInt16((ushort)table.Flags); writer.WriteUInt16(table.UnitsPerEm); - var startDate = new DateTime(1904, 01, 01, 0, 0, 0, DateTimeKind.Utc); + DateTime startDate = new(1904, 01, 01, 0, 0, 0, DateTimeKind.Utc); writer.WriteInt64((long)table.Created.Subtract(startDate).TotalSeconds); writer.WriteInt64((long)table.Modified.Subtract(startDate).TotalSeconds); writer.WriteInt16((short)table.Bounds.Min.X); @@ -565,7 +565,7 @@ public static void WriteVerticalHeadTable(this BigEndianBinaryWriter writer, Ver public static void WriteColrTable(this BigEndianBinaryWriter writer, ColrGlyphRecord[] data) { - var formatted = data.ToList(); + List formatted = [.. data]; // Type | Name | Description // ----------|------------------------|---------------------------------------------------------------------------------------------------- @@ -580,7 +580,7 @@ public static void WriteColrTable(this BigEndianBinaryWriter writer, ColrGlyphRe writer.WriteUInt16((ushort)formatted.Count); uint headerEnd = 14; writer.WriteOffset32(headerEnd); - long baseGlyphEnd = formatted.Sum(x => x.HeaderSize) + headerEnd; + long baseGlyphEnd = formatted.Sum(x => ColrGlyphRecord.HeaderSize) + headerEnd; writer.WriteOffset32((uint)baseGlyphEnd); int layerCount = formatted.Sum(x => x.Layers.Count); writer.WriteUInt16((ushort)layerCount); @@ -609,11 +609,11 @@ public class ColrGlyphRecord { public ushort Glyph { get; set; } - public List Layers { get; set; } = new List(); + public List Layers { get; set; } = []; - public int HeaderSize => 6; + public static int HeaderSize => 6; - public int LayerSize => this.Layers.Sum(x => x.LayerSize); + public int LayerSize => this.Layers.Sum(x => ColrLayerRecord.LayerSize); } public class ColrLayerRecord @@ -622,6 +622,6 @@ public class ColrLayerRecord public ushort Palette { get; set; } - public int LayerSize => 4; + public static int LayerSize => 4; } }