Skip to content

Commit a4d0378

Browse files
Add emoji grid text rendering test and bump Fonts
1 parent cc01945 commit a4d0378

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<None Include="..\..\shared-infrastructure\branding\icons\imagesharp.drawing\sixlabors.imagesharp.drawing.128.png" Pack="true" PackagePath="" />
4141
</ItemGroup>
4242
<ItemGroup>
43-
<PackageReference Include="SixLabors.Fonts" Version="3.0.0-alpha.0.38" />
43+
<PackageReference Include="SixLabors.Fonts" Version="3.0.0-alpha.0.39" />
4444
<PackageReference Include="SixLabors.ImageSharp" Version="4.0.0-alpha.0.94" />
4545
<PackageReference Include="SixLabors.PolygonClipper" Version="1.0.0-alpha.0.54" />
4646
</ItemGroup>

tests/ImageSharp.Drawing.Tests/Processing/ProcessWithDrawingCanvasTests.Text.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,53 @@ public void CanRenderTextOutOfBoundsIssue301<TPixel>(TestImageProvider<TPixel> p
10411041
false,
10421042
false);
10431043

1044+
[Theory]
1045+
[WithSolidFilledImages(10, 10, "White", PixelTypes.Rgba32)]
1046+
public void DrawText_EmojiGrid_NotoColorEmoji<TPixel>(TestImageProvider<TPixel> provider)
1047+
where TPixel : unmanaged, IPixel<TPixel>
1048+
{
1049+
Font font = CreateFont(TestFonts.NotoColorEmojiRegular, 64);
1050+
1051+
const string text =
1052+
"😀😃😄😁😆😅😂🤣😭😉😗😙\n" +
1053+
"😚😘🥰😍🤩🥳🙃🙂🥲🥹😋😛\n" +
1054+
"😝😜🤪😇😊☺️😏😌😔😑😐😶\n" +
1055+
"🫡🤔🤫🫢🤭🥱🤗🫣😱🤨🧐😒\n" +
1056+
"🙄😮‍💨😤😠😡🤬🥺😟😥😢☹️🙁\n" +
1057+
"🫤😕🤐😰😨😧😦😮😯😲😳🤯\n" +
1058+
"😬😓😞😖😣😩😫😵😵‍💫🫥😴😪\n" +
1059+
"🤤🌛🌜🌚🌝🌞🫠😶‍🌫️🥴🥵🥶🤢\n" +
1060+
"🤮🤧🤒🤕😷🤠🤑😎🤓🥸🤥🤡\n" +
1061+
"👻💩👽🤖🎃😈👿👹👺🔥💫⭐\n" +
1062+
"🌟✨💥💯💢💨💦🫧💤🕳️🎉🎊\n" +
1063+
"🙈🙉🙊😺😸😹😻😼😽🙀😿😾\n" +
1064+
"❤️🧡💛💚💙💜🤎🖤🤍♥️💘💝\n" +
1065+
"💖💗💓💞💕💌💟❣️❤️‍🩹💔❤️‍🔥💋\n" +
1066+
"🫂👥👤🗣️👣🧠🫀🫁🩸🦠🦷🦴\n" +
1067+
"☠️💀👀👁️👄🫦👅👃👂🦻🦶🦵\n" +
1068+
"🦿🦾💪👍👎👏🫶🙌👐🤲🤝🤜\n" +
1069+
"🤛✊👊🫳🫴🫱🫲🤚👋🖐️✋🖖\n" +
1070+
"🤟🤘✌️🤞🫰🤙🤌🤏👌🖕☝️👆\n" +
1071+
"👇👉👈🫵✍️🤳🙏💅";
1072+
1073+
RichTextOptions textOptions = new(font)
1074+
{
1075+
ColorFontSupport = ColorFontSupport.ColrV1,
1076+
LineSpacing = 1.15F,
1077+
};
1078+
1079+
FontRectangle bounds = TextMeasurer.MeasureRenderableBounds(text, textOptions);
1080+
int width = (int)MathF.Ceiling(bounds.Right);
1081+
int height = (int)MathF.Ceiling(bounds.Bottom);
1082+
1083+
provider.VerifyOperation(
1084+
TextDrawingComparer,
1085+
img => img.Mutate(i => i.Resize(width, height, KnownResamplers.NearestNeighbor)
1086+
.ProcessWithCanvas(canvas => canvas.DrawText(textOptions, text, Brushes.Solid(Color.Black), pen: null))),
1087+
appendPixelTypeToFileName: false,
1088+
appendSourceFileOrDescription: false);
1089+
}
1090+
10441091
private static RichTextOptions CreateTextOptionsAt(Font font, PointF origin)
10451092
=> new(font) { Origin = origin };
10461093

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)