Skip to content

Commit

Permalink
Merge pull request #234 from SixLabors/js/targetframeworks
Browse files Browse the repository at this point in the history
Drop NetStandard 1.3
  • Loading branch information
JimBobSquarePants authored Feb 9, 2022
2 parents b52ed6e + 353a821 commit 28266e9
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 52 deletions.
34 changes: 9 additions & 25 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,20 @@

<!--
https://apisof.net/
+===================+=======+==========+=====================+
| SUPPORTS | CULTUREINFO_LCID | NULLABLE_ATTRIBUTES |
+===================+==================+=====================+
| netcoreapp3.1 | Y | Y |
| netcoreapp2.1 | Y | N |
| netcoreapp2.0 | Y | N |
| netstandard2.1 | Y | Y |
| netstandard2.0 | Y | N |
| netstandard1.3 | N | N |
| net472 | Y | N |
+===================+==================+=====================+
+===================+=====================+
| SUPPORTS | NULLABLE_ATTRIBUTES |
+===================+=====================+
| netcoreapp3.1 | Y |
| netstandard2.1 | Y |
| netstandard2.0 | N |
+===================+=====================+
-->

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_CULTUREINFO_LCID;NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>$(DefineConstants)SUPPORTS_CULTUREINFO_LCID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<DefineConstants>$(DefineConstants)SUPPORTS_CULTUREINFO_LCID</DefineConstants>
<DefineConstants>$(DefineConstants);NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_CULTUREINFO_LCID;NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);SUPPORTS_CULTUREINFO_LCID</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
<DefineConstants>$(DefineConstants);SUPPORTS_CULTUREINFO_LCID</DefineConstants>
<DefineConstants>$(DefineConstants);NULLABLE_ATTRIBUTES</DefineConstants>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/Buffer{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Span<T> GetSpan()
ref byte r0 = ref MemoryMarshal.GetReference<byte>(this.buffer);
return MemoryMarshal.CreateSpan(ref Unsafe.As<byte, T>(ref r0), this.length);
#else
return MemoryMarshal.Cast<byte, T>(this.buffer.AsSpan()).Slice(0, this.length);
return MemoryMarshal.Cast<byte, T>(this.buffer).Slice(0, this.length);
#endif
}

Expand Down
2 changes: 0 additions & 2 deletions src/SixLabors.Fonts/FontCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public FontFamily Get(string name)
public bool TryGet(string name, out FontFamily family)
=> this.TryGetImpl(name, CultureInfo.InvariantCulture, out family);

#if SUPPORTS_CULTUREINFO_LCID
/// <inheritdoc/>
public FontFamily Add(string path, CultureInfo culture)
=> this.AddImpl(path, culture, out _);
Expand Down Expand Up @@ -111,7 +110,6 @@ public FontFamily Get(string name, CultureInfo culture)
/// <inheritdoc/>
public bool TryGet(string name, CultureInfo culture, out FontFamily family)
=> this.TryGetImpl(name, culture, out family);
#endif

/// <inheritdoc/>
FontFamily IFontMetricsCollection.AddMetrics(FontMetrics metrics, CultureInfo culture)
Expand Down
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/FontReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal FontReader(Stream stream, TableLoader loader)
// This is a woff2 file.
this.TableFormat = TableFormat.Woff2;

#if NETSTANDARD2_0 || NETSTANDARD1_3
#if NETSTANDARD2_0
throw new NotSupportedException("Brotli compression is not available and is required for decoding woff2");
#else

Expand Down
4 changes: 0 additions & 4 deletions src/SixLabors.Fonts/IFontCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0.

using System.Collections.Generic;
#if SUPPORTS_CULTUREINFO_LCID
using System.Globalization;
#endif
using System.IO;

namespace SixLabors.Fonts
Expand Down Expand Up @@ -75,7 +73,6 @@ public interface IFontCollection : IReadOnlyFontCollection
/// <returns>The new <see cref="IEnumerable{T}"/>.</returns>
public IEnumerable<FontFamily> AddCollection(Stream stream, out IEnumerable<FontDescription> descriptions);

#if SUPPORTS_CULTUREINFO_LCID
/// <summary>
/// Adds a font to the collection.
/// </summary>
Expand Down Expand Up @@ -149,6 +146,5 @@ public IEnumerable<FontFamily> AddCollection(
Stream stream,
CultureInfo culture,
out IEnumerable<FontDescription> descriptions);
#endif
}
}
4 changes: 0 additions & 4 deletions src/SixLabors.Fonts/IReadonlyFontCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

