Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/ArrayBuilder{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SixLabors.Fonts/BidiReordering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static void Reorder(List<GlyphLayoutData> glyphs, LayoutMode layoutMode)
/// <param name="bidiRuns">The resolved bidirectional runs covering the source text.</param>
/// <param name="bidiMap">The source codepoint to bidirectional-run mapping.</param>
public static void Reorder(ShapingBuffer glyphs, BidiRun[] bidiRuns, int[] bidiMap)
=> Reorder<ShapingGlyphState, ShapingGlyphOperations>(new(glyphs, bidiRuns, bidiMap), 0, glyphs.Count);
=> Reorder<ShapingGlyphState, ShapingGlyphOperations>(new ShapingGlyphState(glyphs, bidiRuns, bidiMap), 0, glyphs.Count);

/// <summary>
/// Reorders a half-open range of positioned shaping records for one line.
Expand All @@ -190,7 +190,7 @@ public static void Reorder(ShapingBuffer glyphs, BidiRun[] bidiRuns, int[] bidiM
/// <param name="start">The first glyph record in the line.</param>
/// <param name="end">The glyph record immediately after the line.</param>
public static void Reorder(ShapingBuffer glyphs, BidiRun[] bidiRuns, int[] bidiMap, int start, int end)
=> Reorder<ShapingGlyphState, ShapingGlyphOperations>(new(glyphs, bidiRuns, bidiMap), start, end);
=> Reorder<ShapingGlyphState, ShapingGlyphOperations>(new ShapingGlyphState(glyphs, bidiRuns, bidiMap), start, end);

/// <summary>
/// Applies rule L2 of the Unicode Bidirectional Algorithm to one line.
Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public bool TryGetGlyph(
TextRun textRun = new() { Start = 0, End = 1, Font = this, TextAttributes = textAttributes, TextDecorations = textDecorations };
FontGlyphMetrics metrics = fontMetrics.GetGlyphMetrics(codePoint, glyphId, textAttributes, textDecorations, layoutMode, support, palette);

glyph = new(metrics, this.Size, textRun, Vector2.Zero, new Vector2(metrics.AdvanceWidth, metrics.AdvanceHeight));
glyph = new Glyph(metrics, this.Size, textRun, Vector2.Zero, new Vector2(metrics.AdvanceWidth, metrics.AdvanceHeight));
return true;
}

Expand Down
12 changes: 6 additions & 6 deletions src/SixLabors.Fonts/FontDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,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);
}

Expand All @@ -124,7 +124,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);
}
Expand Down Expand Up @@ -170,14 +170,14 @@ public static ReadOnlyMemory<FontDescription> LoadFontCollectionDescriptions(str
public static ReadOnlyMemory<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);
}

