This commit is contained in:
Scott Williams 2024-05-10 16:27:59 +01:00
Родитель c8ae268cc0
Коммит a90adacae5
8 изменённых файлов: 101 добавлений и 11 удалений

Просмотреть файл

@ -367,9 +367,10 @@ internal sealed class RichTextGlyphRenderer : BaseGlyphBuilder, IColorGlyphRende
if (renderData.OutlineMap != null)
{
int offset = (int)((this.currentPen?.StrokeWidth ?? 0) / 2);
this.DrawingOperations.Add(new DrawingOperation
{
RenderLocation = renderLocation,
RenderLocation = renderLocation - new Size(offset, offset),
Map = renderData.OutlineMap,
Brush = this.currentPen?.StrokeFill ?? this.currentBrush!,
RenderPass = RenderOrderOutline

Просмотреть файл

@ -0,0 +1,68 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SixLabors.Fonts;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Drawing.Tests.Issues;
public class Issue_330
{
[Theory]
[WithSolidFilledImages(2084, 2084, nameof(Color.BlueViolet), PixelTypes.Rgba32)]
public void OffsetTextOutlines<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
FontFamily fontFamily = TestFontUtilities.GetFontFamily(TestFonts.OpenSans);
Font bibfont = fontFamily.CreateFont(600, FontStyle.Bold);
Font namefont = fontFamily.CreateFont(140, FontStyle.Bold);
provider.RunValidatingProcessorTest(p =>
{
p.DrawText(
new RichTextOptions(bibfont)
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
TextAlignment = TextAlignment.Center,
TextDirection = TextDirection.LeftToRight,
Origin = new Point(1156, 1024),
},
"9999",
Brushes.Solid(Color.White),
Pens.Solid(Color.Black, 20));
p.DrawText(
new RichTextOptions(namefont)
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
TextAlignment = TextAlignment.Center,
TextDirection = TextDirection.LeftToRight,
Origin = new Point(1156, 713),
},
"JOHAN",
Brushes.Solid(Color.White),
Pens.Solid(Color.Black, 5));
p.DrawText(
new RichTextOptions(namefont)
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
TextAlignment = TextAlignment.Center,
TextDirection = TextDirection.LeftToRight,
Origin = new Point(1156, 1381),
},
"TIGERTECH",
Brushes.Solid(Color.White),
Pens.Solid(Color.Black, 5));
});
}
}

Просмотреть файл

@ -1,6 +1,7 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Globalization;
using System.Reflection;
using SixLabors.Fonts;
using IOPath = System.IO.Path;
@ -19,7 +20,15 @@ public static class TestFontUtilities
/// <param name="size">The font size.</param>
/// <returns>The <see cref="Font"/></returns>
public static Font GetFont(string name, float size)
=> GetFont(new FontCollection(), name, size);
=> GetFontFamily(name).CreateFont(size);
/// <summary>
/// Gets a font family with the given name.
/// </summary>
/// <param name="name">The name of the font.</param>
/// <returns>The <see cref="Font"/></returns>
public static FontFamily GetFontFamily(string name)
=> GetFontFamily(new FontCollection(), name);
/// <summary>
/// Gets a font with the given name and size.
@ -29,7 +38,16 @@ public static class TestFontUtilities
/// <param name="size">The font size.</param>
/// <returns>The <see cref="Font"/></returns>
public static Font GetFont(FontCollection collection, string name, float size)
=> collection.Add(GetPath(name)).CreateFont(size);
=> GetFontFamily(collection, name).CreateFont(size);
/// <summary>
/// Gets a font family with the given name
/// </summary>
/// <param name="collection">The collection to add the font to</param>
/// <param name="name">The name of the font.</param>
/// <returns>The <see cref="Font"/></returns>
public static FontFamily GetFontFamily(FontCollection collection, string name)
=> collection.Add(GetPath(name), CultureInfo.InvariantCulture);
/// <summary>
/// The formats directory.

Просмотреть файл

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4396a75b759dad700ae08df7549df0ab35f2ae154a948eca5bb51710490f0d83
size 2447
oid sha256:c00599c79b059fa60e52b7de3a52d574c677df2c2a9729c3a046f75059583e27
size 6023

Просмотреть файл

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:450d4edb2b067c212705387ea6a42763464707c86d0ddd365b81c1795ad31c93
size 17917
oid sha256:8333f5bf72363f6cbebd69efe351d4234ae7f870b5c088991bd0a18ee855aa30
size 33277

Просмотреть файл

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bb97d53d830d65c290158ce1bbd5eae4033727f8fe8b534b7555c4bde89c9db0
size 1244
oid sha256:74bc71359f75ab560474d53aa74d2e4a4d09807552020d426e6f1545b769b71b
size 2821

Просмотреть файл

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65702ca76b6301fa1c4c1ecf4b07e654de1a4a59940ed156fc91d8670cf4c56a
size 17366
oid sha256:3ffcef97021e6572d9827ac1a128882042695bf2b3bf1e27127358d7cef994f6
size 31488

Просмотреть файл

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b44ee8f82a88b7a6d8c0c908308aac7c9d90ad22370e2942b976c06cbdf2f1b3
size 186486