From 4976c3dacc32258efb639cb1bc216f84b52aa038 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 11 Jul 2025 20:56:22 +0200 Subject: [PATCH] Update SharedInfra and apply Style changes --- SixLabors.Fonts.sln | 2 +- samples/DrawWithImageSharp/Program.cs | 18 +- .../DrawWithImageSharp/TextAlignmentSample.cs | 6 +- .../TextAlignmentWrapped.cs | 6 +- samples/ListFonts/Program.cs | 2 +- src/SixLabors.Fonts/ArrayBuilder{T}.cs | 2 +- src/SixLabors.Fonts/Font.cs | 2 +- src/SixLabors.Fonts/FontDescription.cs | 12 +- src/SixLabors.Fonts/FontFamily.cs | 2 +- src/SixLabors.Fonts/FontReader.cs | 10 +- src/SixLabors.Fonts/GlyphMetrics.cs | 4 +- .../GlyphPositioningCollection.cs | 6 +- src/SixLabors.Fonts/GlyphShapingData.cs | 4 +- .../GlyphSubstitutionCollection.cs | 6 +- src/SixLabors.Fonts/StreamFontMetrics.cs | 28 +-- src/SixLabors.Fonts/SystemFontCollection.cs | 2 +- .../ChainedClassSequenceRuleSetTable.cs | 2 +- .../ChainedSequenceRuleSetTable.cs | 2 +- .../ClassSequenceRuleSetTable.cs | 2 +- .../AdvancedTypographic/CoverageTable.cs | 4 +- .../AdvancedTypographic/FeatureListTable.cs | 4 +- .../AdvancedTypographic/GPos/AnchorTable.cs | 4 +- .../AdvancedTypographic/GPos/Class1Record.cs | 2 +- .../GPos/LookupListTable.cs | 4 +- .../GPos/LookupType1SubTable.cs | 8 +- .../GPos/LookupType2SubTable.cs | 14 +- .../GPos/LookupType3SubTable.cs | 6 +- .../GPos/LookupType4SubTable.cs | 8 +- .../GPos/LookupType5SubTable.cs | 8 +- .../GPos/LookupType6SubTable.cs | 8 +- .../Tables/AdvancedTypographic/GPosTable.cs | 8 +- .../GSub/LookupListTable.cs | 4 +- .../GSub/LookupType1SubTable.cs | 4 +- .../GSub/LookupType2SubTable.cs | 4 +- .../GSub/LookupType3SubTable.cs | 4 +- .../GSub/LookupType4SubTable.cs | 6 +- .../GSub/LookupType8SubTable.cs | 2 +- .../Tables/AdvancedTypographic/GSubTable.cs | 8 +- .../AdvancedTypographic/LigatureCaretList.cs | 2 +- .../AdvancedTypographic/LigatureGlyph.cs | 2 +- .../Tables/AdvancedTypographic/ScriptList.cs | 8 +- .../SequenceLookupRecord.cs | 2 +- .../SequenceRuleSetTable.cs | 2 +- .../Shapers/HangulShaper.cs | 8 +- .../Shapers/IndicShaper.cs | 14 +- .../Shapers/UniversalShaper.cs | 6 +- .../AdvancedTypographic/TableLoadingUtils.cs | 6 +- src/SixLabors.Fonts/Tables/Cff/Cff1Table.cs | 2 +- .../Tables/Cff/CffEvaluationEngine.cs | 10 +- .../Tables/Cff/CffGlyphData.cs | 4 +- src/SixLabors.Fonts/Tables/Cff/CffParser.cs | 4 +- .../Tables/Cff/CffTopDictionary.cs | 2 +- src/SixLabors.Fonts/Tables/Cff/RefStack{T}.cs | 2 +- .../Tables/General/CMap/EncodingRecord.cs | 2 +- .../Tables/General/CMap/Format12SubTable.cs | 10 +- .../Tables/General/CMap/Format14SubTable.cs | 10 +- .../Tables/General/CMap/Format4SubTable.cs | 2 +- .../Tables/General/CMapTable.cs | 4 +- .../Tables/General/Colr/ColrTable.cs | 4 +- .../Tables/General/CpalTable.cs | 2 +- .../Tables/General/HeadTable.cs | 4 +- .../Tables/General/Kern/Format0SubTable.cs | 2 +- .../Tables/General/Kern/KerningPair.cs | 13 +- .../Tables/General/Kern/KerningSubTable.cs | 2 +- .../Tables/General/Name/NameRecord.cs | 2 +- .../Tables/General/Name/NameTable.cs | 4 +- .../Tables/General/OS2Table.cs | 4 +- src/SixLabors.Fonts/Tables/TableHeader.cs | 2 +- .../Tables/TripleEncodingTable.cs | 6 +- .../TrueType/Glyphs/CompositeGlyphLoader.cs | 4 +- .../Tables/TrueType/Glyphs/GlyphLoader.cs | 2 +- .../Tables/TrueType/Glyphs/GlyphTable.cs | 2 +- .../Tables/TrueType/Glyphs/GlyphVector.cs | 4 +- .../TrueType/Glyphs/SimpleGlyphLoader.cs | 6 +- .../TrueType/Hinting/TrueTypeInterpreter.cs | 4 +- .../Tables/TrueType/TrueTypeGlyphMetrics.cs | 4 +- src/SixLabors.Fonts/Tables/Woff/Woff2Utils.cs | 16 +- .../Tables/Woff/WoffTableHeader.cs | 8 +- src/SixLabors.Fonts/TextLayout.cs | 16 +- src/SixLabors.Fonts/TextMeasurer.cs | 2 +- .../Unicode/ArabicJoiningClass.cs | 2 +- src/SixLabors.Fonts/Unicode/BidiAlgorithm.cs | 2 +- src/SixLabors.Fonts/Unicode/BidiData.cs | 2 +- .../Unicode/BidiDictionary{T1,T2}.cs | 4 +- src/SixLabors.Fonts/Unicode/CodePoint.cs | 4 +- .../Unicode/LineBreakEnumerator.cs | 2 +- .../Unicode/MemoryExtensions.cs | 4 +- .../Unicode/Resources/IndicShapingData.cs | 20 +- .../Unicode/SpanGraphemeEnumerator.cs | 4 +- src/SixLabors.Fonts/Unicode/UnicodeTrie.cs | 8 +- src/SixLabors.Fonts/Utilities/StringLoader.cs | 4 +- .../Generator.IndicShapingEngine.cs | 4 +- .../StateAutomation/Compile.cs | 2 +- .../StateAutomation/INode.cs | 6 +- tests/SixLabors.Fonts.Tests/Accents.cs | 4 +- .../BigEndianBinaryWriter.cs | 4 +- .../ColorGlyphRenderer.cs | 2 +- .../CompactFontFormatTests.cs | 2 +- tests/SixLabors.Fonts.Tests/FakeFont.cs | 2 +- .../Fakes/FakeFontInstance.cs | 10 +- .../FontCodePointsTests.cs | 4 +- .../FontCollectionTests.cs | 10 +- .../FontDescriptionTests.cs | 42 ++-- .../SixLabors.Fonts.Tests/FontLoaderTests.cs | 10 +- .../SixLabors.Fonts.Tests/FontMetricsTests.cs | 22 +- .../SixLabors.Fonts.Tests/FontReaderTests.cs | 32 +-- .../FontRectangleTests.cs | 72 +++--- tests/SixLabors.Fonts.Tests/FontTests.cs | 8 +- tests/SixLabors.Fonts.Tests/GlyphTests.cs | 32 +-- .../ImageComparison/ExactImageComparer.cs | 2 +- .../Issues/Issues_104.cs | 2 +- .../Issues/Issues_203.cs | 2 +- .../SixLabors.Fonts.Tests/Issues/Issues_23.cs | 2 +- .../SixLabors.Fonts.Tests/Issues/Issues_33.cs | 2 +- .../Issues/Issues_337.cs | 12 +- .../SixLabors.Fonts.Tests/Issues/Issues_39.cs | 4 +- .../SixLabors.Fonts.Tests/Issues/Issues_47.cs | 10 +- .../Native/MacSystemFontsEnumeratorTests.cs | 6 +- .../SystemFontCollectionTests.cs | 2 +- .../GPos/GPosTableTests.cs | 30 +-- .../Gsub/GSubTableTests.Hangul.cs | 2 +- .../Gsub/GSubTableTests.cs | 32 +-- .../General/CMap/Format0SubTableTests.cs | 6 +- .../General/CMap/Format4SubTableTests.cs | 4 +- .../Tables/General/CMapTableTests.cs | 8 +- .../Tables/General/ColrTableTests.cs | 8 +- .../Glyphs/CompositeGlyphLoaderTests.cs | 32 +-- .../Tables/General/Glyphs/GlyphVectorTests.cs | 18 +- .../Tables/General/HeadTableTests.cs | 4 +- .../General/HorizontalHeadTableTests.cs | 8 +- .../Tables/General/IndexLocationTableTests.cs | 12 +- .../Tables/General/KerningTableTests.cs | 6 +- .../General/MaximumProfileTableTests.cs | 4 +- .../Tables/General/NameTableTests.cs | 12 +- .../Tables/General/Os2TableTests.cs | 4 +- .../Tables/General/VerticalHeadTableTests.cs | 8 +- .../Tables/TableHeaderTests.cs | 6 +- .../Tables/TableLoaderTests.cs | 6 +- tests/SixLabors.Fonts.Tests/TestFonts.cs | 2 +- .../TextLayoutTestUtilities.cs | 4 +- .../SixLabors.Fonts.Tests/TextLayoutTests.cs | 226 ++++++++++-------- .../SixLabors.Fonts.Tests/TextOptionsTests.cs | 26 +- .../TrueTypeCollectionTests.cs | 6 +- .../Unicode/BidiAlgorithmTests.cs | 8 +- .../Unicode/BidiCharacterTests.cs | 8 +- .../Unicode/CodePointTests.TestData.cs | 4 +- .../Unicode/CodePointTests.cs | 22 +- .../SixLabors.Fonts.Tests/Unicode/DfaTests.cs | 78 +++--- .../Unicode/GraphemeEnumeratorTests.cs | 8 +- .../Unicode/LineBreakEnumeratorTests.cs | 18 +- .../Unicode/UnicodeTrieBuilderTests.cs | 194 +++++++-------- .../SixLabors.Fonts.Tests/WriterExtensions.cs | 8 +- 152 files changed, 825 insertions(+), 808 deletions(-) diff --git a/SixLabors.Fonts.sln b/SixLabors.Fonts.sln index 7186cdbfa..2d7163293 100644 --- a/SixLabors.Fonts.sln +++ b/SixLabors.Fonts.sln @@ -4,7 +4,6 @@ VisualStudioVersion = 17.2.32519.379 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" ProjectSection(SolutionItems) = preProject - standards\.editorconfig = standards\.editorconfig ci-build.ps1 = ci-build.ps1 ci-pack.ps1 = ci-pack.ps1 ci-test.ps1 = ci-test.ps1 @@ -12,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{C317F1B1 Directory.Build.targets = Directory.Build.targets NuGet.config = NuGet.config README.md = README.md + .editorconfig = .editorconfig EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}" diff --git a/samples/DrawWithImageSharp/Program.cs b/samples/DrawWithImageSharp/Program.cs index 6421cd32b..94de833d7 100644 --- a/samples/DrawWithImageSharp/Program.cs +++ b/samples/DrawWithImageSharp/Program.cs @@ -19,8 +19,8 @@ public static class Program { public static void Main(string[] args) { - var fonts = new FontCollection(); - var woffFonts = new FontCollection(); + FontCollection fonts = new(); + FontCollection woffFonts = new(); 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")); @@ -186,7 +186,7 @@ public static void Main(string[] args) RenderText(jhengHei, " ,;:!¥()?{}-=+\|~!@#%&", 16); RenderText(arial, "ìíîï", 72); #endif - var sb = new StringBuilder(); + StringBuilder sb = new(); for (char c = 'a'; c <= 'z'; c++) { sb.Append(c); @@ -215,7 +215,7 @@ 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); + using Image img = new(width, height); img.Mutate(x => x.Fill(Color.White)); IPathCollection shapes = TextBuilder.GenerateGlyphs(text, new RichTextOptions(font) { Origin = new Vector2(50f, 4f) }); @@ -274,7 +274,7 @@ public static void RenderTextProcessor( 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); + using Image img = new((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"); @@ -306,7 +306,7 @@ public static void RenderTextProcessorWithAlignment( } FontRectangle textSize = TextMeasurer.MeasureSize(text, textOptions); - using var img = new Image(((int)textSize.Width * 2) + 20, ((int)textSize.Height * 2) + 20); + using Image img = new(((int)textSize.Width * 2) + 20, ((int)textSize.Height * 2) + 20); Size size = img.Size; textOptions.Origin = new PointF(size.Width / 2F, size.Height / 2F); @@ -345,7 +345,7 @@ private static void SaveImage( { string fullPath = CreatePath(path); - using var img = new Image(width, height); + using Image img = new(width, height); img.Mutate(x => x.Fill(Color.Black)); img.Mutate(x => x.DrawText(options, text, Color.White)); @@ -363,7 +363,7 @@ public static void SaveImage(this IEnumerable shapes, params string[] pat shape = shape.Translate(shape.Bounds.Location * -1) // touch top left .Translate(new Vector2(10)); // move in from top left - var sb = new StringBuilder(); + StringBuilder sb = new(); IEnumerable converted = shape.Flatten(); converted.Aggregate(sb, (s, p) => { @@ -399,7 +399,7 @@ public static void SaveImage(this IEnumerable shapes, params string[] pat height = 1; } - using var img = new Image(width, height); + using Image img = new(width, height); img.Mutate(x => x.Fill(Color.DarkBlue)); img.Mutate(x => x.Fill(Color.HotPink, shape)); diff --git a/samples/DrawWithImageSharp/TextAlignmentSample.cs b/samples/DrawWithImageSharp/TextAlignmentSample.cs index ea9fd6280..e5ffdaf0c 100644 --- a/samples/DrawWithImageSharp/TextAlignmentSample.cs +++ b/samples/DrawWithImageSharp/TextAlignmentSample.cs @@ -15,7 +15,7 @@ public static class TextAlignmentSample { public static void Generate(Font font) { - using var img = new Image(1000, 1000); + using Image img = new(1000, 1000); img.Mutate(x => x.Fill(Color.White)); foreach (VerticalAlignment v in Enum.GetValues(typeof(VerticalAlignment))) @@ -63,9 +63,9 @@ public static void Draw(Image img, Font font, VerticalAlignment vert, Ho break; } - var glyphBuilder = new CustomGlyphBuilder(); + CustomGlyphBuilder glyphBuilder = new(); - var renderer = new TextRenderer(glyphBuilder); + TextRenderer renderer = new(glyphBuilder); TextOptions textOptions = new(font) { diff --git a/samples/DrawWithImageSharp/TextAlignmentWrapped.cs b/samples/DrawWithImageSharp/TextAlignmentWrapped.cs index 01494ab37..9e75c8e47 100644 --- a/samples/DrawWithImageSharp/TextAlignmentWrapped.cs +++ b/samples/DrawWithImageSharp/TextAlignmentWrapped.cs @@ -18,7 +18,7 @@ public static void Generate(Font font) const int wrappingWidth = 400; const int size = (wrappingWidth + (wrappingWidth / 3)) * 3; - using var img = new Image(size, size); + using Image img = new(size, size); img.Mutate(x => x.Fill(Color.White)); foreach (VerticalAlignment v in Enum.GetValues(typeof(VerticalAlignment))) @@ -66,9 +66,9 @@ public static void Draw(Image img, Font font, VerticalAlignment vert, Ho break; } - var glyphBuilder = new CustomGlyphBuilder(); + CustomGlyphBuilder glyphBuilder = new(); - var renderer = new TextRenderer(glyphBuilder); + TextRenderer renderer = new(glyphBuilder); TextOptions textOptions = new(font) { diff --git a/samples/ListFonts/Program.cs b/samples/ListFonts/Program.cs index d76588502..fbce579aa 100644 --- a/samples/ListFonts/Program.cs +++ b/samples/ListFonts/Program.cs @@ -10,7 +10,7 @@ public static class Program { public static void Main(string[] args) { - var pairings = new List(); + List pairings = new(); IOrderedEnumerable ordered = SystemFonts.Families.OrderBy(x => x.Name); foreach (FontFamily family in ordered) { diff --git a/src/SixLabors.Fonts/ArrayBuilder{T}.cs b/src/SixLabors.Fonts/ArrayBuilder{T}.cs index e55c20e43..068154e5b 100644 --- a/src/SixLabors.Fonts/ArrayBuilder{T}.cs +++ b/src/SixLabors.Fonts/ArrayBuilder{T}.cs @@ -153,7 +153,7 @@ private void EnsureCapacity(int min) newCapacity = (uint)min; } - var array = new T[newCapacity]; + T[] array = new T[newCapacity]; if (this.size > 0) { diff --git a/src/SixLabors.Fonts/Font.cs b/src/SixLabors.Fonts/Font.cs index 706f9c440..950bce45e 100644 --- a/src/SixLabors.Fonts/Font.cs +++ b/src/SixLabors.Fonts/Font.cs @@ -241,7 +241,7 @@ public bool TryGetGlyphs( List g = new(); foreach (GlyphMetrics metric in metrics) { - g.Add(new(metric.CloneForRendering(textRun), this.Size)); + g.Add(new Glyph(metric.CloneForRendering(textRun), this.Size)); } glyphs = g; diff --git a/src/SixLabors.Fonts/FontDescription.cs b/src/SixLabors.Fonts/FontDescription.cs index da0d75d40..59a5ee4cd 100644 --- a/src/SixLabors.Fonts/FontDescription.cs +++ b/src/SixLabors.Fonts/FontDescription.cs @@ -92,7 +92,7 @@ public static FontDescription LoadDescription(string path) Guard.NotNullOrWhiteSpace(path, nameof(path)); using FileStream fs = File.OpenRead(path); - using var reader = new FontReader(fs); + using FontReader reader = new(fs); return LoadDescription(reader); } @@ -106,7 +106,7 @@ public static FontDescription LoadDescription(Stream stream) Guard.NotNull(stream, nameof(stream)); // Only read the name tables. - using var reader = new FontReader(stream); + using FontReader reader = new(stream); return LoadDescription(reader); } @@ -152,14 +152,14 @@ public static FontDescription[] LoadFontCollectionDescriptions(string path) public static FontDescription[] LoadFontCollectionDescriptions(Stream stream) { long startPos = stream.Position; - using var reader = new BigEndianBinaryReader(stream, true); - var ttcHeader = TtcHeader.Read(reader); + using BigEndianBinaryReader reader = new(stream, true); + TtcHeader ttcHeader = TtcHeader.Read(reader); - var result = new FontDescription[(int)ttcHeader.NumFonts]; + FontDescription[] result = new FontDescription[(int)ttcHeader.NumFonts]; for (int i = 0; i < ttcHeader.NumFonts; ++i) { stream.Position = startPos + ttcHeader.OffsetTable[i]; - using var fontReader = new FontReader(stream); + using FontReader fontReader = new(stream); result[i] = LoadDescription(fontReader); } diff --git a/src/SixLabors.Fonts/FontFamily.cs b/src/SixLabors.Fonts/FontFamily.cs index 6ccf655b5..09785c37d 100644 --- a/src/SixLabors.Fonts/FontFamily.cs +++ b/src/SixLabors.Fonts/FontFamily.cs @@ -126,7 +126,7 @@ public bool TryGetPaths(out IEnumerable paths) FontsThrowHelper.ThrowDefaultInstance(); } - var filePaths = new List(); + List filePaths = new(); foreach (FontStyle style in this.GetAvailableStyles()) { if (this.collection.TryGetMetrics(this.Name, this.Culture, style, out FontMetrics? metrics) diff --git a/src/SixLabors.Fonts/FontReader.cs b/src/SixLabors.Fonts/FontReader.cs index 2c27ef409..957d703e9 100644 --- a/src/SixLabors.Fonts/FontReader.cs +++ b/src/SixLabors.Fonts/FontReader.cs @@ -25,7 +25,7 @@ internal FontReader(Stream stream, TableLoader loader) Func loadHeader = TableHeader.Read; this.stream = stream; - using var reader = new BigEndianBinaryReader(stream, true); + using BigEndianBinaryReader reader = new(stream, true); // we should immediately read the table header to learn which tables we have and what order they are in uint version = reader.ReadUInt32(); @@ -90,9 +90,9 @@ internal FontReader(Stream stream, TableLoader loader) this.isOwnedStream = true; byte[] compressedBuffer = reader.ReadBytes((int)totalCompressedSize); - var decompressedStream = new MemoryStream(); - using var input = new MemoryStream(compressedBuffer); - using var decompressor = new BrotliStream(input, CompressionMode.Decompress); + MemoryStream decompressedStream = new(); + using MemoryStream input = new(compressedBuffer); + using BrotliStream decompressor = new(input, CompressionMode.Decompress); decompressor.CopyTo(decompressedStream); decompressedStream.Position = 0; this.stream = decompressedStream; @@ -111,7 +111,7 @@ internal FontReader(Stream stream, TableLoader loader) this.CompressedTableData = false; } - var headers = new Dictionary(tableCount); + Dictionary headers = new(tableCount); for (int i = 0; i < tableCount; i++) { TableHeader tbl = loadHeader(reader); diff --git a/src/SixLabors.Fonts/GlyphMetrics.cs b/src/SixLabors.Fonts/GlyphMetrics.cs index 582193480..dee4d887a 100644 --- a/src/SixLabors.Fonts/GlyphMetrics.cs +++ b/src/SixLabors.Fonts/GlyphMetrics.cs @@ -54,13 +54,13 @@ internal GlyphMetrics( { float units = this.UnitsPerEm; scaleFactor /= new Vector2(font.SubscriptXSize / units, font.SubscriptYSize / units); - offset = new(font.SubscriptXOffset, font.SubscriptYOffset < 0 ? font.SubscriptYOffset : -font.SubscriptYOffset); + offset = new Vector2(font.SubscriptXOffset, font.SubscriptYOffset < 0 ? font.SubscriptYOffset : -font.SubscriptYOffset); } else if ((textAttributes & TextAttributes.Superscript) == TextAttributes.Superscript) { float units = this.UnitsPerEm; scaleFactor /= new Vector2(font.SuperscriptXSize / units, font.SuperscriptYSize / units); - offset = new(font.SuperscriptXOffset, font.SuperscriptYOffset < 0 ? -font.SuperscriptYOffset : font.SuperscriptYOffset); + offset = new Vector2(font.SuperscriptXOffset, font.SuperscriptYOffset < 0 ? -font.SuperscriptYOffset : font.SuperscriptYOffset); } this.ScaleFactor = scaleFactor; diff --git a/src/SixLabors.Fonts/GlyphPositioningCollection.cs b/src/SixLabors.Fonts/GlyphPositioningCollection.cs index ffb61a9fc..5c2b78edf 100644 --- a/src/SixLabors.Fonts/GlyphPositioningCollection.cs +++ b/src/SixLabors.Fonts/GlyphPositioningCollection.cs @@ -204,7 +204,7 @@ public bool TryUpdate(Font font, GlyphSubstitutionCollection collection) maxAdvancedHeight = Math.Max(maxAdvancedHeight, metrics[k].AdvanceHeight); } - this.glyphs.Insert(i += replacementCount, new(offset, new(shape, true) { Bounds = new(0, 0, maxAdvancedWidth, maxAdvancedHeight) }, pointSize, metrics.ToArray())); + this.glyphs.Insert(i += replacementCount, new GlyphPositioningData(offset, new GlyphShapingData(shape, true) { Bounds = new GlyphShapingBounds(0, 0, maxAdvancedWidth, maxAdvancedHeight) }, pointSize, metrics.ToArray())); replacementCount++; } } @@ -279,11 +279,11 @@ public bool TryAdd(Font font, GlyphSubstitutionCollection collection) GlyphMetrics[] gm = metrics.ToArray(); if (isVertical) { - this.glyphs.Add(new(offset, new(data, true) { Bounds = new(0, 0, 0, gm[0].AdvanceHeight) }, font.Size, gm)); + this.glyphs.Add(new GlyphPositioningData(offset, new GlyphShapingData(data, true) { Bounds = new GlyphShapingBounds(0, 0, 0, gm[0].AdvanceHeight) }, font.Size, gm)); } else { - this.glyphs.Add(new(offset, new(data, true) { Bounds = new(0, 0, gm[0].AdvanceWidth, 0) }, font.Size, gm)); + this.glyphs.Add(new GlyphPositioningData(offset, new GlyphShapingData(data, true) { Bounds = new GlyphShapingBounds(0, 0, gm[0].AdvanceWidth, 0) }, font.Size, gm)); } } } diff --git a/src/SixLabors.Fonts/GlyphShapingData.cs b/src/SixLabors.Fonts/GlyphShapingData.cs index 8b7b2aab7..c68594269 100644 --- a/src/SixLabors.Fonts/GlyphShapingData.cs +++ b/src/SixLabors.Fonts/GlyphShapingData.cs @@ -41,7 +41,7 @@ public GlyphShapingData(GlyphShapingData data, bool clearFeatures = false) this.IsDecomposed = data.IsDecomposed; if (data.UniversalShapingEngineInfo != null) { - this.UniversalShapingEngineInfo = new( + this.UniversalShapingEngineInfo = new UniversalShapingEngineInfo( data.UniversalShapingEngineInfo.Category, data.UniversalShapingEngineInfo.SyllableType, data.UniversalShapingEngineInfo.Syllable); @@ -49,7 +49,7 @@ public GlyphShapingData(GlyphShapingData data, bool clearFeatures = false) if (data.IndicShapingEngineInfo != null) { - this.IndicShapingEngineInfo = new( + this.IndicShapingEngineInfo = new IndicShapingEngineInfo( data.IndicShapingEngineInfo.Category, data.IndicShapingEngineInfo.Position, data.IndicShapingEngineInfo.SyllableType, diff --git a/src/SixLabors.Fonts/GlyphSubstitutionCollection.cs b/src/SixLabors.Fonts/GlyphSubstitutionCollection.cs index f213b6810..bd17f14d3 100644 --- a/src/SixLabors.Fonts/GlyphSubstitutionCollection.cs +++ b/src/SixLabors.Fonts/GlyphSubstitutionCollection.cs @@ -101,7 +101,7 @@ public void DisableShapingFeature(int index, Tag feature) /// The data. /// The zero-based index within the input codepoint collection. public void AddGlyph(GlyphShapingData data, int offset) - => this.glyphs.Add(new(offset, new(data, false))); + => this.glyphs.Add(new OffsetGlyphDataPair(offset, new GlyphShapingData(data, false))); /// /// Adds the glyph id and the codepoint it represents to the collection. @@ -112,7 +112,7 @@ public void AddGlyph(GlyphShapingData data, int offset) /// The text run this glyph belongs to. /// The zero-based index within the input codepoint collection. public void AddGlyph(ushort glyphId, CodePoint codePoint, TextDirection direction, TextRun textRun, int offset) - => this.glyphs.Add(new(offset, new(textRun) + => this.glyphs.Add(new OffsetGlyphDataPair(offset, new GlyphShapingData(textRun) { CodePoint = codePoint, Direction = direction, @@ -363,7 +363,7 @@ public void Replace(int index, ReadOnlySpan glyphIds, Tag feature) data.AppliedFeatures.Add(feature); - this.glyphs.Insert(++index, new(pair.Offset, data)); + this.glyphs.Insert(++index, new OffsetGlyphDataPair(pair.Offset, data)); } } } diff --git a/src/SixLabors.Fonts/StreamFontMetrics.cs b/src/SixLabors.Fonts/StreamFontMetrics.cs index 014b0fcb0..2a4b91b24 100644 --- a/src/SixLabors.Fonts/StreamFontMetrics.cs +++ b/src/SixLabors.Fonts/StreamFontMetrics.cs @@ -61,12 +61,12 @@ internal StreamFontMetrics(TrueTypeFontTables tables) this.trueTypeFontTables = tables; this.outlineType = OutlineType.TrueType; this.description = new FontDescription(tables.Name, tables.Os2, tables.Head); - this.glyphIdCache = new(); - this.codePointCache = new(); - this.glyphCache = new(); + this.glyphIdCache = new ConcurrentDictionary<(int CodePoint, int NextCodePoint), (bool Success, ushort GlyphId, bool SkipNextCodePoint)>(); + this.codePointCache = new ConcurrentDictionary(); + this.glyphCache = new ConcurrentDictionary<(int CodePoint, ushort Id, TextAttributes Attributes, bool IsVerticalLayout), GlyphMetrics[]>(); if (tables.Colr is not null) { - this.colorGlyphCache = new(); + this.colorGlyphCache = new ConcurrentDictionary<(int CodePoint, ushort Id, TextAttributes Attributes, bool IsVerticalLayout), GlyphMetrics[]>(); } (HorizontalMetrics HorizontalMetrics, VerticalMetrics VerticalMetrics) metrics = this.Initialize(tables); @@ -83,12 +83,12 @@ internal StreamFontMetrics(CompactFontTables tables) this.compactFontTables = tables; this.outlineType = OutlineType.CFF; this.description = new FontDescription(tables.Name, tables.Os2, tables.Head); - this.glyphIdCache = new(); - this.codePointCache = new(); - this.glyphCache = new(); + this.glyphIdCache = new ConcurrentDictionary<(int CodePoint, int NextCodePoint), (bool Success, ushort GlyphId, bool SkipNextCodePoint)>(); + this.codePointCache = new ConcurrentDictionary(); + this.glyphCache = new ConcurrentDictionary<(int CodePoint, ushort Id, TextAttributes Attributes, bool IsVerticalLayout), GlyphMetrics[]>(); if (tables.Colr is not null) { - this.colorGlyphCache = new(); + this.colorGlyphCache = new ConcurrentDictionary<(int CodePoint, ushort Id, TextAttributes Attributes, bool IsVerticalLayout), GlyphMetrics[]>(); } (HorizontalMetrics HorizontalMetrics, VerticalMetrics VerticalMetrics) metrics = this.Initialize(tables); @@ -356,7 +356,7 @@ internal override void UpdatePositions(GlyphPositioningCollection collection) public static StreamFontMetrics LoadFont(string path) { using FileStream fs = File.OpenRead(path); - using var reader = new FontReader(fs); + using FontReader reader = new(fs); return LoadFont(reader); } @@ -380,7 +380,7 @@ public static StreamFontMetrics LoadFont(string path, long offset) /// a . public static StreamFontMetrics LoadFont(Stream stream) { - using var reader = new FontReader(stream); + using FontReader reader = new(stream); return LoadFont(reader); } @@ -482,7 +482,7 @@ private static HorizontalMetrics InitializeHorizontalMetrics(HorizontalHeadTable advanceWidthMax = (short)hhea.AdvanceWidthMax; advanceHeightMax = vhea == null ? lineHeight : vhea.AdvanceHeightMax; - return new() + return new HorizontalMetrics { Ascender = ascender, Descender = descender, @@ -546,9 +546,9 @@ public static StreamFontMetrics[] LoadFontCollection(string path) public static StreamFontMetrics[] LoadFontCollection(Stream stream) { long startPos = stream.Position; - var reader = new BigEndianBinaryReader(stream, true); - var ttcHeader = TtcHeader.Read(reader); - var fonts = new StreamFontMetrics[(int)ttcHeader.NumFonts]; + BigEndianBinaryReader reader = new(stream, true); + TtcHeader ttcHeader = TtcHeader.Read(reader); + StreamFontMetrics[] fonts = new StreamFontMetrics[(int)ttcHeader.NumFonts]; for (int i = 0; i < ttcHeader.NumFonts; ++i) { diff --git a/src/SixLabors.Fonts/SystemFontCollection.cs b/src/SixLabors.Fonts/SystemFontCollection.cs index 877b2cac6..f130f4392 100644 --- a/src/SixLabors.Fonts/SystemFontCollection.cs +++ b/src/SixLabors.Fonts/SystemFontCollection.cs @@ -144,7 +144,7 @@ IEnumerator IReadOnlyFontMetricsCollection.GetEnumerator() private static FontCollection CreateSystemFontCollection(IEnumerable paths, IReadOnlyCollection searchDirectories) { - var collection = new FontCollection(searchDirectories); + FontCollection collection = new(searchDirectories); foreach (string path in paths) { diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedClassSequenceRuleSetTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedClassSequenceRuleSetTable.cs index c2c854578..ded6d5601 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedClassSequenceRuleSetTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedClassSequenceRuleSetTable.cs @@ -28,7 +28,7 @@ public static ChainedClassSequenceRuleSetTable Load(BigEndianBinaryReader reader Span seqRuleOffsets = seqRuleOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(seqRuleOffsets); - var subRules = new ChainedClassSequenceRuleTable[seqRuleCount]; + ChainedClassSequenceRuleTable[] subRules = new ChainedClassSequenceRuleTable[seqRuleCount]; for (int i = 0; i < subRules.Length; i++) { subRules[i] = ChainedClassSequenceRuleTable.Load(reader, offset + seqRuleOffsets[i]); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedSequenceRuleSetTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedSequenceRuleSetTable.cs index cabbbf501..20cdd6365 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedSequenceRuleSetTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ChainedSequenceRuleSetTable.cs @@ -28,7 +28,7 @@ public static ChainedSequenceRuleSetTable Load(BigEndianBinaryReader reader, lon Span chainedSeqRuleOffsets = chainedSeqRuleOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(chainedSeqRuleOffsets); - var chainedSequenceRules = new ChainedSequenceRuleTable[chainedSeqRuleCount]; + ChainedSequenceRuleTable[] chainedSequenceRules = new ChainedSequenceRuleTable[chainedSeqRuleCount]; for (int i = 0; i < chainedSequenceRules.Length; i++) { chainedSequenceRules[i] = ChainedSequenceRuleTable.Load(reader, offset + chainedSeqRuleOffsets[i]); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ClassSequenceRuleSetTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ClassSequenceRuleSetTable.cs index e3b282f76..691ea0ce6 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ClassSequenceRuleSetTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ClassSequenceRuleSetTable.cs @@ -35,7 +35,7 @@ public static ClassSequenceRuleSetTable Load(BigEndianBinaryReader reader, long Span seqRuleOffsets = seqRuleOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(seqRuleOffsets); - var subRules = new ClassSequenceRuleTable[seqRuleCount]; + ClassSequenceRuleTable[] subRules = new ClassSequenceRuleTable[seqRuleCount]; for (int i = 0; i < subRules.Length; i++) { subRules[i] = ClassSequenceRuleTable.Load(reader, offset + seqRuleOffsets[i]); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/CoverageTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/CoverageTable.cs index b0839cb17..a613200e9 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/CoverageTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/CoverageTable.cs @@ -29,7 +29,7 @@ public static CoverageTable Load(BigEndianBinaryReader reader, long offset) public static CoverageTable[] LoadArray(BigEndianBinaryReader reader, long offset, ReadOnlySpan coverageOffsets) { - var tables = new CoverageTable[coverageOffsets.Length]; + CoverageTable[] tables = new CoverageTable[coverageOffsets.Length]; for (int i = 0; i < tables.Length; i++) { tables[i] = Load(reader, offset + coverageOffsets[i]); @@ -103,7 +103,7 @@ public static CoverageFormat2Table Load(BigEndianBinaryReader reader) // | RangeRecord | rangeRecords[rangeCount] | Array of glyph ranges — ordered by startGlyphID. | // +-------------+--------------------------+--------------------------------------------------+ ushort rangeCount = reader.ReadUInt16(); - var records = new CoverageRangeRecord[rangeCount]; + CoverageRangeRecord[] records = new CoverageRangeRecord[rangeCount]; for (int i = 0; i < records.Length; i++) { diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/FeatureListTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/FeatureListTable.cs index ba6f5d44f..69ab299e9 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/FeatureListTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/FeatureListTable.cs @@ -33,7 +33,7 @@ public static FeatureListTable Load(BigEndianBinaryReader reader, long offset) reader.Seek(offset, SeekOrigin.Begin); ushort featureCount = reader.ReadUInt16(); - var featureRecords = new FeatureRecord[featureCount]; + FeatureRecord[] featureRecords = new FeatureRecord[featureCount]; for (int i = 0; i < featureRecords.Length; i++) { // FeatureRecord @@ -51,7 +51,7 @@ public static FeatureListTable Load(BigEndianBinaryReader reader, long offset) // Load the other table features. // We do this last to avoid excessive seeking. - var featureTables = new FeatureTable[featureCount]; + FeatureTable[] featureTables = new FeatureTable[featureCount]; for (int i = 0; i < featureTables.Length; i++) { FeatureRecord featureRecord = featureRecords[i]; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/AnchorTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/AnchorTable.cs index 870e62b3e..568a748f0 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/AnchorTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/AnchorTable.cs @@ -133,13 +133,13 @@ public override AnchorXY GetAnchor(FontMetrics fontMetrics, GlyphShapingData dat if (this.anchorPointIndex < points.Count) { Vector2 point = points[this.anchorPointIndex].Point; - return new((short)point.X, (short)point.Y); + return new AnchorXY((short)point.X, (short)point.Y); } } } } - return new(this.XCoordinate, this.YCoordinate); + return new AnchorXY(this.XCoordinate, this.YCoordinate); } } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/Class1Record.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/Class1Record.cs index 27cbd260a..5ab8641b5 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/Class1Record.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/Class1Record.cs @@ -17,7 +17,7 @@ public static Class1Record Load(BigEndianBinaryReader reader, int class2Count, V // | Class2Record | class2Records[class2Count] | Array of Class2 records, ordered by classes | // | | | in classDef2. | // +--------------+----------------------------+---------------------------------------------+ - var class2Records = new Class2Record[class2Count]; + Class2Record[] class2Records = new Class2Record[class2Count]; for (int i = 0; i < class2Records.Length; i++) { class2Records[i] = new Class2Record(reader, valueFormat1, valueFormat2); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupListTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupListTable.cs index 2b65f424b..29a3b1fd3 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupListTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupListTable.cs @@ -38,7 +38,7 @@ public static LookupListTable Load(BigEndianBinaryReader reader, long offset) Span lookupOffsets = lookupOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(lookupOffsets); - var lookupTables = new LookupTable[lookupCount]; + LookupTable[] lookupTables = new LookupTable[lookupCount]; for (int i = 0; i < lookupTables.Length; i++) { @@ -111,7 +111,7 @@ public static LookupTable Load(BigEndianBinaryReader reader, long offset) ? reader.ReadUInt16() : (ushort)0; - var lookupSubTables = new LookupSubTable[subTableCount]; + LookupSubTable[] lookupSubTables = new LookupSubTable[subTableCount]; for (int i = 0; i < lookupSubTables.Length; i++) { diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType1SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType1SubTable.cs index e5307d754..f120dc5f7 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType1SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType1SubTable.cs @@ -56,9 +56,9 @@ public static LookupType1Format1SubTable Load(BigEndianBinaryReader reader, long // +-------------+----------------+-----------------------------------------------+ ushort coverageOffset = reader.ReadOffset16(); ValueFormat valueFormat = reader.ReadUInt16(); - var valueRecord = new ValueRecord(reader, valueFormat); + ValueRecord valueRecord = new(reader, valueFormat); - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType1Format1SubTable(valueRecord, coverageTable, lookupFlags); } @@ -123,13 +123,13 @@ public static LookupType1Format2SubTable Load(BigEndianBinaryReader reader, long ushort coverageOffset = reader.ReadOffset16(); ValueFormat valueFormat = reader.ReadUInt16(); ushort valueCount = reader.ReadUInt16(); - var valueRecords = new ValueRecord[valueCount]; + ValueRecord[] valueRecords = new ValueRecord[valueCount]; for (int i = 0; i < valueCount; i++) { valueRecords[i] = new ValueRecord(reader, valueFormat); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType1Format2SubTable(valueRecords, coverageTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType2SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType2SubTable.cs index ecf296a74..b626c6f6b 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType2SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType2SubTable.cs @@ -73,14 +73,14 @@ public static LookupType2Format1SubTable Load(BigEndianBinaryReader reader, long Span pairSetOffsets = pairSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(pairSetOffsets); - var pairSets = new PairSetTable[pairSetCount]; + PairSetTable[] pairSets = new PairSetTable[pairSetCount]; for (int i = 0; i < pairSetCount; i++) { reader.Seek(offset + pairSetOffsets[i], SeekOrigin.Begin); pairSets[i] = PairSetTable.Load(reader, offset + pairSetOffsets[i], valueFormat1, valueFormat2); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType2Format1SubTable(coverageTable, pairSets, lookupFlags); } @@ -148,7 +148,7 @@ public static PairSetTable Load(BigEndianBinaryReader reader, long offset, Value // +-----------------+----------------------------------+---------------------------------------+ reader.Seek(offset, SeekOrigin.Begin); ushort pairValueCount = reader.ReadUInt16(); - var pairValueRecords = new PairValueRecord[pairValueCount]; + PairValueRecord[] pairValueRecords = new PairValueRecord[pairValueCount]; for (int i = 0; i < pairValueRecords.Length; i++) { pairValueRecords[i] = new PairValueRecord(reader, valueFormat1, valueFormat2); @@ -237,15 +237,15 @@ public static LookupType2Format2SubTable Load(BigEndianBinaryReader reader, long ushort class1Count = reader.ReadUInt16(); ushort class2Count = reader.ReadUInt16(); - var class1Records = new Class1Record[class1Count]; + Class1Record[] class1Records = new Class1Record[class1Count]; for (int i = 0; i < class1Records.Length; i++) { class1Records[i] = Class1Record.Load(reader, class2Count, valueFormat1, valueFormat2); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); - var classDefTable1 = ClassDefinitionTable.Load(reader, offset + classDef1Offset); - var classDefTable2 = ClassDefinitionTable.Load(reader, offset + classDef2Offset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + ClassDefinitionTable classDefTable1 = ClassDefinitionTable.Load(reader, offset + classDef1Offset); + ClassDefinitionTable classDefTable2 = ClassDefinitionTable.Load(reader, offset + classDef2Offset); return new LookupType2Format2SubTable(coverageTable, class1Records, classDefTable1, classDefTable2, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType3SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType3SubTable.cs index 8909bfbab..e30896dbd 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType3SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType3SubTable.cs @@ -53,19 +53,19 @@ public static LookupType3Format1SubTable Load(BigEndianBinaryReader reader, long // +--------------------+---------------------------------+------------------------------------------------------+ ushort coverageOffset = reader.ReadOffset16(); ushort entryExitCount = reader.ReadUInt16(); - var entryExitRecords = new EntryExitRecord[entryExitCount]; + EntryExitRecord[] entryExitRecords = new EntryExitRecord[entryExitCount]; for (int i = 0; i < entryExitCount; i++) { entryExitRecords[i] = new EntryExitRecord(reader, offset); } - var entryExitAnchors = new EntryExitAnchors[entryExitCount]; + EntryExitAnchors[] entryExitAnchors = new EntryExitAnchors[entryExitCount]; for (int i = 0; i < entryExitCount; i++) { entryExitAnchors[i] = new EntryExitAnchors(reader, offset, entryExitRecords[i]); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType3Format1SubTable(coverageTable, entryExitAnchors, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs index 24a05cb39..b7b8d3fae 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs @@ -71,10 +71,10 @@ public static LookupType4Format1SubTable Load(BigEndianBinaryReader reader, long ushort markArrayOffset = reader.ReadOffset16(); ushort baseArrayOffset = reader.ReadOffset16(); - var markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset); - var baseCoverage = CoverageTable.Load(reader, offset + baseCoverageOffset); - var markArrayTable = new MarkArrayTable(reader, offset + markArrayOffset); - var baseArrayTable = new BaseArrayTable(reader, offset + baseArrayOffset, markClassCount); + CoverageTable markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset); + CoverageTable baseCoverage = CoverageTable.Load(reader, offset + baseCoverageOffset); + MarkArrayTable markArrayTable = new(reader, offset + markArrayOffset); + BaseArrayTable baseArrayTable = new(reader, offset + baseArrayOffset, markClassCount); return new LookupType4Format1SubTable(markCoverage, baseCoverage, markArrayTable, baseArrayTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType5SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType5SubTable.cs index 4db3872e6..925cf79c1 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType5SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType5SubTable.cs @@ -74,10 +74,10 @@ public static LookupType5Format1SubTable Load(BigEndianBinaryReader reader, long ushort markArrayOffset = reader.ReadOffset16(); ushort ligatureArrayOffset = reader.ReadOffset16(); - var markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset); - var ligatureCoverage = CoverageTable.Load(reader, offset + ligatureCoverageOffset); - var markArrayTable = new MarkArrayTable(reader, offset + markArrayOffset); - var ligatureArrayTable = new LigatureArrayTable(reader, offset + ligatureArrayOffset, markClassCount); + CoverageTable markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset); + CoverageTable ligatureCoverage = CoverageTable.Load(reader, offset + ligatureCoverageOffset); + MarkArrayTable markArrayTable = new(reader, offset + markArrayOffset); + LigatureArrayTable ligatureArrayTable = new(reader, offset + ligatureArrayOffset, markClassCount); return new LookupType5Format1SubTable(markCoverage, ligatureCoverage, markArrayTable, ligatureArrayTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType6SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType6SubTable.cs index 2bc1f6d6e..1bfab19ce 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType6SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType6SubTable.cs @@ -73,10 +73,10 @@ public static LookupType6Format1SubTable Load(BigEndianBinaryReader reader, long ushort mark1ArrayOffset = reader.ReadOffset16(); ushort mark2ArrayOffset = reader.ReadOffset16(); - var mark1Coverage = CoverageTable.Load(reader, offset + mark1CoverageOffset); - var mark2Coverage = CoverageTable.Load(reader, offset + mark2CoverageOffset); - var mark1ArrayTable = new MarkArrayTable(reader, offset + mark1ArrayOffset); - var mark2ArrayTable = new Mark2ArrayTable(reader, markClassCount, offset + mark2ArrayOffset); + CoverageTable mark1Coverage = CoverageTable.Load(reader, offset + mark1CoverageOffset); + CoverageTable mark2Coverage = CoverageTable.Load(reader, offset + mark2CoverageOffset); + MarkArrayTable mark1ArrayTable = new(reader, offset + mark1ArrayOffset); + Mark2ArrayTable mark2ArrayTable = new(reader, markClassCount, offset + mark2ArrayOffset); return new LookupType6Format1SubTable(mark1Coverage, mark2Coverage, mark1ArrayTable, mark2ArrayTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPosTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPosTable.cs index 7a2759b7e..012c3fbb0 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPosTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GPosTable.cs @@ -89,11 +89,11 @@ internal static GPosTable Load(BigEndianBinaryReader reader) uint featureVariationsOffset = (minorVersion == 1) ? reader.ReadOffset32() : 0; // TODO: Optimization. Allow only reading the scriptList. - var scriptList = ScriptList.Load(reader, scriptListOffset); + ScriptList? scriptList = ScriptList.Load(reader, scriptListOffset); - var featureList = FeatureListTable.Load(reader, featureListOffset); + FeatureListTable featureList = FeatureListTable.Load(reader, featureListOffset); - var lookupList = LookupListTable.Load(reader, lookupListOffset); + LookupListTable lookupList = LookupListTable.Load(reader, lookupListOffset); // TODO: Feature Variations. return new GPosTable(scriptList, featureList, lookupList); @@ -291,7 +291,7 @@ private Tag GetUnicodeScriptTag(ScriptClass script) { ushort lookupIndex = lookupListIndices[k]; LookupTable lookupTable = this.LookupList.LookupTables[lookupIndex]; - lookups.Add(new(feature, lookupIndex, lookupTable)); + lookups.Add((feature, lookupIndex, lookupTable)); } } } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupListTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupListTable.cs index f924aa2df..d4e3a94a3 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupListTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupListTable.cs @@ -38,7 +38,7 @@ public static LookupListTable Load(BigEndianBinaryReader reader, long offset) Span lookupOffsets = lookupOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(lookupOffsets); - var lookupTables = new LookupTable[lookupCount]; + LookupTable[] lookupTables = new LookupTable[lookupCount]; for (int i = 0; i < lookupTables.Length; i++) { @@ -111,7 +111,7 @@ public static LookupTable Load(BigEndianBinaryReader reader, long offset) ? reader.ReadUInt16() : (ushort)0; - var lookupSubTables = new LookupSubTable[subTableCount]; + LookupSubTable[] lookupSubTables = new LookupSubTable[subTableCount]; for (int i = 0; i < lookupSubTables.Length; i++) { diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType1SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType1SubTable.cs index 81ebdf260..01442e336 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType1SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType1SubTable.cs @@ -53,7 +53,7 @@ public static LookupType1Format1SubTable Load(BigEndianBinaryReader reader, long // +----------+----------------+----------------------------------------------------------+ ushort coverageOffset = reader.ReadOffset16(); ushort deltaGlyphId = reader.ReadUInt16(); - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType1Format1SubTable(deltaGlyphId, coverageTable, lookupFlags); } @@ -112,7 +112,7 @@ public static LookupType1Format2SubTable Load(BigEndianBinaryReader reader, long ushort coverageOffset = reader.ReadOffset16(); ushort glyphCount = reader.ReadUInt16(); ushort[] substituteGlyphIds = reader.ReadUInt16Array(glyphCount); - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType1Format2SubTable(substituteGlyphIds, coverageTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType2SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType2SubTable.cs index d01b076ae..633c21f06 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType2SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType2SubTable.cs @@ -58,7 +58,7 @@ public static LookupType2Format1SubTable Load(BigEndianBinaryReader reader, long Span sequenceOffsets = sequenceOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(sequenceOffsets); - var sequenceTables = new SequenceTable[sequenceCount]; + SequenceTable[] sequenceTables = new SequenceTable[sequenceCount]; for (int i = 0; i < sequenceTables.Length; i++) { // Sequence Table @@ -75,7 +75,7 @@ public static LookupType2Format1SubTable Load(BigEndianBinaryReader reader, long sequenceTables[i] = new SequenceTable(reader.ReadUInt16Array(glyphCount)); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType2Format1SubTable(sequenceTables, coverageTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType3SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType3SubTable.cs index 60c79d998..7ce27008f 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType3SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType3SubTable.cs @@ -58,7 +58,7 @@ public static LookupType3Format1SubTable Load(BigEndianBinaryReader reader, long Span alternateSetOffsets = alternateSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(alternateSetOffsets); - var alternateTables = new AlternateSetTable[alternateSetCount]; + AlternateSetTable[] alternateTables = new AlternateSetTable[alternateSetCount]; for (int i = 0; i < alternateTables.Length; i++) { // AlternateSet Table @@ -74,7 +74,7 @@ public static LookupType3Format1SubTable Load(BigEndianBinaryReader reader, long alternateTables[i] = new AlternateSetTable(reader.ReadUInt16Array(glyphCount)); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType3Format1SubTable(alternateTables, coverageTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType4SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType4SubTable.cs index 896c74eb4..4dc278aff 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType4SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType4SubTable.cs @@ -59,7 +59,7 @@ public static LookupType4Format1SubTable Load(BigEndianBinaryReader reader, long Span ligatureSetOffsets = ligatureSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(ligatureSetOffsets); - var ligatureSetTables = new LigatureSetTable[ligatureSetCount]; + LigatureSetTable[] ligatureSetTables = new LigatureSetTable[ligatureSetCount]; for (int i = 0; i < ligatureSetTables.Length; i++) { // LigatureSet Table @@ -79,7 +79,7 @@ public static LookupType4Format1SubTable Load(BigEndianBinaryReader reader, long Span ligatureOffsets = ligatureOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(ligatureOffsets); - var ligatureTables = new LigatureTable[ligatureCount]; + LigatureTable[] ligatureTables = new LigatureTable[ligatureCount]; // Ligature Table // +--------+---------------------------------------+------------------------------------------------------+ @@ -104,7 +104,7 @@ public static LookupType4Format1SubTable Load(BigEndianBinaryReader reader, long ligatureSetTables[i] = new LigatureSetTable(ligatureTables); } - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); return new LookupType4Format1SubTable(ligatureSetTables, coverageTable, lookupFlags); } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType8SubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType8SubTable.cs index ec009404b..24c66adc1 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType8SubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSub/LookupType8SubTable.cs @@ -88,7 +88,7 @@ public static LookupType8Format1SubTable Load(BigEndianBinaryReader reader, long ushort glyphCount = reader.ReadUInt16(); ushort[] substituteGlyphIds = reader.ReadUInt16Array(glyphCount); - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); CoverageTable[] backtrackCoverageTables = CoverageTable.LoadArray(reader, offset, backtrackCoverageOffsets); CoverageTable[] lookaheadCoverageTables = CoverageTable.LoadArray(reader, offset, lookaheadCoverageOffsets); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSubTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSubTable.cs index 590f5ccd0..60909fce6 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSubTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/GSubTable.cs @@ -85,11 +85,11 @@ internal static GSubTable Load(BigEndianBinaryReader reader) uint featureVariationsOffset = (minorVersion == 1) ? reader.ReadOffset32() : 0; // TODO: Optimization. Allow only reading the scriptList. - var scriptList = ScriptList.Load(reader, scriptListOffset); + ScriptList? scriptList = ScriptList.Load(reader, scriptListOffset); - var featureList = FeatureListTable.Load(reader, featureListOffset); + FeatureListTable featureList = FeatureListTable.Load(reader, featureListOffset); - var lookupList = LookupListTable.Load(reader, lookupListOffset); + LookupListTable lookupList = LookupListTable.Load(reader, lookupListOffset); // TODO: Feature Variations. return new GSubTable(scriptList, featureList, lookupList); @@ -310,7 +310,7 @@ private Tag GetUnicodeScriptTag(ScriptClass script) { ushort lookupIndex = lookupListIndices[k]; LookupTable lookupTable = this.LookupList.LookupTables[lookupIndex]; - lookups.Add(new(feature, lookupIndex, lookupTable)); + lookups.Add((feature, lookupIndex, lookupTable)); } } } diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureCaretList.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureCaretList.cs index 4d064947f..ed1538863 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureCaretList.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureCaretList.cs @@ -29,7 +29,7 @@ public static LigatureCaretList Load(BigEndianBinaryReader reader, long offset) Span ligGlyphOffsets = ligGlyphOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(ligGlyphOffsets); - var ligatureCaretList = new LigatureCaretList() + LigatureCaretList ligatureCaretList = new() { CoverageTable = CoverageTable.Load(reader, offset + coverageOffset) }; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureGlyph.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureGlyph.cs index 6d7ffae2f..79aca439e 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureGlyph.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/LigatureGlyph.cs @@ -12,7 +12,7 @@ public static LigatureGlyph Load(BigEndianBinaryReader reader, long offset) reader.Seek(offset, SeekOrigin.Begin); ushort caretCount = reader.ReadUInt16(); - var ligatureGlyph = new LigatureGlyph() + LigatureGlyph ligatureGlyph = new() { CaretValueOffsets = reader.ReadUInt16Array(caretCount) }; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ScriptList.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ScriptList.cs index da8348ba1..15c9ad1a7 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/ScriptList.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/ScriptList.cs @@ -30,7 +30,7 @@ internal sealed class ScriptList : Dictionary ushort scriptCount = reader.ReadUInt16(); // Read records (tags and table offsets) - var scriptTags = new Tag[scriptCount]; + Tag[] scriptTags = new Tag[scriptCount]; ushort[] scriptOffsets = new ushort[scriptCount]; for (int i = 0; i < scriptTags.Length; i++) @@ -49,7 +49,7 @@ internal sealed class ScriptList : Dictionary scriptList = new ScriptList(scriptTag); } - var scriptTable = ScriptListTable.Load(scriptTag, reader, offset + scriptOffsets[i]); + ScriptListTable scriptTable = ScriptListTable.Load(scriptTag, reader, offset + scriptOffsets[i]); scriptList!.Add(scriptTag, scriptTable); } @@ -92,7 +92,7 @@ public static ScriptListTable Load(Tag scriptTag, BigEndianBinaryReader reader, ushort defaultLangSysOffset = reader.ReadOffset16(); ushort langSysCount = reader.ReadUInt16(); - var langSysRecords = new LangSysRecord[langSysCount]; + LangSysRecord[] langSysRecords = new LangSysRecord[langSysCount]; for (int i = 0; i < langSysRecords.Length; i++) { // LangSysRecord @@ -117,7 +117,7 @@ public static ScriptListTable Load(Tag scriptTag, BigEndianBinaryReader reader, // Load the other table features. // We do this last to avoid excessive seeking. - var langSysTables = new LangSysTable[langSysCount]; + LangSysTable[] langSysTables = new LangSysTable[langSysCount]; for (int i = 0; i < langSysTables.Length; i++) { LangSysRecord langSysRecord = langSysRecords[i]; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceLookupRecord.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceLookupRecord.cs index e4d444a09..845f600ab 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceLookupRecord.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceLookupRecord.cs @@ -33,7 +33,7 @@ public static SequenceLookupRecord[] LoadArray(BigEndianBinaryReader reader, int // +--------+-----------------+---------------------------------------------------+ // | uint16 | LookupListIndex | Lookup to apply to that position-zero-based. | // +--------+-----------------+---------------------------------------------------+ - var records = new SequenceLookupRecord[count]; + SequenceLookupRecord[] records = new SequenceLookupRecord[count]; for (int i = 0; i < records.Length; i++) { records[i] = new SequenceLookupRecord(reader.ReadUInt16(), reader.ReadUInt16()); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceRuleSetTable.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceRuleSetTable.cs index 2abb3f085..11c902cc3 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceRuleSetTable.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/SequenceRuleSetTable.cs @@ -28,7 +28,7 @@ public static SequenceRuleSetTable Load(BigEndianBinaryReader reader, long offse Span seqRuleOffsets = seqRuleOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(seqRuleOffsets); - var sequenceRuleTables = new SequenceRuleTable[seqRuleCount]; + SequenceRuleTable[] sequenceRuleTables = new SequenceRuleTable[seqRuleCount]; for (int i = 0; i < sequenceRuleTables.Length; i++) { sequenceRuleTables[i] = SequenceRuleTable.Load(reader, offset + seqRuleOffsets[i]); diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/HangulShaper.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/HangulShaper.cs index 5888e94ae..3d790a716 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/HangulShaper.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/HangulShaper.cs @@ -219,9 +219,9 @@ private int DecomposeGlyph(GlyphSubstitutionCollection collection, GlyphShapingD FontMetrics metrics = data.TextRun.Font!.FontMetrics; // Don't decompose if all of the components are not available - if (!metrics.TryGetGlyphId(new(l), out ushort ljmo) || - !metrics.TryGetGlyphId(new(v), out ushort vjmo) || - (!metrics.TryGetGlyphId(new(t), out ushort tjmo) && t != TBase)) + if (!metrics.TryGetGlyphId(new CodePoint(l), out ushort ljmo) || + !metrics.TryGetGlyphId(new CodePoint(v), out ushort vjmo) || + (!metrics.TryGetGlyphId(new CodePoint(t), out ushort tjmo) && t != TBase)) { return index; } @@ -381,7 +381,7 @@ private int InsertDottedCircle(GlyphSubstitutionCollection collection, GlyphShap bool after = false; FontMetrics fontMetrics = data.TextRun.Font!.FontMetrics; - if (fontMetrics.TryGetGlyphId(new(DottedCircle), out ushort id)) + if (fontMetrics.TryGetGlyphId(new CodePoint(DottedCircle), out ushort id)) { TextAttributes textAttributes = data.TextRun.TextAttributes; TextDecorations textDecorations = data.TextRun.TextDecorations; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/IndicShaper.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/IndicShaper.cs index 6fe5900e9..a803148e4 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/IndicShaper.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/IndicShaper.cs @@ -124,7 +124,7 @@ protected override void AssignFeatures(IGlyphShapingCollection collection, int i substitutionCollection.Replace(i, ids, FeatureTags.GlyphCompositionDecomposition); for (int j = 0; j < decompositions.Length; j++) { - substitutionCollection[i + j].CodePoint = new(decompositions[j]); + substitutionCollection[i + j].CodePoint = new CodePoint(decompositions[j]); } } } @@ -155,7 +155,7 @@ private static void SetupSyllables(IGlyphShapingCollection collection, int index for (int i = last; i < match.StartIndex; i++) { GlyphShapingData data = substitutionCollection[i + index]; - data.IndicShapingEngineInfo = new(Categories.X, Positions.End, "non_indic_cluster", syllable); + data.IndicShapingEngineInfo = new IndicShapingEngineInfo(Categories.X, Positions.End, "non_indic_cluster", syllable); } } @@ -167,7 +167,7 @@ private static void SetupSyllables(IGlyphShapingCollection collection, int index GlyphShapingData data = substitutionCollection[i + index]; CodePoint codePoint = data.CodePoint; - data.IndicShapingEngineInfo = new( + data.IndicShapingEngineInfo = new IndicShapingEngineInfo( (Categories)(1 << IndicShapingCategory(codePoint)), (Positions)IndicShapingPosition(codePoint), match.Tags[0], @@ -183,7 +183,7 @@ private static void SetupSyllables(IGlyphShapingCollection collection, int index for (int i = last; i < count; i++) { GlyphShapingData data = substitutionCollection[i + index]; - data.IndicShapingEngineInfo = new(Categories.X, Positions.End, "non_indic_cluster", syllable); + data.IndicShapingEngineInfo = new IndicShapingEngineInfo(Categories.X, Positions.End, "non_indic_cluster", syllable); } } } @@ -212,7 +212,7 @@ private void InitialReorder(IGlyphShapingCollection collection, int index, int c GlyphShapingData data = substitutionCollection[i + index]; FontMetrics fontMetrics = data.TextRun.Font!.FontMetrics; - fontMetrics.TryGetGlyphId(new(0x0020), out ushort spc); + fontMetrics.TryGetGlyphId(new CodePoint(0x0020), out ushort spc); IndicShapingEngineInfo? info = data.IndicShapingEngineInfo; if (info?.Position == Positions.Base_C) @@ -256,7 +256,7 @@ private void InitialReorder(IGlyphShapingCollection collection, int index, int c break; } - if (dataInfo != null && type == "broken_cluster" && fontMetrics.TryGetGlyphId(new(DottedCircle), out ushort id)) + if (dataInfo != null && type == "broken_cluster" && fontMetrics.TryGetGlyphId(new CodePoint(DottedCircle), out ushort id)) { // Insert after possible Repha. int i = start; @@ -280,7 +280,7 @@ private void InitialReorder(IGlyphShapingCollection collection, int index, int c GlyphShapingData dotted = substitutionCollection[i + 1]; Categories dottedCategory = (Categories)(1 << IndicShapingCategory(dotted.CodePoint)); Positions dottedPosition = (Positions)IndicShapingPosition(dotted.CodePoint); - dotted.IndicShapingEngineInfo = new(dottedCategory, dottedPosition, dataInfo.SyllableType, dataInfo.Syllable); + dotted.IndicShapingEngineInfo = new IndicShapingEngineInfo(dottedCategory, dottedPosition, dataInfo.SyllableType, dataInfo.Syllable); end++; max++; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/UniversalShaper.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/UniversalShaper.cs index 05ee92f86..96447cc89 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/UniversalShaper.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/Shapers/UniversalShaper.cs @@ -107,7 +107,7 @@ private static void DecomposeSplitVowels(IGlyphShapingCollection collection, int substitutionCollection.Replace(i, ids, FeatureTags.GlyphCompositionDecomposition); for (int j = 0; j < decompositions.Length; j++) { - substitutionCollection[i + j].CodePoint = new(decompositions[j]); + substitutionCollection[i + j].CodePoint = new CodePoint(decompositions[j]); } } } @@ -139,7 +139,7 @@ private static void SetupSyllables(IGlyphShapingCollection collection, int index CodePoint codePoint = data.CodePoint; string category = UniversalShapingData.Categories[UnicodeData.GetUniversalShapingSymbolCount((uint)codePoint.Value)]; - data.UniversalShapingEngineInfo = new(category, match.Tags[0], syllable); + data.UniversalShapingEngineInfo = new UniversalShapingEngineInfo(category, match.Tags[0], syllable); } // Assign rphf feature @@ -238,7 +238,7 @@ private static void Reorder(IGlyphShapingCollection collection, int index, int c } FontMetrics fontMetrics = data.TextRun.Font!.FontMetrics; - if (type == "broken_cluster" && fontMetrics.TryGetGlyphId(new(DottedCircle), out ushort id)) + if (type == "broken_cluster" && fontMetrics.TryGetGlyphId(new CodePoint(DottedCircle), out ushort id)) { // Insert after possible Repha. int i = start; diff --git a/src/SixLabors.Fonts/Tables/AdvancedTypographic/TableLoadingUtils.cs b/src/SixLabors.Fonts/Tables/AdvancedTypographic/TableLoadingUtils.cs index 18d739468..43da44b43 100644 --- a/src/SixLabors.Fonts/Tables/AdvancedTypographic/TableLoadingUtils.cs +++ b/src/SixLabors.Fonts/Tables/AdvancedTypographic/TableLoadingUtils.cs @@ -29,7 +29,7 @@ internal static SequenceRuleSetTable[] LoadSequenceContextFormat1(BigEndianBinar Span seqRuleSetOffsets = seqRuleSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(seqRuleSetOffsets); - var seqRuleSets = new SequenceRuleSetTable[seqRuleSetCount]; + SequenceRuleSetTable[] seqRuleSets = new SequenceRuleSetTable[seqRuleSetCount]; for (int i = 0; i < seqRuleSets.Length; i++) { @@ -68,7 +68,7 @@ internal static CoverageTable LoadSequenceContextFormat2(BigEndianBinaryReader r Span classSeqRuleSetOffsets = classSeqRuleSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(classSeqRuleSetOffsets); - var coverageTable = CoverageTable.Load(reader, offset + coverageOffset); + CoverageTable coverageTable = CoverageTable.Load(reader, offset + coverageOffset); classDefTable = ClassDefinitionTable.Load(reader, offset + classDefOffset); classSeqRuleSets = new ClassSequenceRuleSetTable[classSeqRuleSetCount]; @@ -143,7 +143,7 @@ internal static ChainedSequenceRuleSetTable[] LoadChainedSequenceContextFormat1( Span chainedSeqRuleSetOffsets = chainedSeqRuleSetOffsetsBuffer.GetSpan(); reader.ReadUInt16Array(chainedSeqRuleSetOffsets); - var seqRuleSets = new ChainedSequenceRuleSetTable[chainedSeqRuleSetCount]; + ChainedSequenceRuleSetTable[] seqRuleSets = new ChainedSequenceRuleSetTable[chainedSeqRuleSetCount]; for (int i = 0; i < seqRuleSets.Length; i++) { diff --git a/src/SixLabors.Fonts/Tables/Cff/Cff1Table.cs b/src/SixLabors.Fonts/Tables/Cff/Cff1Table.cs index 8fd4f8f9a..9803fde7c 100644 --- a/src/SixLabors.Fonts/Tables/Cff/Cff1Table.cs +++ b/src/SixLabors.Fonts/Tables/Cff/Cff1Table.cs @@ -53,7 +53,7 @@ public static Cff1Table Load(BigEndianBinaryReader reader) { case 1: CffParser parser = new(); - return new(parser.Load(reader, position)); + return new Cff1Table(parser.Load(reader, position)); default: throw new NotSupportedException(); diff --git a/src/SixLabors.Fonts/Tables/Cff/CffEvaluationEngine.cs b/src/SixLabors.Fonts/Tables/Cff/CffEvaluationEngine.cs index a3b48bedf..10c6ca1fa 100644 --- a/src/SixLabors.Fonts/Tables/Cff/CffEvaluationEngine.cs +++ b/src/SixLabors.Fonts/Tables/Cff/CffEvaluationEngine.cs @@ -47,13 +47,13 @@ public CffEvaluationEngine( this.globalBias = CalculateBias(this.globalSubrBuffers.Length); this.localBias = CalculateBias(this.localSubrBuffers.Length); - this.trans = new(); + this.trans = new Dictionary(); this.x = 0; this.y = 0; this.width = null; this.nStems = 0; - this.stack = new(50); + this.stack = new RefStack(50); this.isDisposed = false; } @@ -65,7 +65,7 @@ public Bounds GetBounds() CffBoundsFinder finder = new(); // Note: scale is passed with negative Y to flip the Y axis. - this.transforming = new(finder, Vector2.Zero, new Vector2(1, -1), Vector2.Zero, Matrix3x2.Identity); + this.transforming = new TransformingGlyphRenderer(finder, Vector2.Zero, new Vector2(1, -1), Vector2.Zero, Matrix3x2.Identity); // Boolean IGlyphRenderer.BeginGlyph(..) is handled by the caller. this.Parse(this.charStrings); @@ -83,7 +83,7 @@ public void RenderTo(IGlyphRenderer renderer, Vector2 origin, Vector2 scale, Vec { this.Reset(); - this.transforming = new(renderer, origin, scale, offset, transform); + this.transforming = new TransformingGlyphRenderer(renderer, origin, scale, offset, transform); // Boolean IGlyphRenderer.BeginGlyph(..) is handled by the caller. this.Parse(this.charStrings); @@ -112,7 +112,7 @@ private void Parse(ReadOnlySpan buffer) float c2x; float c2y; - var oneByteOperator = (Type2Operator1)b0; + Type2Operator1 oneByteOperator = (Type2Operator1)b0; switch (oneByteOperator) { case Type2Operator1.Hstem: diff --git a/src/SixLabors.Fonts/Tables/Cff/CffGlyphData.cs b/src/SixLabors.Fonts/Tables/Cff/CffGlyphData.cs index a5e051c83..7be459dac 100644 --- a/src/SixLabors.Fonts/Tables/Cff/CffGlyphData.cs +++ b/src/SixLabors.Fonts/Tables/Cff/CffGlyphData.cs @@ -34,7 +34,7 @@ public CffGlyphData( public readonly Bounds GetBounds() { - using var engine = new CffEvaluationEngine( + using CffEvaluationEngine engine = new( this.charStrings, this.globalSubrBuffers, this.localSubrBuffers, @@ -45,7 +45,7 @@ public readonly Bounds GetBounds() public readonly void RenderTo(IGlyphRenderer renderer, Vector2 origin, Vector2 scale, Vector2 offset, Matrix3x2 transform) { - using var engine = new CffEvaluationEngine( + using CffEvaluationEngine engine = new( this.charStrings, this.globalSubrBuffers, this.localSubrBuffers, diff --git a/src/SixLabors.Fonts/Tables/Cff/CffParser.cs b/src/SixLabors.Fonts/Tables/Cff/CffParser.cs index 1a8020030..e3b738370 100644 --- a/src/SixLabors.Fonts/Tables/Cff/CffParser.cs +++ b/src/SixLabors.Fonts/Tables/Cff/CffParser.cs @@ -48,7 +48,7 @@ public CffFont Load(BigEndianBinaryReader reader, long offset) this.ReadCharsets(reader, stringIndex, glyphs); this.ReadEncodings(reader); - return new(fontName, topDictionary, glyphs); + return new CffFont(fontName, topDictionary, glyphs); } private static string ReadNameIndex(BigEndianBinaryReader reader) @@ -101,7 +101,7 @@ private static string[] ReadStringIndex(BigEndianBinaryReader reader) string[] stringIndex = new string[offsets.Length]; // Allow reusing the same buffer for shorter reads. - using Buffer buffer = new Buffer(512); + using Buffer buffer = new(512); Span bufferSpan = buffer.GetSpan(); for (int i = 0; i < offsets.Length; ++i) diff --git a/src/SixLabors.Fonts/Tables/Cff/CffTopDictionary.cs b/src/SixLabors.Fonts/Tables/Cff/CffTopDictionary.cs index dd6dba73b..6b17946d4 100644 --- a/src/SixLabors.Fonts/Tables/Cff/CffTopDictionary.cs +++ b/src/SixLabors.Fonts/Tables/Cff/CffTopDictionary.cs @@ -5,7 +5,7 @@ namespace SixLabors.Fonts.Tables.Cff; internal class CffTopDictionary { - public CffTopDictionary() => this.CidFontInfo = new(); + public CffTopDictionary() => this.CidFontInfo = new CidFontInfo(); public string? Version { get; set; } diff --git a/src/SixLabors.Fonts/Tables/Cff/RefStack{T}.cs b/src/SixLabors.Fonts/Tables/Cff/RefStack{T}.cs index 66dc27dbf..813f58c8e 100644 --- a/src/SixLabors.Fonts/Tables/Cff/RefStack{T}.cs +++ b/src/SixLabors.Fonts/Tables/Cff/RefStack{T}.cs @@ -74,7 +74,7 @@ public void Push(T value) capacity = MaxLength; } - var newBuffer = new Buffer(capacity); + Buffer newBuffer = new(capacity); Span newStack = newBuffer.GetSpan(); this.stack.CopyTo(newStack); diff --git a/src/SixLabors.Fonts/Tables/General/CMap/EncodingRecord.cs b/src/SixLabors.Fonts/Tables/General/CMap/EncodingRecord.cs index a96036d3c..7eadc2214 100644 --- a/src/SixLabors.Fonts/Tables/General/CMap/EncodingRecord.cs +++ b/src/SixLabors.Fonts/Tables/General/CMap/EncodingRecord.cs @@ -22,7 +22,7 @@ public EncodingRecord(PlatformIDs platformID, ushort encodingID, uint offset) public static EncodingRecord Read(BigEndianBinaryReader reader) { - var platform = (PlatformIDs)reader.ReadUInt16(); + PlatformIDs platform = (PlatformIDs)reader.ReadUInt16(); ushort encoding = reader.ReadUInt16(); uint offset = reader.ReadOffset32(); diff --git a/src/SixLabors.Fonts/Tables/General/CMap/Format12SubTable.cs b/src/SixLabors.Fonts/Tables/General/CMap/Format12SubTable.cs index 2a30b6a91..38e495d91 100644 --- a/src/SixLabors.Fonts/Tables/General/CMap/Format12SubTable.cs +++ b/src/SixLabors.Fonts/Tables/General/CMap/Format12SubTable.cs @@ -83,8 +83,8 @@ public static IEnumerable Load(IEnumerable enc uint language = reader.ReadUInt32(); uint numGroups = reader.ReadUInt32(); - var groups = new SequentialMapGroup[numGroups]; - for (var i = 0; i < numGroups; i++) + SequentialMapGroup[] groups = new SequentialMapGroup[numGroups]; + for (int i = 0; i < numGroups; i++) { groups[i] = SequentialMapGroup.Load(reader); } @@ -110,9 +110,9 @@ public SequentialMapGroup(uint startCodePoint, uint endCodePoint, uint startGlyp public static SequentialMapGroup Load(BigEndianBinaryReader reader) { - var startCodePoint = reader.ReadUInt32(); - var endCodePoint = reader.ReadUInt32(); - var startGlyph = reader.ReadUInt32(); + uint startCodePoint = reader.ReadUInt32(); + uint endCodePoint = reader.ReadUInt32(); + uint startGlyph = reader.ReadUInt32(); return new SequentialMapGroup(startCodePoint, endCodePoint, startGlyph); } } diff --git a/src/SixLabors.Fonts/Tables/General/CMap/Format14SubTable.cs b/src/SixLabors.Fonts/Tables/General/CMap/Format14SubTable.cs index bf4f26172..57c432dc8 100644 --- a/src/SixLabors.Fonts/Tables/General/CMap/Format14SubTable.cs +++ b/src/SixLabors.Fonts/Tables/General/CMap/Format14SubTable.cs @@ -38,7 +38,7 @@ public static IEnumerable Load( uint length = reader.ReadUInt32(); uint numVarSelectorRecords = reader.ReadUInt32(); - var variationSelectors = new Dictionary(); + Dictionary variationSelectors = new(); int[] varSelectors = new int[numVarSelectorRecords]; uint[] defaultUVSOffsets = new uint[numVarSelectorRecords]; uint[] nonDefaultUVSOffsets = new uint[numVarSelectorRecords]; @@ -62,7 +62,7 @@ public static IEnumerable Load( for (int i = 0; i < numVarSelectorRecords; ++i) { - var selector = new VariationSelector(); + VariationSelector selector = new(); if (defaultUVSOffsets[i] != 0) { // Default UVS table @@ -178,10 +178,10 @@ public ushort CharacterPairToGlyphId(CodePoint codePoint, ushort defaultGlyphInd private class VariationSelector { - public List DefaultStartCodes { get; } = new List(); + public List DefaultStartCodes { get; } = new(); - public List DefaultEndCodes { get; } = new List(); + public List DefaultEndCodes { get; } = new(); - public Dictionary UVSMappings { get; } = new Dictionary(); + public Dictionary UVSMappings { get; } = new(); } } diff --git a/src/SixLabors.Fonts/Tables/General/CMap/Format4SubTable.cs b/src/SixLabors.Fonts/Tables/General/CMap/Format4SubTable.cs index edbf09345..916c935cc 100644 --- a/src/SixLabors.Fonts/Tables/General/CMap/Format4SubTable.cs +++ b/src/SixLabors.Fonts/Tables/General/CMap/Format4SubTable.cs @@ -181,7 +181,7 @@ public Segment(ushort index, ushort end, ushort start, short delta, ushort offse public static Segment[] Create(ReadOnlySpan endCounts, ReadOnlySpan startCode, ReadOnlySpan idDelta, ReadOnlySpan idRangeOffset) { int count = endCounts.Length; - var segments = new Segment[count]; + Segment[] segments = new Segment[count]; for (ushort i = 0; i < count; i++) { ushort start = startCode[i]; diff --git a/src/SixLabors.Fonts/Tables/General/CMapTable.cs b/src/SixLabors.Fonts/Tables/General/CMapTable.cs index 8bca9c38c..af848c9ae 100644 --- a/src/SixLabors.Fonts/Tables/General/CMapTable.cs +++ b/src/SixLabors.Fonts/Tables/General/CMapTable.cs @@ -123,14 +123,14 @@ public static CMapTable Load(BigEndianBinaryReader reader) ushort version = reader.ReadUInt16(); ushort numTables = reader.ReadUInt16(); - var encodings = new EncodingRecord[numTables]; + EncodingRecord[] encodings = new EncodingRecord[numTables]; for (int i = 0; i < numTables; i++) { encodings[i] = EncodingRecord.Read(reader); } // foreach encoding we move forward looking for the subtables - var tables = new List(numTables); + List tables = new(numTables); foreach (IGrouping encoding in encodings.GroupBy(x => x.Offset)) { long offset = encoding.Key; diff --git a/src/SixLabors.Fonts/Tables/General/Colr/ColrTable.cs b/src/SixLabors.Fonts/Tables/General/Colr/ColrTable.cs index 5bbabf12b..38286b3df 100644 --- a/src/SixLabors.Fonts/Tables/General/Colr/ColrTable.cs +++ b/src/SixLabors.Fonts/Tables/General/Colr/ColrTable.cs @@ -76,8 +76,8 @@ public static ColrTable Load(BigEndianBinaryReader reader) reader.Seek(baseGlyphRecordsOffset, System.IO.SeekOrigin.Begin); - var glyphs = new BaseGlyphRecord[numBaseGlyphRecords]; - var layers = new LayerRecord[numLayerRecords]; + BaseGlyphRecord[] glyphs = new BaseGlyphRecord[numBaseGlyphRecords]; + LayerRecord[] layers = new LayerRecord[numLayerRecords]; for (int i = 0; i < numBaseGlyphRecords; i++) { ushort gi = reader.ReadUInt16(); diff --git a/src/SixLabors.Fonts/Tables/General/CpalTable.cs b/src/SixLabors.Fonts/Tables/General/CpalTable.cs index e1f18394b..1358612af 100644 --- a/src/SixLabors.Fonts/Tables/General/CpalTable.cs +++ b/src/SixLabors.Fonts/Tables/General/CpalTable.cs @@ -67,7 +67,7 @@ public static CpalTable Load(BigEndianBinaryReader reader) } reader.Seek(offsetFirstColorRecord, System.IO.SeekOrigin.Begin); - var palettes = new GlyphColor[numColorRecords]; + GlyphColor[] palettes = new GlyphColor[numColorRecords]; for (int n = 0; n < numColorRecords; n++) { byte blue = reader.ReadByte(); diff --git a/src/SixLabors.Fonts/Tables/General/HeadTable.cs b/src/SixLabors.Fonts/Tables/General/HeadTable.cs index 178643c6c..97d588aa1 100644 --- a/src/SixLabors.Fonts/Tables/General/HeadTable.cs +++ b/src/SixLabors.Fonts/Tables/General/HeadTable.cs @@ -175,7 +175,7 @@ public static HeadTable Load(BigEndianBinaryReader reader) throw new InvalidFontFileException($"invalid units per em expected value between 16 and 16384 but found {unitsPerEm} in 'head'"); } - var startDate = new DateTime(1904, 01, 01, 0, 0, 0, DateTimeKind.Utc); + DateTime startDate = new(1904, 01, 01, 0, 0, 0, DateTimeKind.Utc); long seconds = reader.ReadInt64(); DateTime created = startDate; if (seconds > 0) @@ -196,7 +196,7 @@ public static HeadTable Load(BigEndianBinaryReader reader) modified = startDate.AddSeconds(seconds); } - var bounds = Bounds.Load(reader); // xMin, yMin, xMax, yMax + Bounds bounds = Bounds.Load(reader); // xMin, yMin, xMax, yMax HeadMacStyle macStyle = reader.ReadUInt16(); ushort lowestRecPPEM = reader.ReadUInt16(); diff --git a/src/SixLabors.Fonts/Tables/General/Kern/Format0SubTable.cs b/src/SixLabors.Fonts/Tables/General/Kern/Format0SubTable.cs index 7e89fe8bc..216b2e310 100644 --- a/src/SixLabors.Fonts/Tables/General/Kern/Format0SubTable.cs +++ b/src/SixLabors.Fonts/Tables/General/Kern/Format0SubTable.cs @@ -24,7 +24,7 @@ public static Format0SubTable Load(BigEndianBinaryReader reader, in KerningCover ushort entrySelector = reader.ReadUInt16(); ushort rangeShift = reader.ReadUInt16(); - var pairs = new KerningPair[pairCount]; + KerningPair[] pairs = new KerningPair[pairCount]; for (int i = 0; i < pairCount; i++) { pairs[i] = KerningPair.Read(reader); diff --git a/src/SixLabors.Fonts/Tables/General/Kern/KerningPair.cs b/src/SixLabors.Fonts/Tables/General/Kern/KerningPair.cs index bfe875b23..4ea1597ff 100644 --- a/src/SixLabors.Fonts/Tables/General/Kern/KerningPair.cs +++ b/src/SixLabors.Fonts/Tables/General/Kern/KerningPair.cs @@ -29,12 +29,13 @@ public static uint CalculateKey(ushort left, ushort right) public static KerningPair Read(BigEndianBinaryReader reader) - // Type | Field | Description - // -------|-------|------------------------------- - // uint16 | left | The glyph index for the left-hand glyph in the kerning pair. - // uint16 | right | The glyph index for the right-hand glyph in the kerning pair. - // FWORD | value | The kerning value for the above pair, in FUnits.If this value is greater than zero, the characters will be moved apart.If this value is less than zero, the character will be moved closer together. - => new KerningPair(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadFWORD()); + // Type | Field | Description + // -------|-------|------------------------------- + // uint16 | left | The glyph index for the left-hand glyph in the kerning pair. + // uint16 | right | The glyph index for the right-hand glyph in the kerning pair. + // FWORD | value | The kerning value for the above pair, in FUnits.If this value is greater than zero, the characters will be moved apart.If this value is less than zero, the character will be moved closer together. + => + new(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadFWORD()); public int CompareTo(KerningPair other) => this.Key.CompareTo(other.Key); diff --git a/src/SixLabors.Fonts/Tables/General/Kern/KerningSubTable.cs b/src/SixLabors.Fonts/Tables/General/Kern/KerningSubTable.cs index e7a7ce8c4..d5076e846 100644 --- a/src/SixLabors.Fonts/Tables/General/Kern/KerningSubTable.cs +++ b/src/SixLabors.Fonts/Tables/General/Kern/KerningSubTable.cs @@ -27,7 +27,7 @@ public KerningSubTable(KerningCoverage coverage) // +--------+----------+----------------------------------------------------------+ ushort subVersion = reader.ReadUInt16(); ushort length = reader.ReadUInt16(); - var coverage = KerningCoverage.Read(reader); + KerningCoverage coverage = KerningCoverage.Read(reader); if (coverage.Format == 0) { return Format0SubTable.Load(reader, coverage); diff --git a/src/SixLabors.Fonts/Tables/General/Name/NameRecord.cs b/src/SixLabors.Fonts/Tables/General/Name/NameRecord.cs index 133981f5f..a2cef1cda 100644 --- a/src/SixLabors.Fonts/Tables/General/Name/NameRecord.cs +++ b/src/SixLabors.Fonts/Tables/General/Name/NameRecord.cs @@ -37,7 +37,7 @@ public static NameRecord Read(BigEndianBinaryReader reader) ushort languageID = reader.ReadUInt16(); KnownNameIds nameID = reader.ReadUInt16(); - var stringReader = StringLoader.Create(reader, encoding); + StringLoader stringReader = StringLoader.Create(reader, encoding); return new NameRecord(platform, languageID, nameID, string.Empty) { diff --git a/src/SixLabors.Fonts/Tables/General/Name/NameTable.cs b/src/SixLabors.Fonts/Tables/General/Name/NameTable.cs index b1ff269ad..7aa00e0c3 100644 --- a/src/SixLabors.Fonts/Tables/General/Name/NameTable.cs +++ b/src/SixLabors.Fonts/Tables/General/Name/NameTable.cs @@ -107,12 +107,12 @@ public string GetNameById(CultureInfo culture, ushort nameId) public static NameTable Load(BigEndianBinaryReader reader) { - var strings = new List(); + List strings = new(); ushort format = reader.ReadUInt16(); ushort nameCount = reader.ReadUInt16(); ushort stringOffset = reader.ReadUInt16(); - var names = new NameRecord[nameCount]; + NameRecord[] names = new NameRecord[nameCount]; for (int i = 0; i < nameCount; i++) { diff --git a/src/SixLabors.Fonts/Tables/General/OS2Table.cs b/src/SixLabors.Fonts/Tables/General/OS2Table.cs index 1c4f49faf..1ea58752a 100644 --- a/src/SixLabors.Fonts/Tables/General/OS2Table.cs +++ b/src/SixLabors.Fonts/Tables/General/OS2Table.cs @@ -316,7 +316,7 @@ public static OS2Table Load(BigEndianBinaryReader reader) ushort winAscent = reader.ReadUInt16(); ushort winDescent = reader.ReadUInt16(); - var version0Table = new OS2Table( + OS2Table version0Table = new( averageCharWidth, weightClass, widthClass, @@ -372,7 +372,7 @@ public static OS2Table Load(BigEndianBinaryReader reader) maxContext = reader.ReadUInt16(); } - var versionLessThan5Table = new OS2Table( + OS2Table versionLessThan5Table = new( version0Table, codePageRange1, codePageRange2, diff --git a/src/SixLabors.Fonts/Tables/TableHeader.cs b/src/SixLabors.Fonts/Tables/TableHeader.cs index 2633ee13e..06d0ab63c 100644 --- a/src/SixLabors.Fonts/Tables/TableHeader.cs +++ b/src/SixLabors.Fonts/Tables/TableHeader.cs @@ -21,7 +21,7 @@ public TableHeader(string tag, uint checkSum, uint offset, uint len) public uint Length { get; } - public static TableHeader Read(BigEndianBinaryReader reader) => new TableHeader( + public static TableHeader Read(BigEndianBinaryReader reader) => new( reader.ReadTag(), reader.ReadUInt32(), reader.ReadOffset32(), diff --git a/src/SixLabors.Fonts/Tables/TripleEncodingTable.cs b/src/SixLabors.Fonts/Tables/TripleEncodingTable.cs index 90a039fae..d35c7cf0e 100644 --- a/src/SixLabors.Fonts/Tables/TripleEncodingTable.cs +++ b/src/SixLabors.Fonts/Tables/TripleEncodingTable.cs @@ -7,8 +7,8 @@ namespace SixLabors.Fonts.Tables; // see https://github.com/LayoutFarm/Typography/blob/master/Typography.OpenFont/WebFont/Woff2Reader.cs internal class TripleEncodingTable { - public static readonly TripleEncodingTable EncTable = new TripleEncodingTable(); - private readonly List records = new List(); + public static readonly TripleEncodingTable EncTable = new(); + private readonly List records = new(); private TripleEncodingTable() => this.BuildTable(); @@ -245,7 +245,7 @@ private void BuildRecords(byte byteCount, byte xbits, byte ybits, ushort[] delta private void AddRecord(byte byteCount, byte xbits, byte ybits, ushort deltaX, ushort deltaY, sbyte xsign, sbyte ysign) { - var rec = new TripleEncodingRecord(byteCount, xbits, ybits, deltaX, deltaY, xsign, ysign); + TripleEncodingRecord rec = new(byteCount, xbits, ybits, deltaX, deltaY, xsign, ysign); this.records.Add(rec); } } diff --git a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/CompositeGlyphLoader.cs b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/CompositeGlyphLoader.cs index 4e4497a23..9bdbbd01a 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/CompositeGlyphLoader.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/CompositeGlyphLoader.cs @@ -25,7 +25,7 @@ public override GlyphVector CreateGlyph(GlyphTable table) for (int i = 0; i < this.composites.Length; i++) { Composite composite = this.composites[i]; - var clone = GlyphVector.DeepClone(table.GetGlyph(composite.GlyphIndex)); + GlyphVector clone = GlyphVector.DeepClone(table.GetGlyph(composite.GlyphIndex)); GlyphVector.TransformInPlace(ref clone, composite.Transformation); ushort endPointOffset = (ushort)controlPoints.Count; @@ -36,7 +36,7 @@ public override GlyphVector CreateGlyph(GlyphTable table) } } - return new(controlPoints, endPoints, this.bounds, this.instructions, true); + return new GlyphVector(controlPoints, endPoints, this.bounds, this.instructions, true); } public static CompositeGlyphLoader LoadCompositeGlyph(BigEndianBinaryReader reader, in Bounds bounds) diff --git a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphLoader.cs b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphLoader.cs index 3175284c4..1630bf216 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphLoader.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphLoader.cs @@ -10,7 +10,7 @@ internal abstract class GlyphLoader public static GlyphLoader Load(BigEndianBinaryReader reader) { short contoursCount = reader.ReadInt16(); - var bounds = Bounds.Load(reader); + Bounds bounds = Bounds.Load(reader); if (contoursCount >= 0) { diff --git a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphTable.cs b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphTable.cs index 72a0d1d1b..0b3b308b4 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphTable.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphTable.cs @@ -36,7 +36,7 @@ public static GlyphTable Load(BigEndianBinaryReader reader, TableFormat format, EmptyGlyphLoader empty = new(fallbackEmptyBounds); int entryCount = locations.Length; int glyphCount = entryCount - 1; // last entry is a placeholder to the end of the table - var glyphs = new GlyphLoader[glyphCount]; + GlyphLoader[] glyphs = new GlyphLoader[glyphCount]; // Special case for WOFF2 format where all glyphs need to be read in one go. if (format is TableFormat.Woff2) diff --git a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphVector.cs b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphVector.cs index 5fd363188..3bb3eef55 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphVector.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/GlyphVector.cs @@ -81,7 +81,7 @@ public static void Hint( return; } - var controlPoints = new ControlPoint[glyph.ControlPoints.Count + 4]; + ControlPoint[] controlPoints = new ControlPoint[glyph.ControlPoints.Count + 4]; controlPoints[controlPoints.Length - 4].Point = pp1; controlPoints[controlPoints.Length - 3].Point = pp2; controlPoints[controlPoints.Length - 2].Point = pp3; @@ -110,7 +110,7 @@ public static GlyphVector DeepClone(GlyphVector src) List controlPoints = new(src.ControlPoints); List endPoints = new(src.EndPoints); - return new(controlPoints, endPoints, src.Bounds, src.Instructions, src.IsComposite); + return new GlyphVector(controlPoints, endPoints, src.Bounds, src.Instructions, src.IsComposite); } /// diff --git a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/SimpleGlyphLoader.cs b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/SimpleGlyphLoader.cs index 3031155c2..4afe5de8e 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Glyphs/SimpleGlyphLoader.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Glyphs/SimpleGlyphLoader.cs @@ -72,10 +72,10 @@ public static GlyphLoader LoadSimpleGlyph(BigEndianBinaryReader reader, short co short[] xs = ReadCoordinates(reader, pointCount, flags, Flags.XByte, Flags.XSignOrSame); short[] ys = ReadCoordinates(reader, pointCount, flags, Flags.YByte, Flags.YSignOrSame); - var controlPoints = new ControlPoint[xs.Length]; + ControlPoint[] controlPoints = new ControlPoint[xs.Length]; for (int i = 0; i < flags.Length; i++) { - controlPoints[i] = new(new Vector2(xs[i], ys[i]), (flags[i] & Flags.OnCurve) == Flags.OnCurve); + controlPoints[i] = new ControlPoint(new Vector2(xs[i], ys[i]), (flags[i] & Flags.OnCurve) == Flags.OnCurve); } return new SimpleGlyphLoader(controlPoints, endPoints, bounds, instructions); @@ -83,7 +83,7 @@ public static GlyphLoader LoadSimpleGlyph(BigEndianBinaryReader reader, short co private static Flags[] ReadFlags(BigEndianBinaryReader reader, int flagCount) { - var result = new Flags[flagCount]; + Flags[] result = new Flags[flagCount]; int c = 0; int repeatCount = 0; Flags flag = default; diff --git a/src/SixLabors.Fonts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs b/src/SixLabors.Fonts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs index 5ab0499bd..64b0293bb 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs @@ -294,7 +294,7 @@ private void Execute(StackInstructionStream stream, bool inFunction, bool allowF { int y = this.stack.Pop(); int x = this.stack.Pop(); - var vec = Vector2.Normalize(new Vector2(F2Dot14ToFloat(x), F2Dot14ToFloat(y))); + Vector2 vec = Vector2.Normalize(new Vector2(F2Dot14ToFloat(x), F2Dot14ToFloat(y))); if (opcode == OpCode.SFVFS) { this.state.Freedom = vec; @@ -2321,7 +2321,7 @@ public Zone(ControlPoint[] controlPoints, bool isTwilight) this.IsTwilight = isTwilight; this.Current = controlPoints; - var original = new ControlPoint[controlPoints.Length]; + ControlPoint[] original = new ControlPoint[controlPoints.Length]; controlPoints.AsSpan().CopyTo(original); this.Original = original; this.TouchState = new TouchState[controlPoints.Length]; diff --git a/src/SixLabors.Fonts/Tables/TrueType/TrueTypeGlyphMetrics.cs b/src/SixLabors.Fonts/Tables/TrueType/TrueTypeGlyphMetrics.cs index f4c9658d7..b46656db2 100644 --- a/src/SixLabors.Fonts/Tables/TrueType/TrueTypeGlyphMetrics.cs +++ b/src/SixLabors.Fonts/Tables/TrueType/TrueTypeGlyphMetrics.cs @@ -140,10 +140,10 @@ internal override void RenderTo(IGlyphRenderer renderer, Vector2 location, Vecto { // Create a scaled deep copy of the vector so that we do not alter // the globally cached instance. - var clone = GlyphVector.DeepClone(this.vector); + GlyphVector clone = GlyphVector.DeepClone(this.vector); Vector2 scale = new Vector2(scaledPPEM) / this.ScaleFactor; - var matrix = Matrix3x2.CreateScale(scale); + Matrix3x2 matrix = Matrix3x2.CreateScale(scale); matrix.Translation = this.Offset * scale; GlyphVector.TransformInPlace(ref clone, matrix); diff --git a/src/SixLabors.Fonts/Tables/Woff/Woff2Utils.cs b/src/SixLabors.Fonts/Tables/Woff/Woff2Utils.cs index 05e76d744..341711a32 100644 --- a/src/SixLabors.Fonts/Tables/Woff/Woff2Utils.cs +++ b/src/SixLabors.Fonts/Tables/Woff/Woff2Utils.cs @@ -32,7 +32,7 @@ internal static class Woff2Utils public static ReadOnlyDictionary ReadWoff2Headers(BigEndianBinaryReader reader, int tableCount) { uint expectedTableStartAt = 0; - var headers = new Dictionary(tableCount); + Dictionary headers = new(tableCount); for (int i = 0; i < tableCount; i++) { Woff2TableHeader woffTableHeader = Read(reader, expectedTableStartAt, out uint nextExpectedTableStartAt); @@ -162,10 +162,10 @@ public static GlyphLoader[] LoadAllGlyphs(BigEndianBinaryReader reader, EmptyGly long bboxStreamOffset = compositeStreamOffset + compositeStreamSize; long instructionStreamOffset = bboxStreamOffset + bboxStreamSize; - var glyphs = new GlyphVector[numGlyphs]; - var allGlyphs = new GlyphData[numGlyphs]; - var glyphLoaders = new GlyphLoader[numGlyphs]; - var compositeGlyphs = new List(); + GlyphVector[] glyphs = new GlyphVector[numGlyphs]; + GlyphData[] allGlyphs = new GlyphData[numGlyphs]; + GlyphLoader[] glyphLoaders = new GlyphLoader[numGlyphs]; + List compositeGlyphs = new(); int contourCount = 0; for (ushort i = 0; i < numGlyphs; i++) { @@ -323,7 +323,7 @@ private static GlyphVector ReadSimpleGlyphData( endPoints[i] = (ushort)(pointCount - 1); } - var controlPoints = new ControlPoint[pointCount]; + ControlPoint[] controlPoints = new ControlPoint[pointCount]; int n = 0; for (int i = 0; i < numContour; i++) { @@ -370,7 +370,7 @@ private static GlyphVector ReadSimpleGlyphData( } // Most significant 1 bit -> on/off curve. - controlPoints[n] = new(new Vector2(curX += x, curY += y), f >> 7 == 0); + controlPoints[n] = new ControlPoint(new Vector2(curX += x, curY += y), f >> 7 == 0); } } @@ -459,7 +459,7 @@ private static GlyphVector ReadCompositeGlyphData(GlyphVector[] createdGlyphs, B transform.M22 = reader.ReadF2dot14(); } - var clone = GlyphVector.DeepClone(createdGlyphs[glyphIndex]); + GlyphVector clone = GlyphVector.DeepClone(createdGlyphs[glyphIndex]); GlyphVector.TransformInPlace(ref clone, transform); ushort endPointOffset = (ushort)controlPoints.Count; diff --git a/src/SixLabors.Fonts/Tables/Woff/WoffTableHeader.cs b/src/SixLabors.Fonts/Tables/Woff/WoffTableHeader.cs index 5aac24484..097692e70 100644 --- a/src/SixLabors.Fonts/Tables/Woff/WoffTableHeader.cs +++ b/src/SixLabors.Fonts/Tables/Woff/WoffTableHeader.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.Fonts.IO; + namespace SixLabors.Fonts.Tables.Woff; internal sealed class WoffTableHeader : TableHeader @@ -21,7 +23,7 @@ public override BigEndianBinaryReader CreateReader(Stream stream) // Read all data from the compressed stream. stream.Seek(this.Offset, SeekOrigin.Begin); - using var compressedStream = new IO.ZlibInflateStream(stream); + using ZlibInflateStream compressedStream = new(stream); byte[] uncompressedBytes = new byte[this.Length]; int totalBytesRead = 0; int bytesLeftToRead = uncompressedBytes.Length; @@ -37,7 +39,7 @@ public override BigEndianBinaryReader CreateReader(Stream stream) bytesLeftToRead -= bytesRead; } - var memoryStream = new MemoryStream(uncompressedBytes); + MemoryStream memoryStream = new(uncompressedBytes); return new BigEndianBinaryReader(memoryStream, false); } @@ -48,7 +50,7 @@ public override BigEndianBinaryReader CreateReader(Stream stream) // UInt32 | origLength | Length of the uncompressed table, excluding padding. // UInt32 | origChecksum | Checksum of the uncompressed table. public static new WoffTableHeader Read(BigEndianBinaryReader reader) => - new WoffTableHeader( + new( reader.ReadTag(), reader.ReadUInt32(), reader.ReadUInt32(), diff --git a/src/SixLabors.Fonts/TextLayout.cs b/src/SixLabors.Fonts/TextLayout.cs index 526c5d691..02b78eb4b 100644 --- a/src/SixLabors.Fonts/TextLayout.cs +++ b/src/SixLabors.Fonts/TextLayout.cs @@ -48,7 +48,7 @@ public static IReadOnlyList BuildTextRuns(ReadOnlySpan text, Text // Fill gaps within runs. if (textRun.Start > start) { - textRuns.Add(new() + textRuns.Add(new TextRun { Start = start, End = textRun.Start, @@ -74,7 +74,7 @@ public static IReadOnlyList BuildTextRuns(ReadOnlySpan text, Text // Add a final run if required. if (start < end) { - textRuns.Add(new() + textRuns.Add(new TextRun { Start = start, End = end, @@ -1342,9 +1342,9 @@ internal sealed class TextLine private readonly List data; private readonly Dictionary advances = new(); - public TextLine() => this.data = new(16); + public TextLine() => this.data = new List(16); - public TextLine(int capacity) => this.data = new(capacity); + public TextLine(int capacity) => this.data = new List(capacity); public int Count => this.data.Count; @@ -1384,7 +1384,7 @@ public void Add( this.ScaledMaxAscender = MathF.Max(this.ScaledMaxAscender, scaledAscender); this.ScaledMaxDescender = MathF.Max(this.ScaledMaxDescender, scaledDescender); - this.data.Add(new( + this.data.Add(new GlyphLayoutData( metrics, pointSize, scaledAdvance, @@ -1454,7 +1454,7 @@ public bool TrySplitAt(float length, [NotNullWhen(true)] out TextLine? result) if (advance >= length) { int count = this.data.Count - i; - result = new(count); + result = new TextLine(count); result.data.AddRange(this.data.GetRange(i, count)); RecalculateLineMetrics(result); @@ -1509,7 +1509,7 @@ public bool TrySplitAt(LineBreak lineBreak, bool keepAll, [NotNullWhen(true)] ou // Create a new line ensuring we capture the initial metrics. int count = this.data.Count - index; - result = new(count); + result = new TextLine(count); result.data.AddRange(this.data.GetRange(index, count)); RecalculateLineMetrics(result); @@ -1637,7 +1637,7 @@ public void BidiReOrder() if (run != g.BidiRun) { run = g.BidiRun; - current.Next = new(run.Level); + current.Next = new OrderedBidiRun(run.Level); current = current.Next; } diff --git a/src/SixLabors.Fonts/TextMeasurer.cs b/src/SixLabors.Fonts/TextMeasurer.cs index ae9edda93..8658be6d5 100644 --- a/src/SixLabors.Fonts/TextMeasurer.cs +++ b/src/SixLabors.Fonts/TextMeasurer.cs @@ -287,7 +287,7 @@ internal static bool TryGetCharacterSizes(IReadOnlyList glyphLayout { GlyphLayout g = glyphLayouts[i]; FontRectangle bounds = g.BoundingBox(dpi); - bounds = new(0, 0, bounds.Width, bounds.Height); + bounds = new FontRectangle(0, 0, bounds.Width, bounds.Height); hasSize |= bounds.Width > 0 || bounds.Height > 0; characterBoundsList[i] = new GlyphBounds(g.Glyph.GlyphMetrics.CodePoint, in bounds, g.GraphemeIndex, g.StringIndex); diff --git a/src/SixLabors.Fonts/Unicode/ArabicJoiningClass.cs b/src/SixLabors.Fonts/Unicode/ArabicJoiningClass.cs index e9cdab1e4..11aeafe86 100644 --- a/src/SixLabors.Fonts/Unicode/ArabicJoiningClass.cs +++ b/src/SixLabors.Fonts/Unicode/ArabicJoiningClass.cs @@ -37,7 +37,7 @@ public ArabicJoiningClass(CodePoint codePoint) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static ArabicJoiningType GetJoiningType(CodePoint codePoint, uint value, UnicodeCategory category) { - var type = (ArabicJoiningType)(value & 0xFF); + ArabicJoiningType type = (ArabicJoiningType)(value & 0xFF); // All others not explicitly listed have joining type U if (type == ArabicJoiningType.NonJoining) diff --git a/src/SixLabors.Fonts/Unicode/BidiAlgorithm.cs b/src/SixLabors.Fonts/Unicode/BidiAlgorithm.cs index 832543fc5..b281817bb 100644 --- a/src/SixLabors.Fonts/Unicode/BidiAlgorithm.cs +++ b/src/SixLabors.Fonts/Unicode/BidiAlgorithm.cs @@ -182,7 +182,7 @@ public BidiAlgorithm() /// Gets a per-thread instance that can be re-used as often /// as necessary. /// - public static ThreadLocal Instance { get; } = new ThreadLocal(() => new BidiAlgorithm()); + public static ThreadLocal Instance { get; } = new(() => new BidiAlgorithm()); /// /// Gets the resolved levels. diff --git a/src/SixLabors.Fonts/Unicode/BidiData.cs b/src/SixLabors.Fonts/Unicode/BidiData.cs index 6133a6889..0ca4aa037 100644 --- a/src/SixLabors.Fonts/Unicode/BidiData.cs +++ b/src/SixLabors.Fonts/Unicode/BidiData.cs @@ -76,7 +76,7 @@ public void Init(ReadOnlySpan text, sbyte paragraphEmbeddingLevel) this.HasIsolates = false; int i = 0; - var codePointEnumerator = new SpanCodePointEnumerator(text); + SpanCodePointEnumerator codePointEnumerator = new(text); while (codePointEnumerator.MoveNext()) { CodePoint codePoint = codePointEnumerator.Current; diff --git a/src/SixLabors.Fonts/Unicode/BidiDictionary{T1,T2}.cs b/src/SixLabors.Fonts/Unicode/BidiDictionary{T1,T2}.cs index cde400054..9d24f6fd4 100644 --- a/src/SixLabors.Fonts/Unicode/BidiDictionary{T1,T2}.cs +++ b/src/SixLabors.Fonts/Unicode/BidiDictionary{T1,T2}.cs @@ -12,9 +12,9 @@ internal sealed class BidiDictionary where T1 : struct where T2 : struct { - public Dictionary Forward { get; } = new Dictionary(); + public Dictionary Forward { get; } = new(); - public Dictionary Reverse { get; } = new Dictionary(); + public Dictionary Reverse { get; } = new(); public void Clear() { diff --git a/src/SixLabors.Fonts/Unicode/CodePoint.cs b/src/SixLabors.Fonts/Unicode/CodePoint.cs index e5057f779..661d869ed 100644 --- a/src/SixLabors.Fonts/Unicode/CodePoint.cs +++ b/src/SixLabors.Fonts/Unicode/CodePoint.cs @@ -179,7 +179,7 @@ public int Utf8SequenceLength /// /// Gets a instance that represents the Unicode replacement character U+FFFD. /// - public static CodePoint ReplacementChar { get; } = new CodePoint(0xFFFD); + public static CodePoint ReplacementChar { get; } = new(0xFFFD); #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member @@ -460,7 +460,7 @@ public static int GetCodePointCount(ReadOnlySpan source) } int count = 0; - var enumerator = new SpanCodePointEnumerator(source); + SpanCodePointEnumerator enumerator = new(source); while (enumerator.MoveNext()) { count++; diff --git a/src/SixLabors.Fonts/Unicode/LineBreakEnumerator.cs b/src/SixLabors.Fonts/Unicode/LineBreakEnumerator.cs index 1d81a2beb..36f1f57ff 100644 --- a/src/SixLabors.Fonts/Unicode/LineBreakEnumerator.cs +++ b/src/SixLabors.Fonts/Unicode/LineBreakEnumerator.cs @@ -97,7 +97,7 @@ public bool MoveNext() return true; } - bool? shouldBreak = this.GetSimpleBreak() ?? (bool?)this.GetPairTableBreak(lastClass); + bool? shouldBreak = this.GetSimpleBreak() ?? this.GetPairTableBreak(lastClass); // Rule LB8a this.lb8a = this.nextClass == LineBreakClass.ZWJ; diff --git a/src/SixLabors.Fonts/Unicode/MemoryExtensions.cs b/src/SixLabors.Fonts/Unicode/MemoryExtensions.cs index 21d78d19b..eff3198ba 100644 --- a/src/SixLabors.Fonts/Unicode/MemoryExtensions.cs +++ b/src/SixLabors.Fonts/Unicode/MemoryExtensions.cs @@ -88,7 +88,7 @@ public static SpanGraphemeEnumerator EnumerateGraphemes(this Span span) public static int GetGraphemeCount(this ReadOnlySpan span) { int count = 0; - var enumerator = new SpanGraphemeEnumerator(span); + SpanGraphemeEnumerator enumerator = new(span); while (enumerator.MoveNext()) { count++; @@ -105,7 +105,7 @@ public static int GetGraphemeCount(this ReadOnlySpan span) public static int GetGraphemeCount(this Span span) { int count = 0; - var enumerator = new SpanGraphemeEnumerator(span); + SpanGraphemeEnumerator enumerator = new(span); while (enumerator.MoveNext()) { count++; diff --git a/src/SixLabors.Fonts/Unicode/Resources/IndicShapingData.cs b/src/SixLabors.Fonts/Unicode/Resources/IndicShapingData.cs index 1fb945390..1597b228e 100644 --- a/src/SixLabors.Fonts/Unicode/Resources/IndicShapingData.cs +++ b/src/SixLabors.Fonts/Unicode/Resources/IndicShapingData.cs @@ -105,7 +105,7 @@ public enum BlwfMode { { ScriptClass.Devanagari, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x094D, @@ -117,7 +117,7 @@ public enum BlwfMode }, { ScriptClass.Bengali, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x09CD, @@ -129,7 +129,7 @@ public enum BlwfMode }, { ScriptClass.Gurmukhi, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0A4D, @@ -141,7 +141,7 @@ public enum BlwfMode }, { ScriptClass.Gujarati, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0ACD, @@ -153,7 +153,7 @@ public enum BlwfMode }, { ScriptClass.Oriya, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0B4D, @@ -165,7 +165,7 @@ public enum BlwfMode }, { ScriptClass.Tamil, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0BCD, @@ -177,7 +177,7 @@ public enum BlwfMode }, { ScriptClass.Telugu, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0C4D, @@ -189,7 +189,7 @@ public enum BlwfMode }, { ScriptClass.Kannada, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0CCD, @@ -201,7 +201,7 @@ public enum BlwfMode }, { ScriptClass.Malayalam, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x0D4D, @@ -213,7 +213,7 @@ public enum BlwfMode }, { ScriptClass.Khmer, - new() + new ShapingConfiguration { HasOldSpec = true, Virama = 0x17D2, diff --git a/src/SixLabors.Fonts/Unicode/SpanGraphemeEnumerator.cs b/src/SixLabors.Fonts/Unicode/SpanGraphemeEnumerator.cs index 4256e144f..7ee3832a6 100644 --- a/src/SixLabors.Fonts/Unicode/SpanGraphemeEnumerator.cs +++ b/src/SixLabors.Fonts/Unicode/SpanGraphemeEnumerator.cs @@ -51,7 +51,7 @@ public bool MoveNext() } // Algorithm given at https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules. - var processor = new Processor(this.source); + Processor processor = new(this.source); processor.MoveNext(); @@ -220,7 +220,7 @@ public Processor(ReadOnlySpan source) public void MoveNext() { this.CharsConsumed += this.charsConsumed; - var codePoint = CodePoint.DecodeFromUtf16At(this.source, this.CharsConsumed, out this.charsConsumed); + CodePoint codePoint = CodePoint.DecodeFromUtf16At(this.source, this.CharsConsumed, out this.charsConsumed); this.CurrentType = CodePoint.GetGraphemeClusterClass(codePoint); } } diff --git a/src/SixLabors.Fonts/Unicode/UnicodeTrie.cs b/src/SixLabors.Fonts/Unicode/UnicodeTrie.cs index 57920bf06..9bcec1773 100644 --- a/src/SixLabors.Fonts/Unicode/UnicodeTrie.cs +++ b/src/SixLabors.Fonts/Unicode/UnicodeTrie.cs @@ -55,7 +55,7 @@ public UnicodeTrie(ReadOnlySpan rawData) public UnicodeTrie(Stream stream) { // Read the header info - using (var br = new BinaryReader(stream, Encoding.UTF8, true)) + using (BinaryReader br = new(stream, Encoding.UTF8, true)) { this.highStart = br.ReadInt32(); this.errorValue = br.ReadUInt32(); @@ -63,7 +63,7 @@ public UnicodeTrie(Stream stream) } // Read the data in compressed format. - using (var br = new BinaryReader(stream, Encoding.UTF8, true)) + using (BinaryReader br = new(stream, Encoding.UTF8, true)) { for (int i = 0; i < this.data.Length; i++) { @@ -146,7 +146,7 @@ public uint Get(uint codePoint) public void Save(Stream stream) { // Write the header info - using (var bw = new BinaryWriter(stream, Encoding.UTF8, true)) + using (BinaryWriter bw = new(stream, Encoding.UTF8, true)) { bw.Write(this.highStart); bw.Write(this.errorValue); @@ -154,7 +154,7 @@ public void Save(Stream stream) } // Write the data. - using (var bw = new BinaryWriter(stream, Encoding.UTF8, true)) + using (BinaryWriter bw = new(stream, Encoding.UTF8, true)) { for (int i = 0; i < this.data.Length; i++) { diff --git a/src/SixLabors.Fonts/Utilities/StringLoader.cs b/src/SixLabors.Fonts/Utilities/StringLoader.cs index 164af47ab..ea60fd142 100644 --- a/src/SixLabors.Fonts/Utilities/StringLoader.cs +++ b/src/SixLabors.Fonts/Utilities/StringLoader.cs @@ -28,8 +28,8 @@ public StringLoader(ushort length, ushort offset, Encoding encoding) public static StringLoader Create(BigEndianBinaryReader reader) => Create(reader, Encoding.BigEndianUnicode); - public static StringLoader Create(BigEndianBinaryReader reader, Encoding encoding) - => new StringLoader(reader.ReadUInt16(), reader.ReadUInt16(), encoding); + public static StringLoader Create(BigEndianBinaryReader reader, Encoding encoding) => + new(reader.ReadUInt16(), reader.ReadUInt16(), encoding); public void LoadValue(BigEndianBinaryReader reader) => this.Value = reader.ReadString(this.Length, this.Encoding).Replace("\0", string.Empty); diff --git a/src/UnicodeTrieGenerator/Generator.IndicShapingEngine.cs b/src/UnicodeTrieGenerator/Generator.IndicShapingEngine.cs index abe1309d3..dba46d350 100644 --- a/src/UnicodeTrieGenerator/Generator.IndicShapingEngine.cs +++ b/src/UnicodeTrieGenerator/Generator.IndicShapingEngine.cs @@ -202,7 +202,7 @@ private static void GenerateIndicShapingDataTrie(Codepoint[] codePoints) { SetBlocks(codePoints); - var symbols = ((Categories[])Enum.GetValues(typeof(Categories))).ToDictionary(c => c.ToString(), c => (int)Math.Log((int)c, 2)); + Dictionary symbols = ((Categories[])Enum.GetValues(typeof(Categories))).ToDictionary(c => c.ToString(), c => (int)Math.Log((int)c, 2)); UnicodeTrieBuilder builder = new(); for (int i = 0; i < codePoints.Length; i++) @@ -224,7 +224,7 @@ private static void GenerateIndicShapingDataTrie(Codepoint[] codePoints) private static void SetBlocks(Codepoint[] codePoints) { - var regex = new Regex(@"^([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s*;\s*([\w\s-]+)"); + Regex regex = new(@"^([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s*;\s*([\w\s-]+)"); using StreamReader sr = GetStreamReader("Blocks.txt"); string? line; diff --git a/src/UnicodeTrieGenerator/StateAutomation/Compile.cs b/src/UnicodeTrieGenerator/StateAutomation/Compile.cs index b5aed88d8..399f212e1 100644 --- a/src/UnicodeTrieGenerator/StateAutomation/Compile.cs +++ b/src/UnicodeTrieGenerator/StateAutomation/Compile.cs @@ -16,7 +16,7 @@ public static StateMachine Build(string value, IDictionary? externa private static SymbolTable Parse(string value, IDictionary? externalSymbols = null) { IList ast = new GrammarParser().Parse(value); - return new SymbolTable(ast, new(externalSymbols ?? new Dictionary())); + return new SymbolTable(ast, new Dictionary(externalSymbols ?? new Dictionary())); } private static StateMachine Build(SymbolTable symbolTable) diff --git a/src/UnicodeTrieGenerator/StateAutomation/INode.cs b/src/UnicodeTrieGenerator/StateAutomation/INode.cs index 422d8cd40..a2048a03f 100644 --- a/src/UnicodeTrieGenerator/StateAutomation/INode.cs +++ b/src/UnicodeTrieGenerator/StateAutomation/INode.cs @@ -110,10 +110,10 @@ internal class Variable : Node, ILogicalNode public string Name { get; } /// - HashSet ILogicalNode.FirstPos { get; } = new HashSet(); + HashSet ILogicalNode.FirstPos { get; } = new(); /// - HashSet ILogicalNode.LastPos { get; } = new HashSet(); + HashSet ILogicalNode.LastPos { get; } = new(); /// public override INode Copy() => new Variable(this.Name); @@ -396,7 +396,7 @@ public static ILogicalNode Concat(ILogicalNode? a, ILogicalNode b) /// The . public static HashSet Union(HashSet a, HashSet b) { - var s = new HashSet(a); + HashSet s = new(a); AddAll(s, b); return s; } diff --git a/tests/SixLabors.Fonts.Tests/Accents.cs b/tests/SixLabors.Fonts.Tests/Accents.cs index da9a2eedb..b54238997 100644 --- a/tests/SixLabors.Fonts.Tests/Accents.cs +++ b/tests/SixLabors.Fonts.Tests/Accents.cs @@ -17,7 +17,7 @@ public class Accents public void MeasuringAccentedCharacterDoesNotThrow(char c) { FontFamily sans = new FontCollection().Add(TestFonts.OpenSansFile); - var font = new Font(sans, 1f, FontStyle.Regular); + Font font = new(sans, 1f, FontStyle.Regular); FontRectangle size = TextMeasurer.MeasureSize(c.ToString(), new TextOptions(font)); } @@ -34,7 +34,7 @@ public void MeasuringAccentedCharacterDoesNotThrow(char c) public void MeasuringWordWithAccentedCharacterDoesNotThrow(char c) { FontFamily sans = new FontCollection().Add(TestFonts.OpenSansFile); - var font = new Font(sans, 1f, FontStyle.Regular); + Font font = new(sans, 1f, FontStyle.Regular); FontRectangle size = 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 303f5b975..1c7a2c508 100644 --- a/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs +++ b/tests/SixLabors.Fonts.Tests/ColorGlyphRenderer.cs @@ -5,7 +5,7 @@ namespace SixLabors.Fonts.Tests; public class ColorGlyphRenderer : GlyphRenderer, IColorGlyphRenderer { - public List Colors { get; } = new List(); + public List Colors { get; } = new(); public void SetColor(GlyphColor color) => this.Colors.Add(color); } diff --git a/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs b/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs index 3abbaa11f..092db65df 100644 --- a/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs +++ b/tests/SixLabors.Fonts.Tests/CompactFontFormatTests.cs @@ -14,7 +14,7 @@ public void FDSelectFormat0_Works(string testStr, int expectedGlyphIndex) { // arrange Font font = new FontCollection().Add(TestFonts.FDArrayTest257File).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + 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..5a52d604c 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,16 +60,16 @@ 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(); VerticalMetricsTable vmtx = GenerateVerticalMetricsTable(glyphs); IndexLocationTable loca = GenerateIndexLocationTable(glyphs); - return new(cmap, head, hhea, htmx, maxp, name, os2, post, glyf, loca) + return new TrueTypeFontTables(cmap, head, hhea, htmx, maxp, name, os2, post, glyf, loca) { Kern = kern, Vhea = vhea, diff --git a/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs b/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs index 2a9fc5a96..7f1bd23af 100644 --- a/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontCodePointsTests.cs @@ -10,7 +10,7 @@ public class FontCodePointsTests [Fact] public void TtfTest() { - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.SimpleFontFile); Font font = family.CreateFont(12); @@ -47,7 +47,7 @@ public void TtfTest() [Fact] public void WoffTest() { - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.SimpleFontFileWoff); Font font = family.CreateFont(12); 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/FontLoaderTests.cs b/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs index af86164b4..a1a8f2292 100644 --- a/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontLoaderTests.cs @@ -25,7 +25,7 @@ public void Issue21_LoopDetectedLoadingGlyphs() [Fact] public void LoadFontMetadata() { - var description = FontDescription.LoadDescription(TestFonts.SimpleFontFileData()); + FontDescription description = FontDescription.LoadDescription(TestFonts.SimpleFontFileData()); Assert.Equal("SixLaborsSampleAB regular", description.FontNameInvariantCulture); Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture); @@ -34,7 +34,7 @@ public void LoadFontMetadata() [Fact] public void LoadFontMetadataWoff() { - var description = FontDescription.LoadDescription(TestFonts.SimpleFontFileWoffData()); + FontDescription description = FontDescription.LoadDescription(TestFonts.SimpleFontFileWoffData()); Assert.Equal("SixLaborsSampleAB regular", description.FontNameInvariantCulture); Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture); @@ -74,7 +74,7 @@ public void LoadFont_WithWoff1Format() [Fact] public void LoadFontMetadata_WithWoff1Format() { - var description = FontDescription.LoadDescription(TestFonts.OpensSansWoff1Data()); + FontDescription description = FontDescription.LoadDescription(TestFonts.OpensSansWoff1Data()); Assert.Equal("Open Sans Regular", description.FontNameInvariantCulture); Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture); @@ -83,7 +83,7 @@ public void LoadFontMetadata_WithWoff1Format() [Fact] public void LoadFontMetadata_WithWoff2Format() { - var description = FontDescription.LoadDescription(TestFonts.OpensSansWoff2Data()); + FontDescription description = FontDescription.LoadDescription(TestFonts.OpensSansWoff2Data()); Assert.Equal("Open Sans Regular", description.FontNameInvariantCulture); Assert.Equal("Regular", description.FontSubFamilyNameInvariantCulture); @@ -145,7 +145,7 @@ public void LoadFontWithIncorrectClassDefinitionTableOffset() // See https://forum.stimulsoft.com/viewtopic.php?t=60972 Font font = new FontCollection().Add(TestFonts.THSarabunFile).CreateFont(12); - FontRectangle advance = TextMeasurer.MeasureAdvance("เราใช้คุกกี้เพื่อพัฒนาประสิทธิภาพ และประสบการณ์ที่ดีในการใช้เว็บไซต์ของคุณ คุณสามารถศึกษารายละเอียดได้ที่", new(font)); + FontRectangle advance = TextMeasurer.MeasureAdvance("เราใช้คุกกี้เพื่อพัฒนาประสิทธิภาพ และประสบการณ์ที่ดีในการใช้เว็บไซต์ของคุณ คุณสามารถศึกษารายละเอียดได้ที่", new TextOptions(font)); Assert.NotEqual(default, advance); } diff --git a/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs b/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs index 250f63c52..19fe1739e 100644 --- a/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontMetricsTests.cs @@ -13,7 +13,7 @@ public void FontMetricsMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.OpenSansFile); Font font = family.CreateFont(12); @@ -52,7 +52,7 @@ public void FontMetricsVerticalFontMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.NotoSansSCThinFile); Font font = family.CreateFont(12); @@ -99,7 +99,7 @@ public void FontMetricsVerticalFontMatchesReferenceCFF() { // Compared to OpenTypeJS Font Inspector metrics // https://opentype.js.org/font-inspector.html - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.NotoSansKRRegular); Font font = family.CreateFont(12); @@ -146,11 +146,11 @@ public void GlyphMetricsMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.OpenSansFile); Font font = family.CreateFont(12); - var codePoint = new CodePoint('A'); + CodePoint codePoint = new('A'); Assert.True(font.FontMetrics.TryGetGlyphMetrics( codePoint, @@ -178,11 +178,11 @@ public void GlyphMetricsMatchesReference_WithWoff1format() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.OpenSansFileWoff1); Font font = family.CreateFont(12); - var codePoint = new CodePoint('A'); + CodePoint codePoint = new('A'); Assert.True(font.FontMetrics.TryGetGlyphMetrics( codePoint, @@ -210,11 +210,11 @@ public void GlyphMetricsMatchesReference_WithWoff2format() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.OpenSansFileWoff2); Font font = family.CreateFont(12); - var codePoint = new CodePoint('A'); + CodePoint codePoint = new('A'); Assert.True(font.FontMetrics.TryGetGlyphMetrics( codePoint, @@ -242,11 +242,11 @@ public void GlyphMetricsVerticalMatchesReference() { // Compared to EveryFonts TTFDump metrics // https://everythingfonts.com/ttfdump - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.NotoSansSCThinFile); Font font = family.CreateFont(12); - var codePoint = new CodePoint('A'); + CodePoint codePoint = new('A'); Assert.True(font.FontMetrics.TryGetGlyphMetrics( codePoint, diff --git a/tests/SixLabors.Fonts.Tests/FontReaderTests.cs b/tests/SixLabors.Fonts.Tests/FontReaderTests.cs index 2c0983279..2b94a576e 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)); @@ -59,7 +59,7 @@ public void ReadCMapTable() new byte[] { 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..c801c8f13 100644 --- a/tests/SixLabors.Fonts.Tests/FontTests.cs +++ b/tests/SixLabors.Fonts.Tests/FontTests.cs @@ -44,9 +44,9 @@ public void FontClass_NullWithSizeFontThrowsException() [Fact] public void FontClassWithPath_SetProperties() { - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.CarterOneFile); - var font = new Font(family, 12); + Font font = new(family, 12); Assert.Equal("Carter One", font.Name); Assert.Equal(12, font.Size); @@ -60,10 +60,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/GlyphTests.cs b/tests/SixLabors.Fonts.Tests/GlyphTests.cs index ebec89c08..7002f896e 100644 --- a/tests/SixLabors.Fonts.Tests/GlyphTests.cs +++ b/tests/SixLabors.Fonts.Tests/GlyphTests.cs @@ -55,7 +55,7 @@ public void RenderToPointAndSingleDPI() public void IdenticalGlyphsInDifferentPlacesCreateIdenticalKeys() { Font fakeFont = CreateFont("AB"); - var textRenderer = new TextRenderer(this.renderer); + TextRenderer textRenderer = new(this.renderer); textRenderer.RenderText("ABA", new TextOptions(fakeFont)); @@ -66,10 +66,10 @@ public void IdenticalGlyphsInDifferentPlacesCreateIdenticalKeys() [Fact] public void BeginGlyph_ReturnsFalse_SkipRenderingFigures() { - var renderer = new Mock(); + Mock renderer = new(); renderer.Setup(x => x.BeginGlyph(It.Ref.IsAny, It.Ref.IsAny)).Returns(false); Font fakeFont = CreateFont("A"); - var textRenderer = new TextRenderer(renderer.Object); + TextRenderer textRenderer = new(renderer.Object); textRenderer.RenderText("ABA", new TextOptions(fakeFont)); renderer.Verify(x => x.BeginFigure(), Times.Never); @@ -78,10 +78,10 @@ public void BeginGlyph_ReturnsFalse_SkipRenderingFigures() [Fact] public void BeginGlyph_ReturnsTrue_RendersFigures() { - var renderer = new Mock(); + Mock renderer = new(); renderer.Setup(x => x.BeginGlyph(It.Ref.IsAny, It.Ref.IsAny)).Returns(true); Font fakeFont = CreateFont("A"); - var textRenderer = new TextRenderer(renderer.Object); + TextRenderer textRenderer = new(renderer.Object); textRenderer.RenderText("ABA", new TextOptions(fakeFont)); renderer.Verify(x => x.BeginFigure(), Times.Exactly(3)); @@ -89,7 +89,7 @@ public void BeginGlyph_ReturnsTrue_RendersFigures() public static Font CreateFont(string text, float pointSize = 1) { - 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, pointSize); } @@ -113,7 +113,7 @@ public void RenderColrGlyph() Font font = new FontCollection().Add(TestFonts.TwemojiMozillaData()).CreateFont(12); // Get letter Grinning Face emoji - var instance = font.FontMetrics as StreamFontMetrics; + StreamFontMetrics instance = font.FontMetrics as StreamFontMetrics; CodePoint codePoint = this.AsCodePoint("😀"); Assert.True(instance.TryGetGlyphId(codePoint, out ushort idx)); IEnumerable vectors = instance.GetGlyphMetrics( @@ -132,7 +132,7 @@ public void RenderColrGlyphTextRenderer() { Font font = new FontCollection().Add(TestFonts.TwemojiMozillaData()).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, "😀", new TextOptions(font) { ColorFontSupport = ColorFontSupport.MicrosoftColrFormat @@ -180,14 +180,14 @@ public void RenderWoffGlyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHin Font fontWoff = new FontCollection().Add(TestFonts.OpenSansFileWoff1).CreateFont(12); string testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - var rendererTtf = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) { KerningMode = applyKerning ? KerningMode.Standard : KerningMode.None, HintingMode = applyHinting ? HintingMode.Standard : HintingMode.None, ColorFontSupport = ColorFontSupport.MicrosoftColrFormat }); - var rendererWoff = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererWoff = new(); TextRenderer.RenderTextTo(rendererWoff, testStr, new TextOptions(fontWoff) { KerningMode = applyKerning ? KerningMode.Standard : KerningMode.None, @@ -210,13 +210,13 @@ 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); - var rendererTtf = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) { HintingMode = HintingMode.Standard, ColorFontSupport = ColorFontSupport.MicrosoftColrFormat }); - var rendererWoff = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererWoff = new(); TextRenderer.RenderTextTo(rendererWoff, testStr, new TextOptions(fontWoff) { HintingMode = HintingMode.Standard, @@ -238,14 +238,14 @@ public void RenderWoff2Glyphs_IsEqualToTtfGlyphs(bool applyKerning, bool applyHi Font fontWoff2 = new FontCollection().Add(TestFonts.OpenSansFileWoff2).CreateFont(12); string testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - var rendererTtf = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) { KerningMode = applyKerning ? KerningMode.Standard : KerningMode.None, HintingMode = applyHinting ? HintingMode.Standard : HintingMode.None, ColorFontSupport = ColorFontSupport.MicrosoftColrFormat }); - var rendererWoff2 = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererWoff2 = new(); TextRenderer.RenderTextTo(rendererWoff2, testStr, new TextOptions(fontWoff2) { KerningMode = applyKerning ? KerningMode.Standard : KerningMode.None, @@ -268,13 +268,13 @@ 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); - var rendererTtf = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererTtf = new(); TextRenderer.RenderTextTo(rendererTtf, testStr, new TextOptions(fontTtf) { HintingMode = HintingMode.Standard, ColorFontSupport = ColorFontSupport.MicrosoftColrFormat }); - var rendererWoff2 = new ColorGlyphRenderer(); + ColorGlyphRenderer rendererWoff2 = new(); TextRenderer.RenderTextTo(rendererWoff2, testStr, new TextOptions(fontWoff2) { HintingMode = HintingMode.Standard, diff --git a/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs b/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs index f321e849c..43c5400f8 100644 --- a/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs +++ b/tests/SixLabors.Fonts.Tests/ImageComparison/ExactImageComparer.cs @@ -9,7 +9,7 @@ namespace SixLabors.Fonts.Tests.ImageComparison; public class ExactImageComparer : ImageComparer { - public static ExactImageComparer Instance { get; } = new ExactImageComparer(); + public static ExactImageComparer Instance { get; } = new(); public override ImageSimilarityReport CompareImagesOrFrames( int index, diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_104.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_104.cs index 3cb734f19..b13421b95 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_104.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_104.cs @@ -21,7 +21,7 @@ public void Format4SubTableWithSegmentsHasOffByOneWhenOverflowing() short.MaxValue, // delta 0) // zero to force correctly tested codepath }; - var tbl = new Format4SubTable( + Format4SubTable tbl = new( 0, WellKnownIds.PlatformIDs.Windows, 0, 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 63e605d10..349aea945 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_23.cs @@ -11,7 +11,7 @@ public void BleadingFonts() // wendy one returns wrong points for 'o' Font font = new FontCollection().Add(TestFonts.WendyOneFile).CreateFont(12); - var r = new GlyphRenderer(); + GlyphRenderer r = new(); new TextRenderer(r).RenderText("o", new TextOptions(new Font(font, 30))); 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_337.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs index cf6e611d1..b44230f5f 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_337.cs @@ -20,13 +20,13 @@ public void CanShapeCompositeGlyphs() Assert.Equal(5, renderer.GlyphKeys.Count); Assert.Equal(5, renderer.GlyphRects.Count); - var expected = new FontRectangle[] + FontRectangle[] expected = new FontRectangle[] { - new FontRectangle(0, -254.99994F, 1024, 1024), - new FontRectangle(1024, -254.99994F, 1024, 1024), - new FontRectangle(2048, -254.99994F, 1024, 1024), - new FontRectangle(3072, -254.99994F, 1024, 1024), - new FontRectangle(4096, -254.99994F, 1024, 1024) + new(0, -254.99994F, 1024, 1024), + new(1024, -254.99994F, 1024, 1024), + new(2048, -254.99994F, 1024, 1024), + new(3072, -254.99994F, 1024, 1024), + new(4096, -254.99994F, 1024, 1024) }; for (int i = 0; i < expected.Length; i++) diff --git a/tests/SixLabors.Fonts.Tests/Issues/Issues_39.cs b/tests/SixLabors.Fonts.Tests/Issues/Issues_39.cs index 060851d06..f383e840b 100644 --- a/tests/SixLabors.Fonts.Tests/Issues/Issues_39.cs +++ b/tests/SixLabors.Fonts.Tests/Issues/Issues_39.cs @@ -13,14 +13,14 @@ public void RenderingEmptyString_DoesNotThrow() { Font font = CreateFont("\t x"); - var r = new GlyphRenderer(); + GlyphRenderer r = new(); new TextRenderer(r).RenderText(string.Empty, new TextOptions(new Font(font, 30))); } 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_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/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 bc9a3fb79..35d938946 100644 --- a/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs +++ b/tests/SixLabors.Fonts.Tests/SystemFontCollectionTests.cs @@ -99,7 +99,7 @@ public void CanEnumerateNonGenericSystemFontMetrics() [Fact] public void CanGetAllMetricsByCulture() { - var collection = (IReadOnlyFontMetricsCollection)SysFontCollection; + IReadOnlyFontMetricsCollection collection = (IReadOnlyFontMetricsCollection)SysFontCollection; FontFamily family = SysFontCollection.Families.First(); IEnumerable metrics = collection.GetAllMetrics(family.Name, family.Culture); diff --git a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs index 641727edf..63e0c9026 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/GPos/GPosTableTests.cs @@ -14,7 +14,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -49,7 +49,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -84,7 +84,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -120,7 +120,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -155,7 +155,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -190,7 +190,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -225,7 +225,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -260,7 +260,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -296,7 +296,7 @@ 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 }; FontRectangle[] expectedFontRectangles = @@ -332,7 +332,7 @@ 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 }; @@ -369,7 +369,7 @@ 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"; @@ -408,7 +408,7 @@ 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"; @@ -447,7 +447,7 @@ 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"; @@ -484,7 +484,7 @@ 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 }; @@ -519,7 +519,7 @@ 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 }; 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 a80608456..93555bd53 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.Hangul.cs @@ -13,7 +13,7 @@ public partial class GSubTableTests private static Font CreateHangulFont() { - var collection = new FontCollection(); + FontCollection collection = new(); FontFamily family = collection.Add(TestFonts.NotoSansKRRegular); return family.CreateFont(12); } diff --git a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs index 210482371..7d5a5628e 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/AdvancedTypographic/Gsub/GSubTableTests.cs @@ -41,7 +41,7 @@ public void RenderArabicCharacters_WithIsolatedForm_Works(string testStr, int ex { // arrange Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); // act TextRenderer.RenderTextTo(renderer, testStr, new TextOptions(arabicFont)); @@ -58,7 +58,7 @@ public void SingleSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "A"; int expectedGlyphIndex = 38; // we expect A to be mapped to B. @@ -75,7 +75,7 @@ public void ContextualFractions_WithFractionSlash_Works() { // arrange Font font = new FontCollection().Add(TestFonts.RobotoRegular).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "9⁄2"; int[] expectedGlyphIndices = { 580, 404, 453 }; @@ -95,7 +95,7 @@ public void ContextualFractions_WithSlash_Works() { // arrange Font font = new FontCollection().Add(TestFonts.RobotoRegular).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "9/2"; int[] expectedGlyphIndices = { 580, 404, 453 }; @@ -117,7 +117,7 @@ public void MultipleSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "C"; int expectedGlyphIndex = 40; // we expect C to be mapped to D. @@ -136,7 +136,7 @@ public void AlternateSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "E"; int expectedGlyphIndex = 42; // we expect E to be mapped to F. @@ -155,7 +155,7 @@ public void LigatureSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "ffi"; int expectedGlyphIndex = 229; @@ -174,7 +174,7 @@ public void ContextualSubstitution_Format1_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042"; // "6566" (\u0041\u0042) -> "6576" int[] expectedGlyphIndices = { 3, 7 }; @@ -196,7 +196,7 @@ public void ContextualSubstitution_Format2_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042"; // "6566" (\u0041\u0042) -> "6576" int[] expectedGlyphIndices = { 3, 7 }; @@ -218,7 +218,7 @@ public void ContextualSubstitution_Format3_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType5Format3).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0041\u0042\u0043\u0044"; // "65666768" -> "657678" int[] expectedGlyphIndices = { 67, 78, 80 }; @@ -240,7 +240,7 @@ public void ChainedContextsSubstitution_Format1_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType6Format1).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016\u0017"; // "20212223" -> "20636423" int[] expectedGlyphIndices = { 22, 63, 64, 25 }; @@ -262,7 +262,7 @@ public void ChainedContextsSubstitution_Format2_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubLookupType6Format2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "\u0014\u0015\u0016\u0017"; // "20212223" -> "20216423" int[] expectedGlyphIndices = { 22, 23, 64, 25 }; @@ -284,7 +284,7 @@ public void ChainedContextsSubstitution_Format3_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "x=y"; // This should be replaced with "x>y". int[] expectedGlyphIndices = { 89, 31, 90 }; @@ -306,7 +306,7 @@ public void ChainedContextsSubstitution_Format3_WithCursiveScript_Works() { // arrange Font font = new FontCollection().Add(TestFonts.FormalScript).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "ba"; // Characters following b should have a special form and should be replaced. int[] expectedGlyphIndices = { 69, 102 }; @@ -328,7 +328,7 @@ public void ReverseChainingContextualSingleSubstitution_Works() { // arrange Font font = new FontCollection().Add(TestFonts.GSubTestFontFile2).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "X89"; // X89 -> XYZ int[] expectedGlyphIndices = { 57, 58, 59 }; @@ -349,7 +349,7 @@ public void OldStyleFiguresFeature_Works() { // arrange Font font = new FontCollection().Add(TestFonts.EbGaramond).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "123456"; int[] expectedGlyphIndices = { 2242, 2243, 2244, 2245, 2246, 2247 }; diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/CMap/Format0SubTableTests.cs index a96f873a7..0887ad0f4 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( @@ -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, new byte[] { 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, new byte[] { 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..1bd8ac39b 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( @@ -71,7 +71,7 @@ public void GetCharacter(int src, int expected, bool expectedFound) 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..3131c029f 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/CMapTableTests.cs @@ -12,14 +12,14 @@ 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 }) }); - var table = CMapTable.Load(writer.GetReader()); + CMapTable table = CMapTable.Load(writer.GetReader()); Assert.Single(table.Tables.Where(x => x != null)); @@ -30,14 +30,14 @@ public void LoadFormat0() [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..5167a91f0 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,7 +24,7 @@ public void ShouldReturnNullWhenTableCouldNotBeFound() [Fact] public void ShouldReturnTableValues() { - var writer = new BigEndianBinaryWriter(); + BigEndianBinaryWriter writer = new(); writer.WriteTrueTypeFileHeader(); writer.WriteColrTable(new[] { @@ -50,7 +50,7 @@ public void ShouldReturnTableValues() 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..044dd0852 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,10 +19,10 @@ 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()) @@ -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,10 +45,10 @@ 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()) @@ -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,10 +71,10 @@ 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()) @@ -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,10 +97,10 @@ 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()) diff --git a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs index 15ecd0085..49341fa94 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/General/Glyphs/GlyphVectorTests.cs @@ -14,11 +14,11 @@ 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); + 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)); @@ -33,9 +33,9 @@ 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); + 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; @@ -72,9 +72,9 @@ public void TtfTransformWith2x2Matrix_Works() }; 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); + 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..61dfe07af 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 @@ -59,7 +59,7 @@ public void LoadFormat1() "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 +73,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..8ccf5e581 100644 --- a/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Tables/TableHeaderTests.cs @@ -8,7 +8,7 @@ namespace SixLabors.Fonts.Tests.Tables; public class TableHeaderTests { public static TheoryData ReadAllValuesData { get; } = - new TheoryData + new() { { "TAG1", 98, 18, 1218 }, { "TAG2", 198, 0, 121 }, @@ -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/TestFonts.cs b/tests/SixLabors.Fonts.Tests/TestFonts.cs index b7a5e2330..b9bb62043 100644 --- a/tests/SixLabors.Fonts.Tests/TestFonts.cs +++ b/tests/SixLabors.Fonts.Tests/TestFonts.cs @@ -305,7 +305,7 @@ private static Stream OpenStream(string path) => private static Stream Clone(this Stream src) { - var ms = new MemoryStream(); + MemoryStream ms = new(); src.Position = 0; src.CopyTo(ms); ms.Position = 0; diff --git a/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs b/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs index 51c680305..5da9df40a 100644 --- a/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs +++ b/tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs @@ -44,11 +44,11 @@ public static void TestLayout( { if (!options.LayoutMode.IsHorizontal()) { - img.Mutate(x => x.DrawLine(Color.Red, 1, new(0, wrappingLength), new(width, wrappingLength))); + img.Mutate(x => x.DrawLine(Color.Red, 1, new PointF(0, wrappingLength), new PointF(width, wrappingLength))); } else { - img.Mutate(x => x.DrawLine(Color.Red, 1, new(wrappingLength, 0), new(wrappingLength, height))); + img.Mutate(x => x.DrawLine(Color.Red, 1, new PointF(wrappingLength, 0), new PointF(wrappingLength, height))); } if (properties.Any()) diff --git a/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs b/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs index 7b3ff0ca3..081282a2d 100644 --- a/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs +++ b/tests/SixLabors.Fonts.Tests/TextLayoutTests.cs @@ -468,7 +468,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(); + FontCollection c = new(); Font font = c.Add(TestFonts.SimpleFontFileData()).CreateFont(12); FontRectangle size = TextMeasurer.MeasureBounds( text, @@ -486,11 +486,11 @@ 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(); + FontCollection c = new(); Font font = c.Add(TestFonts.SimpleFontFileData()).CreateFont(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)) @@ -591,9 +591,9 @@ 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 }, } }; @@ -646,8 +646,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 }, } }; @@ -852,100 +852,100 @@ public void TextJustification_InterWord_Vertical(TextDirection direction) public static TheoryData OpenSans_Data = new() { - { '!', new(0F, 0F, 1.1621094F, 7.2753906F) }, - { '"', new(0F, 0F, 2.6660156F, 2.578125F) }, - { '#', new(0F, 0F, 5.9472656F, 7.138672F) }, - { '$', new(0F, 0F, 4.4921875F, 8.168945F) }, - { '%', new(0F, 0F, 7.270508F, 7.338867F) }, - { '&', new(0F, 0F, 6.689453F, 7.348633F) }, - { '\'', new(0F, 0F, 0.87890625F, 2.578125F) }, - { '(', new(0F, 0F, 2.2460938F, 8.720703F) }, - { ')', new(0F, 0F, 2.2460938F, 8.720703F) }, - { '*', new(0F, 0F, 4.614258F, 4.4433594F) }, - { '+', new(0F, 0F, 4.692383F, 4.814453F) }, - { ',', new(0F, 0F, 1.4404297F, 2.4511719F) }, - { '-', new(0F, 0F, 2.421875F, 0.72265625F) }, - { '.', new(0F, 0F, 1.1621094F, 1.2744141F) }, - { '/', new(0F, 0F, 3.4570312F, 7.138672F) }, - { '0', new(0F, 0F, 4.7070312F, 7.348633F) }, - { '1', new(0F, 0F, 2.6074219F, 7.138672F) }, - { '2', new(0F, 0F, 4.6777344F, 7.241211F) }, - { '3', new(0F, 0F, 4.6777344F, 7.338867F) }, - { '4', new(0F, 0F, 5.3125F, 7.1777344F) }, - { '5', new(0F, 0F, 4.4970703F, 7.236328F) }, - { '6', new(0F, 0F, 4.6679688F, 7.338867F) }, - { '7', new(0F, 0F, 4.760742F, 7.138672F) }, - { '8', new(0F, 0F, 4.6972656F, 7.338867F) }, - { '9', new(0F, 0F, 4.6777344F, 7.34375F) }, - { ':', new(0F, 0F, 1.1621094F, 5.6152344F) }, - { ';', new(0F, 0F, 1.5576172F, 6.767578F) }, - { '<', new(0F, 0F, 4.6972656F, 4.868164F) }, - { '=', new(0F, 0F, 4.580078F, 2.65625F) }, - { '>', new(0F, 0F, 4.6972656F, 4.868164F) }, - { '?', new(0F, 0F, 3.8916016F, 7.3779297F) }, - { '@', new(0F, 0F, 7.817383F, 8.032227F) }, - { 'A', new(0F, 0F, 6.3134766F, 7.1679688F) }, - { 'B', new(0F, 0F, 4.9414062F, 7.138672F) }, - { 'C', new(0F, 0F, 5.3808594F, 7.338867F) }, - { 'D', new(0F, 0F, 5.6689453F, 7.138672F) }, - { 'E', new(0F, 0F, 3.9746094F, 7.138672F) }, - { 'F', new(0F, 0F, 3.9746094F, 7.138672F) }, - { 'G', new(0F, 0F, 5.913086F, 7.338867F) }, - { 'H', new(0F, 0F, 5.4101562F, 7.138672F) }, - { 'I', new(0F, 0F, 0.8300781F, 7.138672F) }, - { 'J', new(0F, 0F, 2.5683594F, 9.018555F) }, - { 'K', new(0F, 0F, 5.1464844F, 7.138672F) }, - { 'L', new(0F, 0F, 3.9990234F, 7.138672F) }, - { 'M', new(0F, 0F, 7.0410156F, 7.138672F) }, - { 'N', new(0F, 0F, 5.5810547F, 7.138672F) }, - { 'O', new(0F, 0F, 6.557617F, 7.348633F) }, - { 'P', new(0F, 0F, 4.5214844F, 7.138672F) }, - { 'Q', new(0F, 0F, 6.557617F, 8.950195F) }, - { 'R', new(0F, 0F, 5.029297F, 7.138672F) }, - { 'S', new(0F, 0F, 4.4921875F, 7.338867F) }, - { 'T', new(0F, 0F, 5.317383F, 7.138672F) }, - { 'U', new(0F, 0F, 5.473633F, 7.236328F) }, - { 'V', new(0F, 0F, 5.961914F, 7.138672F) }, - { 'W', new(0F, 0F, 8.94043F, 7.138672F) }, - { 'X', new(0F, 0F, 5.7128906F, 7.138672F) }, - { 'Y', new(0F, 0F, 5.5908203F, 7.138672F) }, - { 'Z', new(0F, 0F, 4.9560547F, 7.138672F) }, - { '[', new(0F, 0F, 2.211914F, 8.720703F) }, - { '\\', new(0F, 0F, 3.4667969F, 7.138672F) }, - { ']', new(0F, 0F, 2.2167969F, 8.720703F) }, - { '^', new(0F, 0F, 4.9414062F, 4.5117188F) }, - { '_', new(0F, 0F, 4.4189453F, 0.60058594F) }, - { '`', new(0F, 0F, 1.9775391F, 1.6015625F) }, - { 'a', new(0F, 0F, 4.2822266F, 5.5371094F) }, - { 'b', new(0F, 0F, 4.7070312F, 7.6953125F) }, - { 'c', new(0F, 0F, 3.90625F, 5.546875F) }, - { 'd', new(0F, 0F, 4.7021484F, 7.6953125F) }, - { 'e', new(0F, 0F, 4.536133F, 5.546875F) }, - { 'f', new(0F, 0F, 3.671875F, 7.651367F) }, - { 'g', new(0F, 0F, 5.078125F, 7.861328F) }, - { 'h', new(0F, 0F, 4.4628906F, 7.5976562F) }, - { 'i', new(0F, 0F, 0.9765625F, 7.3535156F) }, - { 'j', new(0F, 0F, 2.3046875F, 9.755859F) }, - { 'k', new(0F, 0F, 4.321289F, 7.5976562F) }, - { 'l', new(0F, 0F, 0.8154297F, 7.5976562F) }, - { 'm', new(0F, 0F, 7.5927734F, 5.4492188F) }, - { 'n', new(0F, 0F, 4.4628906F, 5.4492188F) }, - { 'o', new(0F, 0F, 4.9121094F, 5.546875F) }, - { 'p', new(0F, 0F, 4.7070312F, 7.841797F) }, - { 'q', new(0F, 0F, 4.7021484F, 7.841797F) }, - { 'r', new(0F, 0F, 3.0810547F, 5.4492188F) }, - { 's', new(0F, 0F, 3.8134766F, 5.546875F) }, - { 't', new(0F, 0F, 3.178711F, 6.689453F) }, - { 'u', new(0F, 0F, 4.477539F, 5.4492188F) }, - { 'v', new(0F, 0F, 4.995117F, 5.3515625F) }, - { 'w', new(0F, 0F, 7.5146484F, 5.3515625F) }, - { 'x', new(0F, 0F, 4.8535156F, 5.3515625F) }, - { 'y', new(0F, 0F, 5F, 7.758789F) }, - { 'z', new(0F, 0F, 3.9013672F, 5.3515625F) }, - { '{', new(0F, 0F, 3.149414F, 8.720703F) }, - { '|', new(0F, 0F, 0.67871094F, 10.024414F) }, - { '}', new(0F, 0F, 3.149414F, 8.720703F) }, - { '~', new(0F, 0F, 4.6972656F, 1.2597656F) }, + { '!', new FontRectangle(0F, 0F, 1.1621094F, 7.2753906F) }, + { '"', new FontRectangle(0F, 0F, 2.6660156F, 2.578125F) }, + { '#', new FontRectangle(0F, 0F, 5.9472656F, 7.138672F) }, + { '$', new FontRectangle(0F, 0F, 4.4921875F, 8.168945F) }, + { '%', new FontRectangle(0F, 0F, 7.270508F, 7.338867F) }, + { '&', new FontRectangle(0F, 0F, 6.689453F, 7.348633F) }, + { '\'', new FontRectangle(0F, 0F, 0.87890625F, 2.578125F) }, + { '(', new FontRectangle(0F, 0F, 2.2460938F, 8.720703F) }, + { ')', new FontRectangle(0F, 0F, 2.2460938F, 8.720703F) }, + { '*', new FontRectangle(0F, 0F, 4.614258F, 4.4433594F) }, + { '+', new FontRectangle(0F, 0F, 4.692383F, 4.814453F) }, + { ',', new FontRectangle(0F, 0F, 1.4404297F, 2.4511719F) }, + { '-', new FontRectangle(0F, 0F, 2.421875F, 0.72265625F) }, + { '.', new FontRectangle(0F, 0F, 1.1621094F, 1.2744141F) }, + { '/', new FontRectangle(0F, 0F, 3.4570312F, 7.138672F) }, + { '0', new FontRectangle(0F, 0F, 4.7070312F, 7.348633F) }, + { '1', new FontRectangle(0F, 0F, 2.6074219F, 7.138672F) }, + { '2', new FontRectangle(0F, 0F, 4.6777344F, 7.241211F) }, + { '3', new FontRectangle(0F, 0F, 4.6777344F, 7.338867F) }, + { '4', new FontRectangle(0F, 0F, 5.3125F, 7.1777344F) }, + { '5', new FontRectangle(0F, 0F, 4.4970703F, 7.236328F) }, + { '6', new FontRectangle(0F, 0F, 4.6679688F, 7.338867F) }, + { '7', new FontRectangle(0F, 0F, 4.760742F, 7.138672F) }, + { '8', new FontRectangle(0F, 0F, 4.6972656F, 7.338867F) }, + { '9', new FontRectangle(0F, 0F, 4.6777344F, 7.34375F) }, + { ':', new FontRectangle(0F, 0F, 1.1621094F, 5.6152344F) }, + { ';', new FontRectangle(0F, 0F, 1.5576172F, 6.767578F) }, + { '<', new FontRectangle(0F, 0F, 4.6972656F, 4.868164F) }, + { '=', new FontRectangle(0F, 0F, 4.580078F, 2.65625F) }, + { '>', new FontRectangle(0F, 0F, 4.6972656F, 4.868164F) }, + { '?', new FontRectangle(0F, 0F, 3.8916016F, 7.3779297F) }, + { '@', new FontRectangle(0F, 0F, 7.817383F, 8.032227F) }, + { 'A', new FontRectangle(0F, 0F, 6.3134766F, 7.1679688F) }, + { 'B', new FontRectangle(0F, 0F, 4.9414062F, 7.138672F) }, + { 'C', new FontRectangle(0F, 0F, 5.3808594F, 7.338867F) }, + { 'D', new FontRectangle(0F, 0F, 5.6689453F, 7.138672F) }, + { 'E', new FontRectangle(0F, 0F, 3.9746094F, 7.138672F) }, + { 'F', new FontRectangle(0F, 0F, 3.9746094F, 7.138672F) }, + { 'G', new FontRectangle(0F, 0F, 5.913086F, 7.338867F) }, + { 'H', new FontRectangle(0F, 0F, 5.4101562F, 7.138672F) }, + { 'I', new FontRectangle(0F, 0F, 0.8300781F, 7.138672F) }, + { 'J', new FontRectangle(0F, 0F, 2.5683594F, 9.018555F) }, + { 'K', new FontRectangle(0F, 0F, 5.1464844F, 7.138672F) }, + { 'L', new FontRectangle(0F, 0F, 3.9990234F, 7.138672F) }, + { 'M', new FontRectangle(0F, 0F, 7.0410156F, 7.138672F) }, + { 'N', new FontRectangle(0F, 0F, 5.5810547F, 7.138672F) }, + { 'O', new FontRectangle(0F, 0F, 6.557617F, 7.348633F) }, + { 'P', new FontRectangle(0F, 0F, 4.5214844F, 7.138672F) }, + { 'Q', new FontRectangle(0F, 0F, 6.557617F, 8.950195F) }, + { 'R', new FontRectangle(0F, 0F, 5.029297F, 7.138672F) }, + { 'S', new FontRectangle(0F, 0F, 4.4921875F, 7.338867F) }, + { 'T', new FontRectangle(0F, 0F, 5.317383F, 7.138672F) }, + { 'U', new FontRectangle(0F, 0F, 5.473633F, 7.236328F) }, + { 'V', new FontRectangle(0F, 0F, 5.961914F, 7.138672F) }, + { 'W', new FontRectangle(0F, 0F, 8.94043F, 7.138672F) }, + { 'X', new FontRectangle(0F, 0F, 5.7128906F, 7.138672F) }, + { 'Y', new FontRectangle(0F, 0F, 5.5908203F, 7.138672F) }, + { 'Z', new FontRectangle(0F, 0F, 4.9560547F, 7.138672F) }, + { '[', new FontRectangle(0F, 0F, 2.211914F, 8.720703F) }, + { '\\', new FontRectangle(0F, 0F, 3.4667969F, 7.138672F) }, + { ']', new FontRectangle(0F, 0F, 2.2167969F, 8.720703F) }, + { '^', new FontRectangle(0F, 0F, 4.9414062F, 4.5117188F) }, + { '_', new FontRectangle(0F, 0F, 4.4189453F, 0.60058594F) }, + { '`', new FontRectangle(0F, 0F, 1.9775391F, 1.6015625F) }, + { 'a', new FontRectangle(0F, 0F, 4.2822266F, 5.5371094F) }, + { 'b', new FontRectangle(0F, 0F, 4.7070312F, 7.6953125F) }, + { 'c', new FontRectangle(0F, 0F, 3.90625F, 5.546875F) }, + { 'd', new FontRectangle(0F, 0F, 4.7021484F, 7.6953125F) }, + { 'e', new FontRectangle(0F, 0F, 4.536133F, 5.546875F) }, + { 'f', new FontRectangle(0F, 0F, 3.671875F, 7.651367F) }, + { 'g', new FontRectangle(0F, 0F, 5.078125F, 7.861328F) }, + { 'h', new FontRectangle(0F, 0F, 4.4628906F, 7.5976562F) }, + { 'i', new FontRectangle(0F, 0F, 0.9765625F, 7.3535156F) }, + { 'j', new FontRectangle(0F, 0F, 2.3046875F, 9.755859F) }, + { 'k', new FontRectangle(0F, 0F, 4.321289F, 7.5976562F) }, + { 'l', new FontRectangle(0F, 0F, 0.8154297F, 7.5976562F) }, + { 'm', new FontRectangle(0F, 0F, 7.5927734F, 5.4492188F) }, + { 'n', new FontRectangle(0F, 0F, 4.4628906F, 5.4492188F) }, + { 'o', new FontRectangle(0F, 0F, 4.9121094F, 5.546875F) }, + { 'p', new FontRectangle(0F, 0F, 4.7070312F, 7.841797F) }, + { 'q', new FontRectangle(0F, 0F, 4.7021484F, 7.841797F) }, + { 'r', new FontRectangle(0F, 0F, 3.0810547F, 5.4492188F) }, + { 's', new FontRectangle(0F, 0F, 3.8134766F, 5.546875F) }, + { 't', new FontRectangle(0F, 0F, 3.178711F, 6.689453F) }, + { 'u', new FontRectangle(0F, 0F, 4.477539F, 5.4492188F) }, + { 'v', new FontRectangle(0F, 0F, 4.995117F, 5.3515625F) }, + { 'w', new FontRectangle(0F, 0F, 7.5146484F, 5.3515625F) }, + { 'x', new FontRectangle(0F, 0F, 4.8535156F, 5.3515625F) }, + { 'y', new FontRectangle(0F, 0F, 5F, 7.758789F) }, + { 'z', new FontRectangle(0F, 0F, 3.9013672F, 5.3515625F) }, + { '{', new FontRectangle(0F, 0F, 3.149414F, 8.720703F) }, + { '|', new FontRectangle(0F, 0F, 0.67871094F, 10.024414F) }, + { '}', new FontRectangle(0F, 0F, 3.149414F, 8.720703F) }, + { '~', new FontRectangle(0F, 0F, 4.6972656F, 1.2597656F) }, }; [Theory] @@ -961,7 +961,7 @@ public void TrueTypeHinting_CanHintSmallOpenSans(char c, FontRectangle expected) FontRectangle actual = TextMeasurer.MeasureSize(c.ToString(), options); Assert.Equal(expected, actual, Comparer); - options = new(OpenSansWoff) + options = new TextOptions(OpenSansWoff) { KerningMode = KerningMode.Standard, HintingMode = HintingMode.Standard @@ -1233,23 +1233,37 @@ public static List GenerateGlyphsBoxes(string text, TextOptions o renderer.RenderText(text, options); return glyphBuilder.GlyphBounds; } + public readonly List GlyphBounds = new(); + public CaptureGlyphBoundBuilder() { } + bool IGlyphRenderer.BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters) { this.GlyphBounds.Add(bounds); return true; } + public void BeginFigure() { } + public void MoveTo(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() { } + void IGlyphRenderer.BeginText(in FontRectangle bounds) { } + public TextDecorations EnabledDecorations() => TextDecorations.None; + public void SetDecoration(TextDecorations textDecorations, Vector2 start, Vector2 end, float thickness) { } } @@ -1411,14 +1425,14 @@ public static Font CreateRenderingFont(float pointSize = 12) 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); } public static Font CreateFont(string text, float pointSize) { - 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, pointSize); } diff --git a/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs b/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs index 8efe34a8f..f6cd99f3b 100644 --- a/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs +++ b/tests/SixLabors.Fonts.Tests/TextOptionsTests.cs @@ -23,7 +23,7 @@ public TextOptionsTests() public void ConstructorTest_FontOnly() { Font font = FakeFont.CreateFont("ABC"); - var options = new TextOptions(font); + TextOptions options = new(font); Assert.Equal(72, options.Dpi); Assert.Empty(options.FallbackFontFamilies); @@ -37,7 +37,7 @@ public void ConstructorTest_FontWithSingleDpi() { Font font = FakeFont.CreateFont("ABC"); const float dpi = 123; - var options = new TextOptions(font) { Dpi = dpi }; + TextOptions options = new(font) { Dpi = dpi }; Assert.Equal(dpi, options.Dpi); Assert.Empty(options.FallbackFontFamilies); @@ -50,7 +50,7 @@ public void ConstructorTest_FontWithSingleDpi() public void ConstructorTest_FontWithOrigin() { Font font = FakeFont.CreateFont("ABC"); - var origin = new Vector2(123, 345); + Vector2 origin = new(123, 345); TextOptions options = new(font) { Origin = origin }; Assert.Equal(72, options.Dpi); @@ -64,7 +64,7 @@ public void ConstructorTest_FontWithOrigin() public void ConstructorTest_FontWithSingleDpiWithOrigin() { Font font = FakeFont.CreateFont("ABC"); - var origin = new Vector2(123, 345); + Vector2 origin = new(123, 345); const float dpi = 123; TextOptions options = new(font) { Dpi = dpi, Origin = origin }; @@ -85,7 +85,7 @@ public void ConstructorTest_FontOnly_WithFallbackFonts() FakeFont.CreateFont("GHI").Family }; - var options = new TextOptions(font) + TextOptions options = new(font) { FallbackFontFamilies = fontFamilies }; @@ -108,7 +108,7 @@ public void ConstructorTest_FontWithSingleDpi_WithFallbackFonts() }; const float dpi = 123; - var options = new TextOptions(font) + TextOptions options = new(font) { Dpi = dpi, FallbackFontFamilies = fontFamilies @@ -131,7 +131,7 @@ public void ConstructorTest_FontWithOrigin_WithFallbackFonts() FakeFont.CreateFont("GHI").Family }; - var origin = new Vector2(123, 345); + Vector2 origin = new(123, 345); TextOptions options = new(font) { FallbackFontFamilies = fontFamilies, @@ -155,7 +155,7 @@ public void ConstructorTest_FontWithSingleDpiWithOrigin_WithFallbackFonts() FakeFont.CreateFont("GHI").Family }; - var origin = new Vector2(123, 345); + Vector2 origin = new(123, 345); const float dpi = 123; TextOptions options = new(font) { @@ -181,14 +181,14 @@ public void GetMissingGlyphFromMainFont() FakeFont.CreateFontWithInstance("GHI", "GHI", out Fakes.FakeFontInstance ghiFontInstance).Family }; - var options = new TextOptions(font) + TextOptions options = new(font) { FallbackFontFamilies = fontFamilies, ColorFontSupport = ColorFontSupport.None }; ReadOnlySpan text = "Z".AsSpan(); - var renderer = new GlyphRenderer(); + GlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, text, options); GlyphRendererParameters glyph = Assert.Single(renderer.GlyphKeys); @@ -209,14 +209,14 @@ public void GetGlyphFromFirstAvailableInstance(char character, string instance) FakeFont.CreateFontWithInstance("EFGHI", "EFGHI", out Fakes.FakeFontInstance efghiFontInstance).Family }; - var options = new TextOptions(font) + TextOptions options = new(font) { FallbackFontFamilies = fontFamilies, ColorFontSupport = ColorFontSupport.None }; ReadOnlySpan text = new[] { character }; - var renderer = new GlyphRenderer(); + GlyphRenderer renderer = new(); TextRenderer.RenderTextTo(renderer, text, options); GlyphRendererParameters glyph = Assert.Single(renderer.GlyphKeys); Assert.Equal(GlyphType.Standard, glyph.GlyphType); @@ -328,7 +328,7 @@ public void NonDefaultClone() [Fact] public void CloneIsDeep() { - var expected = new TextOptions(this.fakeFont); + TextOptions expected = new(this.fakeFont); TextOptions actual = new(expected) { KerningMode = KerningMode.None, 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 9ecdecf27..92f6d89e1 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/BidiAlgorithmTests.cs @@ -41,7 +41,7 @@ public void RendersFarsiTextCorrect() { // arrange Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(8); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); const string testStr = "زناب فارسی را تک کمی سخت است"; int[] expectedGlyphIndices = { @@ -90,7 +90,7 @@ public void RendersArabicNumbersFromLeftToRight() { // arrange Font arabicFont = new FontCollection().Add(TestFonts.ArabicFontFile).CreateFont(12); - var renderer = new ColorGlyphRenderer(); + ColorGlyphRenderer renderer = new(); string testStr = "٠١٢٣٤٥٦٧٨٩"; int[] expectedGlyphIndices = { 403, 405, 407, 409, 411, 413, 415, 417, 419, 421 }; @@ -156,9 +156,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 = new(); // Process each line int[] levels = null; diff --git a/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/BidiCharacterTests.cs index d0a348489..70e112398 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 @@ -56,14 +56,14 @@ private bool ICUTestsImpl() // 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(); - 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.TestData.cs b/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.TestData.cs index a5f07ece3..84f2fac97 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.TestData.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/CodePointTests.TestData.cs @@ -170,12 +170,12 @@ public static IEnumerable GeneralTestData_SupplementaryCodePoints_Vali public static IEnumerable IsValidTestData() { - foreach (var obj in GeneralTestData_BmpCodePoints_NoSurrogates().Concat(GeneralTestData_SupplementaryCodePoints_ValidOnly())) + foreach (object[] obj in GeneralTestData_BmpCodePoints_NoSurrogates().Concat(GeneralTestData_SupplementaryCodePoints_ValidOnly())) { yield return new object[] { ((GeneralTestData)obj[0]).ScalarValue /* value */, true /* isValid */ }; } - foreach (var obj in BmpCodePoints_SurrogatesOnly().Concat(SupplementaryCodePoints_InvalidOnly())) + foreach (object[] obj in BmpCodePoints_SurrogatesOnly().Concat(SupplementaryCodePoints_InvalidOnly())) { yield return new object[] { Convert.ToInt32(obj[0], CultureInfo.InvariantCulture) /* value */, false /* isValid */ }; } 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..caf95a6d1 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/DfaTests.cs @@ -13,11 +13,11 @@ public void CanCompileWithSingleLiteral() StateMachine stateMachine = Compile.Build("a = 0; b = 1; Main = a;"); StateMatch[] matches = stateMachine.Match(new[] { 0, 0, 1, 0 }).ToArray(); - 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)); @@ -29,10 +29,10 @@ 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(); - 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)); @@ -44,11 +44,11 @@ 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(); - 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)); @@ -60,10 +60,10 @@ 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(); - 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)); @@ -75,10 +75,10 @@ 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(); - 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)); @@ -90,9 +90,9 @@ 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(); - var expected = new StateMatch[] + StateMatch[] expected = new StateMatch[] { - new StateMatch() { StartIndex = 3, EndIndex = 6 } + new() { StartIndex = 3, EndIndex = 6 } }; Assert.True(expected.SequenceEqual(matches)); @@ -104,10 +104,10 @@ 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(); - 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)); @@ -119,12 +119,12 @@ 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(); - 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)); @@ -136,10 +136,10 @@ 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(); - 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)); @@ -153,12 +153,12 @@ public void CanCompileWithTags() 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(); - 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)); @@ -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(); - 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..a4a20299f 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; @@ -164,7 +164,7 @@ public bool ICUTestsImpl() tests.Add(new Test(lineNumber, codePoints.ToArray(), breakPoints.ToArray())); } - 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..d4bf91edb 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); @@ -87,7 +87,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 +108,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 +137,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 +149,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; @@ -188,11 +188,11 @@ public bool ICUTestsImpl() } // Create test - var test = new Test(lineNumber, codePoints.ToArray(), breakPoints.ToArray()); + Test test = new(lineNumber, codePoints.ToArray(), breakPoints.ToArray()); tests.Add(test); } - var foundBreaks = new List(); + List foundBreaks = new(); for (int testNumber = 0; testNumber < tests.Count; testNumber++) { @@ -203,7 +203,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); diff --git a/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs b/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs index aca9c65d2..4a0eee1bd 100644 --- a/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs +++ b/tests/SixLabors.Fonts.Tests/Unicode/UnicodeTrieBuilderTests.cs @@ -13,138 +13,138 @@ public class UnicodeTrieBuilderTests { private static readonly TestRange[] TestRanges1 = new TestRange[] { - new TestRange(0, 0, 0, false), - new TestRange(0, 0x40, 0, false), - new TestRange(0x40, 0xe7, 0x1234, false), - new TestRange(0xe7, 0x3400, 0, false), - new TestRange(0x3400, 0x9fa6, 0x6162, false), - new TestRange(0x9fa6, 0xda9e, 0x3132, false), - new TestRange(0xdada, 0xeeee, 0x87ff, false), - new TestRange(0xeeee, 0x11111, 1, false), - new TestRange(0x11111, 0x44444, 0x6162, false), - new TestRange(0x44444, 0x60003, 0, false), - new TestRange(0xf0003, 0xf0004, 0xf, false), - new TestRange(0xf0004, 0xf0006, 0x10, false), - new TestRange(0xf0006, 0xf0007, 0x11, false), - new TestRange(0xf0007, 0xf0040, 0x12, false), - new TestRange(0xf0040, 0x110000, 0, false) + new(0, 0, 0, false), + new(0, 0x40, 0, false), + new(0x40, 0xe7, 0x1234, false), + new(0xe7, 0x3400, 0, false), + new(0x3400, 0x9fa6, 0x6162, false), + new(0x9fa6, 0xda9e, 0x3132, false), + new(0xdada, 0xeeee, 0x87ff, false), + new(0xeeee, 0x11111, 1, false), + new(0x11111, 0x44444, 0x6162, false), + new(0x44444, 0x60003, 0, false), + new(0xf0003, 0xf0004, 0xf, false), + new(0xf0004, 0xf0006, 0x10, false), + new(0xf0006, 0xf0007, 0x11, false), + new(0xf0007, 0xf0040, 0x12, false), + new(0xf0040, 0x110000, 0, false) }; private static readonly CheckValue[] CheckValues1 = new CheckValue[] { - new CheckValue(0, 0), - new CheckValue(0x40, 0), - new CheckValue(0xe7, 0x1234), - new CheckValue(0x3400, 0), - new CheckValue(0x9fa6, 0x6162), - new CheckValue(0xda9e, 0x3132), - new CheckValue(0xdada, 0), - new CheckValue(0xeeee, 0x87ff), - new CheckValue(0x11111, 1), - new CheckValue(0x44444, 0x6162), - new CheckValue(0xf0003, 0), - new CheckValue(0xf0004, 0xf), - new CheckValue(0xf0006, 0x10), - new CheckValue(0xf0007, 0x11), - new CheckValue(0xf0040, 0x12), - new CheckValue(0x110000, 0), + new(0, 0), + new(0x40, 0), + new(0xe7, 0x1234), + new(0x3400, 0), + new(0x9fa6, 0x6162), + new(0xda9e, 0x3132), + new(0xdada, 0), + new(0xeeee, 0x87ff), + new(0x11111, 1), + new(0x44444, 0x6162), + new(0xf0003, 0), + new(0xf0004, 0xf), + new(0xf0006, 0x10), + new(0xf0007, 0x11), + new(0xf0040, 0x12), + new(0x110000, 0), }; private static readonly TestRange[] TestRanges2 = new TestRange[] { - new TestRange(0, 0, 0, false), - new TestRange(0x21, 0x7f, 0x5555, true), - new TestRange(0x2f800, 0x2fedc, 0x7a, true), - new TestRange(0x72, 0xdd, 3, true), - new TestRange(0xdd, 0xde, 4, false), - new TestRange(0x201, 0x240, 6, true), // 3 consecutive blocks with the same pattern but - new TestRange(0x241, 0x280, 6, true), // discontiguous value ranges, testing utrie2_enum() - new TestRange(0x281, 0x2c0, 6, true), - new TestRange(0x2f987, 0x2fa98, 5, true), - new TestRange(0x2f777, 0x2f883, 0, true), - new TestRange(0x2f900, 0x2ffaa, 1, false), - new TestRange(0x2ffaa, 0x2ffab, 2, true), - new TestRange(0x2ffbb, 0x2ffc0, 7, true), + new(0, 0, 0, false), + new(0x21, 0x7f, 0x5555, true), + new(0x2f800, 0x2fedc, 0x7a, true), + new(0x72, 0xdd, 3, true), + new(0xdd, 0xde, 4, false), + new(0x201, 0x240, 6, true), // 3 consecutive blocks with the same pattern but + new(0x241, 0x280, 6, true), // discontiguous value ranges, testing utrie2_enum() + new(0x281, 0x2c0, 6, true), + new(0x2f987, 0x2fa98, 5, true), + new(0x2f777, 0x2f883, 0, true), + new(0x2f900, 0x2ffaa, 1, false), + new(0x2ffaa, 0x2ffab, 2, true), + new(0x2ffbb, 0x2ffc0, 7, true), }; private static readonly CheckValue[] CheckValues2 = new CheckValue[] { - new CheckValue(0, 0), - new CheckValue(0x21, 0), - new CheckValue(0x72, 0x5555), - new CheckValue(0xdd, 3), - new CheckValue(0xde, 4), - new CheckValue(0x201, 0), - new CheckValue(0x240, 6), - new CheckValue(0x241, 0), - new CheckValue(0x280, 6), - new CheckValue(0x281, 0), - new CheckValue(0x2c0, 6), - new CheckValue(0x2f883, 0), - new CheckValue(0x2f987, 0x7a), - new CheckValue(0x2fa98, 5), - new CheckValue(0x2fedc, 0x7a), - new CheckValue(0x2ffaa, 1), - new CheckValue(0x2ffab, 2), - new CheckValue(0x2ffbb, 0), - new CheckValue(0x2ffc0, 7), - new CheckValue(0x110000, 0), + new(0, 0), + new(0x21, 0), + new(0x72, 0x5555), + new(0xdd, 3), + new(0xde, 4), + new(0x201, 0), + new(0x240, 6), + new(0x241, 0), + new(0x280, 6), + new(0x281, 0), + new(0x2c0, 6), + new(0x2f883, 0), + new(0x2f987, 0x7a), + new(0x2fa98, 5), + new(0x2fedc, 0x7a), + new(0x2ffaa, 1), + new(0x2ffab, 2), + new(0x2ffbb, 0), + new(0x2ffc0, 7), + new(0x110000, 0), }; private static readonly TestRange[] TestRanges3 = new TestRange[] { - new TestRange(0, 0, 9, false), // non-zero initial value. - new TestRange(0x31, 0xa4, 1, false), - new TestRange(0x3400, 0x6789, 2, false), - new TestRange(0x8000, 0x89ab, 9, true), - new TestRange(0x9000, 0xa000, 4, true), - new TestRange(0xabcd, 0xbcde, 3, true), - new TestRange(0x55555, 0x110000, 6, true), // highStart(); + List offsets = new(); 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.ToList(); // Type | Name | Description // ----------|------------------------|---------------------------------------------------------------------------------------------------- @@ -609,7 +609,7 @@ public class ColrGlyphRecord { public ushort Glyph { get; set; } - public List Layers { get; set; } = new List(); + public List Layers { get; set; } = new(); public int HeaderSize => 6;