SixLabors / Fonts

:black_nib: Font loading and layout library.
https://sixlabors.com/products/fonts
Other
308 stars 71 forks source link

Incorrect render of Thai characters when ascii characters are present in rendered text #300

Closed eangelov closed 2 years ago

eangelov commented 2 years ago

Prerequisites

Description

When using DrawText on the test image to draw "ดวันโอวัน" everything is as expected resultImage_1

When we draw "Test ดวันโอวัน" we get image

Test Image: testImage

Steps to Reproduce

using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Processing;

var fonts = new FontCollection();
fonts.AddSystemFonts();

string textToDraw = "ดวันโอวัน";

TextOptions textOpts = new TextOptions( fonts.Get( "Microsoft Sans Serif" ).CreateFont( 60, SixLabors.Fonts.FontStyle.Regular ) ){
    Origin = new SixLabors.ImageSharp.PointF( 10, 10 )
};

using Image image = Image.Load( "testImage.jpg" );
image.Mutate( 
    x => x.DrawText( 
        textOpts, textToDraw, Color.ParseHex( "#000000" ) 
    ) 
);
image.SaveAsJpeg( "resultImage_1.jpg" );

using Image image2 = Image.Load( "testImage.jpg" );
image2.Mutate( 
    x => x.DrawText( 
        textOpts, $"Test {textToDraw}", Color.ParseHex( "#000000" ) 
    ) 
);
image2.SaveAsJpeg( "resultImage_2.jpg" );

System Configuration

JimBobSquarePants commented 2 years ago

See https://github.com/SixLabors/Fonts/issues/215 we don't have a shaper for it yet.

I'll have a look at why it changes when mixed with English though as that's odd.