Skip to content

Commit 425bdbd

Browse files
Merge pull request #62 from SixLabors/js/beta-10
Beta 10
2 parents 92098af + 5c6f7a8 commit 425bdbd

9 files changed

Lines changed: 124 additions & 10 deletions

File tree

Directory.Build.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<PackageReference Update="StyleCop.Analyzers" PrivateAssets="All" Version="1.1.118" />
2424

2525
<!--Src Dependencies-->
26-
<PackageReference Update="SixLabors.Fonts" Version="1.0.0-beta0012" />
27-
<PackageReference Update="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
26+
<PackageReference Update="SixLabors.Fonts" Version="1.0.0-beta0013" />
27+
<PackageReference Update="SixLabors.ImageSharp" Version="1.0.0-rc0003" />
2828
</ItemGroup>
2929

3030
</Project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using SixLabors.ImageSharp.Drawing.Processing;
5+
using SixLabors.ImageSharp.PixelFormats;
6+
using SixLabors.ImageSharp.Processing;
7+
using Xunit;
8+
9+
namespace SixLabors.ImageSharp.Drawing.Tests.Issues
10+
{
11+
public class Issue_37
12+
{
13+
[Fact]
14+
public void CanRenderLargeFont()
15+
{
16+
if (!TestEnvironment.IsWindows)
17+
{
18+
return;
19+
}
20+
21+
using (var image = new Image<Rgba32>(300, 200))
22+
{
23+
string text = "TEST text foiw|\\";
24+
25+
Fonts.Font font = Fonts.SystemFonts.CreateFont("Arial", 40, Fonts.FontStyle.Regular);
26+
var graphicsOptions = new GraphicsOptions { Antialias = false };
27+
image.Mutate(x =>
28+
{
29+
x.BackgroundColor(Color.White)
30+
.DrawLines(
31+
new ShapeGraphicsOptions { GraphicsOptions = graphicsOptions },
32+
Color.Black,
33+
1,
34+
new PointF(0, 50),
35+
new PointF(150, 50))
36+
.DrawText(
37+
new TextGraphicsOptions { GraphicsOptions = graphicsOptions },
38+
text,
39+
font,
40+
Color.Black,
41+
new PointF(50, 50));
42+
});
43+
}
44+
}
45+
}
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System.Globalization;
5+
using SixLabors.Fonts;
6+
using SixLabors.ImageSharp.Drawing.Processing;
7+
using SixLabors.ImageSharp.PixelFormats;
8+
using SixLabors.ImageSharp.Processing;
9+
using Xunit;
10+
11+
namespace SixLabors.ImageSharp.Drawing.Tests.Issues
12+
{
13+
public class Issue_46
14+
{
15+
[Fact]
16+
public void CanRenderCustomFont()
17+
{
18+
Font font = CreateFont("icomoon-events.ttf", 175);
19+
20+
var options = new RendererOptions(font)
21+
{
22+
VerticalAlignment = VerticalAlignment.Center
23+
};
24+
25+
const int ImageSize = 300;
26+
27+
var image = new Image<Rgba32>(ImageSize, ImageSize);
28+
29+
string iconText = char.ConvertFromUtf32(int.Parse("e926", NumberStyles.HexNumber));
30+
31+
FontRectangle rect = TextMeasurer.Measure(iconText, options);
32+
33+
float textX = ((ImageSize - rect.Width) * 0.5F) + rect.Left;
34+
float textY = ((ImageSize - rect.Height) * 0.5F) + (rect.Top * 0.25F);
35+
36+
image.Mutate(x => x.DrawText(iconText, font, Color.Black, new PointF(textX, textY)));
37+
image.Save(TestFontUtilities.GetPath("e96.png"));
38+
}
39+
40+
private static Font CreateFont(string fontName, int size)
41+
{
42+
var fontCollection = new FontCollection();
43+
string fontPath = TestFontUtilities.GetPath(fontName);
44+
return fontCollection.Install(fontPath).CreateFont(size);
45+
}
46+
}
47+
}
22.1 KB
Binary file not shown.

tests/ImageSharp.Drawing.Tests/TestFormat.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
using System.IO;
77
using System.Linq;
88
using System.Numerics;
9-
9+
using System.Threading.Tasks;
10+
using SixLabors.ImageSharp;
1011
using SixLabors.ImageSharp.Formats;
1112
using SixLabors.ImageSharp.PixelFormats;
1213
using Xunit;
@@ -184,7 +185,7 @@ public TestHeader(TestFormat testFormat)
184185
this.testFormat = testFormat;
185186
}
186187
}
187-
public class TestDecoder : ImageSharp.Formats.IImageDecoder
188+
public class TestDecoder : IImageDecoder
188189
{
189190
private TestFormat testFormat;
190191

@@ -219,9 +220,16 @@ public Image<TPixel> Decode<TPixel>(Configuration config, Stream stream) where T
219220
public bool IsSupportedFileFormat(Span<byte> header) => testFormat.IsSupportedFileFormat(header);
220221

221222
public Image Decode(Configuration configuration, Stream stream) => this.Decode<TestPixelForAgnosticDecode>(configuration, stream);
223+
224+
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream)
225+
where TPixel : unmanaged, IPixel<TPixel>
226+
=> throw new NotImplementedException();
227+
228+
public Task<Image> DecodeAsync(Configuration configuration, Stream stream)
229+
=> throw new NotImplementedException();
222230
}
223231

