dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 532 forks source link

Is there any way to use AntiAliasGridFit in .net android? #9501

Closed ljzj2 closed 1 week ago

ljzj2 commented 1 week ago

I wonder if there is any way to use AntiAliasGridFit in .net android ? I draw text in winform and I can set it as is: Image

in winform I only set AntiAliasGridFit but If I use .net android and set

Bitmap bmp = Bitmap.CreateBitmap(309, 36, Bitmap.Config.Argb8888);
Canvas canvas = new(bmp);
canvas.DrawColor(Color.ParseColor("#000000"));
canvas.DrawFilter = new PaintFlagsDrawFilter(0, PaintFlags.AntiAlias | PaintFlags.FilterBitmap);
Paint paint = new()
{
    Color = Color.ParseColor("#ffffff"),
    AntiAlias = true
};
//var arail = Typeface.Create("Arial", TypefaceStyle.Normal);
var arail = Typeface.CreateFromAsset(Assets, "fonts/micross.ttf");//this is the Arial which winform use
paint.SetTypeface(arail);
paint.TextSize = 12;
paint.SubpixelText = true;
paint.FilterBitmap = true;
 canvas.DrawText(str1, 0 + xoffset, rect1.Height(), paint);

it is like this: Image

the two picture is zoomed.

in winform is sharp right and clear?

Is there any way I can use to draw text like winforms?

jpobst commented 1 week ago

Ultimately, all .NET for Android does is provide generated wrappers that allow you to call Google’s Android API. We do not have much expertise in how to use those API’s properly.

You will likely need to use the Android API documentation and relevant forums to determine how to write code for your desired outcome.