Expand Down
10 changes: 5 additions & 5 deletions src/SixLabors.Fonts/FontGlyphMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ internal FontGlyphMetrics(
{
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;
Expand Down Expand Up @@ -719,19 +719,19 @@ private TextDecorationGeometry ComputeDecorationGeometry(
{
// To ensure that we share the scaling when sharing font metrics we need to
// recalculate the offset and scale factor here using the common font metrics.
scaleFactor = new(fontMetrics.UnitsPerEm * PointsPerInch);
scaleFactor = new Vector2(fontMetrics.UnitsPerEm * PointsPerInch);
offset = Vector2.Zero;
if ((this.TextAttributes & TextAttributes.Subscript) == TextAttributes.Subscript)
{
float units = this.UnitsPerEm;
scaleFactor /= new Vector2(fontMetrics.SubscriptXSize / units, fontMetrics.SubscriptYSize / units);
offset = new(fontMetrics.SubscriptXOffset, fontMetrics.SubscriptYOffset < 0 ? fontMetrics.SubscriptYOffset : -fontMetrics.SubscriptYOffset);
offset = new Vector2(fontMetrics.SubscriptXOffset, fontMetrics.SubscriptYOffset < 0 ? fontMetrics.SubscriptYOffset : -fontMetrics.SubscriptYOffset);
}
else if ((this.TextAttributes & TextAttributes.Superscript) == TextAttributes.Superscript)
{
float units = this.UnitsPerEm;
scaleFactor /= new Vector2(fontMetrics.SuperscriptXSize / units, fontMetrics.SuperscriptYSize / units);
offset = new(fontMetrics.SuperscriptXOffset, fontMetrics.SuperscriptYOffset < 0 ? -fontMetrics.SuperscriptYOffset : fontMetrics.SuperscriptYOffset);
offset = new Vector2(fontMetrics.SuperscriptXOffset, fontMetrics.SuperscriptYOffset < 0 ? -fontMetrics.SuperscriptYOffset : fontMetrics.SuperscriptYOffset);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/SixLabors.Fonts/FontReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal FontReader(Stream stream, TableLoader loader)
Func<BigEndianBinaryReader, TableHeader> 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();
Expand Down Expand Up @@ -91,9 +91,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;
Expand All @@ -112,7 +112,7 @@ internal FontReader(Stream stream, TableLoader loader)
this.CompressedTableData = false;
}

var headers = new Dictionary<string, TableHeader>(tableCount);
Dictionary<string, TableHeader> headers = new(tableCount);
for (int i = 0; i < tableCount; i++)
{
TableHeader tbl = loadHeader(reader);
Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/LineLayoutEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed class LineLayoutEnumerator
internal LineLayoutEnumerator(TextBlock textBlock)
{
this.textBlock = textBlock;
this.lineEnumerator = new(textBlock.LogicalLine, textBlock.Options);
this.lineEnumerator = new TextLineBreakEnumerator(textBlock.LogicalLine, textBlock.Options);
this.textDirection = TextLayout.GetTextDirection(textBlock.LogicalLine, textBlock.Options);
this.suppressLayout = textBlock.Options.MaxLines == 0;
}
Expand Down
28 changes: 14 additions & 14 deletions src/SixLabors.Fonts/Native/CoreFoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal enum CFNumberType : long
/// <param name="theArray">The array to examine.</param>
/// <returns>The number of values in <paramref name="theArray"/>.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial long CFArrayGetCount(IntPtr theArray);

/// <summary>
Expand All @@ -44,7 +44,7 @@ internal enum CFNumberType : long
/// <param name="idx">The index of the value to retrieve. If the index is outside the index space of <paramref name="theArray"/> (<c>0</c> to <c>N-1</c> inclusive where <c>N</c> is the count of <paramref name="theArray"/>), the behavior is undefined.</param>
/// <returns>The value at the <paramref name="idx"/> index in <paramref name="theArray"/>. If the return value is a Core Foundation Object, ownership follows The Get Rule.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial IntPtr CFArrayGetValueAtIndex(IntPtr theArray, long idx);

/// <summary>
Expand All @@ -58,15 +58,15 @@ internal enum CFNumberType : long
/// These values might change from release to release or platform to platform.
/// </remarks>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial ulong CFGetTypeID(IntPtr cf);

/// <summary>
/// Returns the type identifier for the CFDictionary opaque type.
/// </summary>
/// <returns>The type identifier for the CFDictionary opaque type.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial ulong CFDictionaryGetTypeID();

/// <summary>
Expand All @@ -77,7 +77,7 @@ internal enum CFNumberType : long
/// <param name="value">The matching value.</param>
/// <returns><see langword="true"/> when the key exists; otherwise, <see langword="false"/>.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
public static partial bool CFDictionaryGetValueIfPresent(IntPtr theDict, IntPtr key, out IntPtr value);

Expand All @@ -86,7 +86,7 @@ internal enum CFNumberType : long
/// </summary>
/// <returns>The type identifier for the CFNumber opaque type.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial ulong CFNumberGetTypeID();

/// <summary>
Expand All @@ -97,7 +97,7 @@ internal enum CFNumberType : long
/// <param name="value">The converted value.</param>
/// <returns><see langword="true"/> when conversion succeeds; otherwise, <see langword="false"/>.</returns>
[LibraryImport(CoreFoundationFramework, EntryPoint = "CFNumberGetValue")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
public static partial bool CFNumberGetDoubleValue(IntPtr number, CFNumberType theType, out double value);

Expand All @@ -109,7 +109,7 @@ internal enum CFNumberType : long
/// <param name="value">The converted value.</param>
/// <returns><see langword="true"/> when conversion succeeds; otherwise, <see langword="false"/>.</returns>
[LibraryImport(CoreFoundationFramework, EntryPoint = "CFNumberGetValue")]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
[return: MarshalAs(UnmanagedType.I1)]
public static partial bool CFNumberGetIntValue(IntPtr number, CFNumberType theType, out int value);

Expand All @@ -119,7 +119,7 @@ internal enum CFNumberType : long
/// <param name="theString">The string to examine.</param>
/// <returns>The number (in terms of UTF-16 code pairs) of characters stored in <paramref name="theString"/>.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial long CFStringGetLength(IntPtr theString);

/// <summary>
Expand All @@ -129,7 +129,7 @@ internal enum CFNumberType : long
/// <param name="range">The range of characters to copy.</param>
/// <param name="buffer">The caller-provided UTF-16 character buffer.</param>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static unsafe partial void CFStringGetCharacters(IntPtr theString, CoreText.CFRange range, char* buffer);

/// <summary>
Expand All @@ -147,7 +147,7 @@ internal enum CFNumberType : long
/// released with <see cref="CFRelease"/>.
/// </remarks>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static unsafe partial IntPtr CFStringCreateWithCharacters(
IntPtr allocator,
char* characters,
Expand All @@ -158,7 +158,7 @@ public static unsafe partial IntPtr CFStringCreateWithCharacters(
/// </summary>
/// <param name="cf">A CFType object to release. This value must not be <c>NULL</c>.</param>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial void CFRelease(IntPtr cf);

/// <summary>
Expand All @@ -169,14 +169,14 @@ public static unsafe partial IntPtr CFStringCreateWithCharacters(
/// <returns>The URL's path in the format specified by <paramref name="pathStyle"/>. Ownership follows the create rule. See The Create Rule.</returns>
/// <remarks>This function returns the URL's path as a file system path for a given path style.</remarks>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial IntPtr CFURLCopyFileSystemPath(IntPtr anURL, CFURLPathStyle pathStyle);

/// <summary>
/// Returns the type identifier for the CFURL opaque type.
/// </summary>
/// <returns>The type identifier for the CFURL opaque type.</returns>
[LibraryImport(CoreFoundationFramework)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
public static partial ulong CFURLGetTypeID();
}
Loading
Loading