224-
public class TestEncoder : ImageSharp.Formats.IImageEncoder
232+
public class TestEncoder : IImageEncoder
225233
{
226234
private TestFormat testFormat;
227235

@@ -238,6 +246,9 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream) where TPixel : un
238246
{
239247
// TODO record this happened so we can verify it.
240248
}
249+
250+
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
251+
=> throw new NotImplementedException();
241252
}
242253

243254

tests/ImageSharp.Drawing.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
using System;
55
using System.IO;
66
using System.Runtime.InteropServices;
7-
7+
using System.Threading.Tasks;
88
using ImageMagick;
9-
109
using SixLabors.ImageSharp.Advanced;
1110
using SixLabors.ImageSharp.Formats;
1211
using SixLabors.ImageSharp.Memory;
@@ -79,5 +78,7 @@ private static void FromRgba64Bytes<TPixel>(Configuration configuration, Span<by
7978
}
8079

8180
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
81+
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream) where TPixel : unmanaged, IPixel<TPixel> => throw new NotImplementedException();
82+
public Task<Image> DecodeAsync(Configuration configuration, Stream stream) => throw new NotImplementedException();
8283
}
8384
}

tests/ImageSharp.Drawing.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.IO;
5-
5+
using System.Threading.Tasks;
66
using SixLabors.ImageSharp.Formats;
77
using SixLabors.ImageSharp.Metadata;
88
using SixLabors.ImageSharp.PixelFormats;
@@ -53,5 +53,8 @@ public IImageInfo Identify(Configuration configuration, Stream stream)
5353
}
5454

5555
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
56+
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream) where TPixel : unmanaged, IPixel<TPixel> => throw new System.NotImplementedException();
57+
public Task<Image> DecodeAsync(Configuration configuration, Stream stream) => throw new System.NotImplementedException();
58+
public Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream) => throw new System.NotImplementedException();
5659
}
5760
}

tests/ImageSharp.Drawing.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System.Drawing.Imaging;
55
using System.IO;
6-
6+
using System.Threading.Tasks;
77
using SixLabors.ImageSharp.Formats;
88
using SixLabors.ImageSharp.PixelFormats;
99

@@ -30,5 +30,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
3030
sdBitmap.Save(stream, this.imageFormat);
3131
}
3232
}
33+
34+
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream) where TPixel : unmanaged, IPixel<TPixel> => throw new System.NotImplementedException();
3335
}
3436
}

tests/ImageSharp.Drawing.Tests/TestUtilities/Tests/TestImageProviderTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Collections.Concurrent;
66
using System.IO;
7-
7+
using System.Threading.Tasks;
88
using SixLabors.ImageSharp.Advanced;
99
using SixLabors.ImageSharp.Formats;
1010
using SixLabors.ImageSharp.Memory;
@@ -379,6 +379,8 @@ internal void InitCaller(string name)
379379
}
380380

381381
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
382+
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream) where TPixel : unmanaged, IPixel<TPixel> => throw new NotImplementedException();
383+
public Task<Image> DecodeAsync(Configuration configuration, Stream stream) => throw new NotImplementedException();
382384
}
383385

384386
private class TestDecoderWithParameters : IImageDecoder
@@ -418,6 +420,8 @@ internal void InitCaller(string name)
418420
}
419421

420422
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
423+
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream) where TPixel : unmanaged, IPixel<TPixel> => throw new NotImplementedException();
424+
public Task<Image> DecodeAsync(Configuration configuration, Stream stream) => throw new NotImplementedException();
421425
}
422426
}
423427
}

0 commit comments

Comments
 (0)