Fonts icon indicating copy to clipboard operation
Fonts copied to clipboard

Hinting makes text looks like zalgo.

Open eX-pes opened this issue 3 years ago • 5 comments

Description

I'm evaluating your library for my project. But when i tried to turn hinting on - text got broken: _six Without hinting it's looks like this: _six

Steps to Reproduce

public static void Main(string[] args)
{
    var fonts = new FontCollection();

    FontFamily font = fonts.Add(@"Fonts\OpenSans-Regular.ttf");

    using var img = new Image<Rgba32>(1024, 800);
    img.Mutate(x => x.Fill(Color.White));

    var str = "The quick brown fox jumps over the lazy dog. 0123456789";

    var off_y = 0f;

    for (int size = 5; size < 64; size++)
    {
        RenderText(font.CreateFont(size), str, img, off_y += size + 1);
    }

    using FileStream fs = File.Create("_six" + ".png");
    img.SaveAsPng(fs);
}

public static void RenderText(Font font, string text, Image<Rgba32> img, float y)
{
    string path = IOPath.GetInvalidFileNameChars().Aggregate(text, (x, c) => x.Replace($"{c}", "-"));
    string fullPath = IOPath.GetFullPath(IOPath.Combine("Output", IOPath.Combine(path)));

    IPathCollection shapes = TextBuilder.GenerateGlyphs(text, new TextOptions(font)
    {
        Origin = new Vector2(50f, y),
    });
    img.Mutate(x => x.Fill(Color.Black, shapes));
}

System Configuration

  • Fonts version: 1.0.0-beta18
  • Other Six Labors packages and versions: SixLabors.ImageSharp.Drawing 1.0.0-beta14.8
  • Environment (Operating system, version and so on): Win10
  • .NET Framework version: netcore sdk 3.1.421

eX-pes avatar Aug 03 '22 08:08 eX-pes

See #293

Also, please don’t change the template

JimBobSquarePants avatar Aug 03 '22 08:08 JimBobSquarePants

Nice test code btw. I’m going to use that while I finish fixing the issue

JimBobSquarePants avatar Aug 03 '22 08:08 JimBobSquarePants

@eX-pes can you please attach your version of the font?

JimBobSquarePants avatar Aug 03 '22 09:08 JimBobSquarePants

It was this one: https://github.com/SixLabors/Fonts/blob/v1.0.0-beta18/tests/SixLabors.Fonts.Tests/Fonts/OpenSans-Regular.ttf

We did checkout repo at 1.0.0-beta18 tag, and made our own example.

jakerdy avatar Aug 03 '22 09:08 jakerdy

It looks like the fixes I'm working locally are working well.

Hinting is left, no hinting right

Open San hinting comparison

JimBobSquarePants avatar Aug 03 '22 13:08 JimBobSquarePants

Fixed with #295

JimBobSquarePants avatar Oct 15 '22 13:10 JimBobSquarePants