using System;
using System.Collections.Generic;
#if SUPPORTS_CULTUREINFO_LCID
using System.Globalization;
#endif

namespace SixLabors.Fonts
{
Expand Down Expand Up @@ -45,7 +43,6 @@ public interface IReadOnlyFontCollection
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/></exception>
bool TryGet(string name, out FontFamily family);

#if SUPPORTS_CULTUREINFO_LCID
/// <summary>
/// Gets the collection of <see cref="FontFamily"/> in this <see cref="FontCollection"/>
/// using the given culture.
Expand Down Expand Up @@ -80,6 +77,5 @@ public interface IReadOnlyFontCollection
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="name"/> is <see langword="null"/></exception>
bool TryGet(string name, CultureInfo culture, out FontFamily family);
#endif
}
}
6 changes: 3 additions & 3 deletions src/SixLabors.Fonts/SixLabors.Fonts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl Condition="'$(RepositoryUrl)' == ''">https://github.com/SixLabors/Fonts/</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<PackageTags>font;truetype;opentype;woff</PackageTags>
<PackageTags>font;truetype;opentype;woff;woff2</PackageTags>
<Description>A cross-platform library for loading and laying out fonts for processing and measuring; written in C#</Description>
<TargetFrameworks>netcoreapp3.1;netstandard2.1;netstandard2.0;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netstandard2.1;netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<!--Prevent version conflicts in DrawWithImageSharp-->
Expand Down Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard1.3' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/SixLabors.Fonts/StringComparerHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ internal static class StringComparerHelpers
{
public static StringComparer GetCaseInsensitiveStringComparer(CultureInfo culture)
{
#if SUPPORTS_CULTUREINFO_LCID
if (culture != null)
{
return StringComparer.Create(culture, true);
}
#endif

return StringComparer.OrdinalIgnoreCase;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/SixLabors.Fonts/SystemFontCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public SystemFontCollection(IEnumerable<string> paths)
public bool TryGet(string name, out FontFamily family)
=> this.collection.TryGet(name, out family);

#if SUPPORTS_CULTUREINFO_LCID
/// <inheritdoc/>
public IEnumerable<FontFamily> GetByCulture(CultureInfo culture)
=> this.collection.GetByCulture(culture);
Expand All @@ -99,7 +98,6 @@ public FontFamily Get(string name, CultureInfo culture)
/// <inheritdoc/>
public bool TryGet(string name, CultureInfo culture, out FontFamily family)
=> this.collection.TryGet(name, culture, out family);
#endif

/// <inheritdoc/>
bool IReadOnlyFontMetricsCollection.TryGetMetrics(string name, CultureInfo culture, FontStyle style, [NotNullWhen(true)] out FontMetrics? metrics)
Expand Down
4 changes: 0 additions & 4 deletions src/SixLabors.Fonts/SystemFonts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

using System;
using System.Collections.Generic;
#if SUPPORTS_CULTUREINFO_LCID
using System.Globalization;
#endif

namespace SixLabors.Fonts
{
Expand Down Expand Up @@ -52,7 +50,6 @@ public static Font CreateFont(string name, float size)
public static Font CreateFont(string name, float size, FontStyle style)
=> Collection.Get(name).CreateFont(size, style);

#if SUPPORTS_CULTUREINFO_LCID
/// <inheritdoc cref="IReadOnlyFontCollection.GetByCulture(CultureInfo)"/>
public static IEnumerable<FontFamily> GetByCulture(CultureInfo culture)
=> Collection.GetByCulture(culture);
Expand Down Expand Up @@ -85,6 +82,5 @@ public static Font CreateFont(string name, CultureInfo culture, float size)
/// <returns>The new <see cref="Font"/>.</returns>
public static Font CreateFont(string name, CultureInfo culture, float size, FontStyle style)
=> Collection.Get(name, culture).CreateFont(size, style);
#endif
}
}
4 changes: 0 additions & 4 deletions src/SixLabors.Fonts/Tables/General/NameTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ public string FontSubFamilyName(CultureInfo culture)

public string GetNameById(CultureInfo culture, KnownNameIds nameId)
{
#if SUPPORTS_CULTUREINFO_LCID
int languageId = culture.LCID;
#else
int languageId = 0x0409;
#endif
NameRecord? usaVersion = null;
NameRecord? firstWindows = null;
NameRecord? first = null;
Expand Down

0 comments on commit 28266e9

Please sign in to comment.