diff --git a/binding/SkiaSharp/SKBitmap.cs b/binding/SkiaSharp/SKBitmap.cs index 93219f0b90c..cc4ed9f18c4 100644 --- a/binding/SkiaSharp/SKBitmap.cs +++ b/binding/SkiaSharp/SKBitmap.cs @@ -328,7 +328,7 @@ public byte[] Bytes { public SKColor[] Pixels { get { var info = Info; - var pixels = new SKColor[info.Width * info.Height]; + var pixels = new SKColor[checked(info.Width * info.Height)]; fixed (SKColor* p = pixels) { SkiaApi.sk_bitmap_get_pixel_colors (Handle, (uint*)p); } @@ -339,8 +339,9 @@ public SKColor[] Pixels { throw new ArgumentNullException (nameof (value)); var info = Info; - if (info.Width * info.Height != value.Length) - throw new ArgumentException ($"The number of pixels must equal Width x Height, or {info.Width * info.Height}.", nameof (value)); + var expected = (long)info.Width * info.Height; + if (expected != value.Length) + throw new ArgumentException ($"The number of pixels must equal Width x Height, or {expected}.", nameof (value)); fixed (SKColor* v = value) { var tempInfo = new SKImageInfo (info.Width, info.Height, SKColorType.Bgra8888, SKAlphaType.Unpremul); @@ -653,11 +654,11 @@ public bool PeekPixels (SKPixmap pixmap) // Resize - [Obsolete ("Use Resize(SKImageInfo info, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use Resize(SKImageInfo info, SKSamplingOptions sampling) instead.", error: true)] public SKBitmap Resize (SKImageInfo info, SKFilterQuality quality) => Resize (info, quality.ToSamplingOptions ()); - [Obsolete ("Use Resize(SKSizeI size, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use Resize(SKSizeI size, SKSamplingOptions sampling) instead.", error: true)] public SKBitmap Resize (SKSizeI size, SKFilterQuality quality) => Resize (size, quality.ToSamplingOptions ()); @@ -680,11 +681,11 @@ public SKBitmap Resize (SKSizeI size, SKSamplingOptions sampling) => // ScalePixels - [Obsolete ("Use ScalePixels(SKBitmap destination, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use ScalePixels(SKBitmap destination, SKSamplingOptions sampling) instead.", error: true)] public bool ScalePixels (SKBitmap destination, SKFilterQuality quality) => ScalePixels (destination, quality.ToSamplingOptions ()); - [Obsolete ("Use ScalePixels(SKPixmap destination, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use ScalePixels(SKPixmap destination, SKSamplingOptions sampling) instead.", error: true)] public bool ScalePixels (SKPixmap destination, SKFilterQuality quality) => ScalePixels (destination, quality.ToSamplingOptions ()); @@ -767,7 +768,7 @@ public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy) => public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) => ToShader (tmx, tmy, sampling, null); - [Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.", error: true)] public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality) => ToShader (tmx, tmy, quality.ToSamplingOptions(), null); @@ -777,7 +778,7 @@ public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix l public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) => ToShader (tmx, tmy, sampling, &localMatrix); - [Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")] + [Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.", error: true)] public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality, SKMatrix localMatrix) => ToShader (tmx, tmy, quality.ToSamplingOptions(), &localMatrix); diff --git a/binding/SkiaSharp/SKCanvas.cs b/binding/SkiaSharp/SKCanvas.cs index b16a04e4ffa..fee2faf9311 100644 --- a/binding/SkiaSharp/SKCanvas.cs +++ b/binding/SkiaSharp/SKCanvas.cs @@ -454,9 +454,7 @@ public void DrawPoint (float x, float y, SKColor color) public void DrawImage (SKImage image, SKPoint p, SKPaint paint = null) { -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawImage (image, p.X, p.Y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawImage (image, p.X, p.Y, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKPoint p, SKSamplingOptions sampling, SKPaint paint = null) @@ -466,9 +464,7 @@ public void DrawImage (SKImage image, SKPoint p, SKSamplingOptions sampling, SKP public void DrawImage (SKImage image, float x, float y, SKPaint paint = null) { -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawImage (image, x, y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawImage (image, x, y, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, float x, float y, SKSamplingOptions sampling, SKPaint paint = null) @@ -480,9 +476,7 @@ public void DrawImage (SKImage image, float x, float y, SKSamplingOptions sampli public void DrawImage (SKImage image, SKRect dest, SKPaint paint = null) { -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawImage (image, null, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawImage (image, null, &dest, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null) @@ -492,9 +486,7 @@ public void DrawImage (SKImage image, SKRect dest, SKSamplingOptions sampling, S public void DrawImage (SKImage image, SKRect source, SKRect dest, SKPaint paint = null) { -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawImage (image, &source, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawImage (image, &source, &dest, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, paint); } public void DrawImage (SKImage image, SKRect source, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null) @@ -628,26 +620,24 @@ public void DrawText (SKTextBlob text, float x, float y, SKPaint paint) // DrawText - [Obsolete ("Use DrawText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] + [Obsolete ("Use DrawText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawText (string text, SKPoint p, SKPaint paint) => DrawText (text, p, paint.TextAlign, paint.GetFont (), paint); - [Obsolete ("Use DrawText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] + [Obsolete ("Use DrawText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawText (string text, float x, float y, SKPaint paint) => DrawText (text, x, y, paint.TextAlign, paint.GetFont (), paint); + [Obsolete ("Use DrawText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawText (string text, SKPoint p, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - DrawText (text, p, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + DrawText (text, p, paint.GetLegacyTextAlign (), font, paint); public void DrawText (string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) => DrawText (text, p.X, p.Y, textAlign, font, paint); + [Obsolete ("Use DrawText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawText (string text, float x, float y, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - DrawText (text, x, y, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + DrawText (text, x, y, paint.GetLegacyTextAlign (), font, paint); public void DrawText (string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) { @@ -674,38 +664,32 @@ public void DrawText (string text, float x, float y, SKTextAlign textAlign, SKFo // DrawTextOnPath - [Obsolete ("Use DrawTextOnPath(string text, SKPath path, float hOffset, float vOffset, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] + [Obsolete ("Use DrawTextOnPath(string text, SKPath path, float hOffset, float vOffset, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawTextOnPath (string text, SKPath path, SKPoint offset, SKPaint paint) => DrawTextOnPath (text, path, offset, true, paint); - [Obsolete ("Use DrawTextOnPath(string text, SKPath path, float hOffset, float vOffset, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] + [Obsolete ("Use DrawTextOnPath(string text, SKPath path, float hOffset, float vOffset, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawTextOnPath (string text, SKPath path, float hOffset, float vOffset, SKPaint paint) => DrawTextOnPath (text, path, new SKPoint (hOffset, vOffset), true, paint); - [Obsolete ("Use DrawTextOnPath(string text, SKPath path, SKPoint offset, bool warpGlyphs, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] + [Obsolete ("Use DrawTextOnPath(string text, SKPath path, SKPoint offset, bool warpGlyphs, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.", error: true)] public void DrawTextOnPath (string text, SKPath path, SKPoint offset, bool warpGlyphs, SKPaint paint) => DrawTextOnPath (text, path, offset, warpGlyphs, paint.GetFont (), paint); public void DrawTextOnPath (string text, SKPath path, SKPoint offset, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - DrawTextOnPath (text, path, offset, true, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + DrawTextOnPath (text, path, offset, true, paint.GetLegacyTextAlign (), font, paint); public void DrawTextOnPath (string text, SKPath path, SKPoint offset, SKTextAlign textAlign, SKFont font, SKPaint paint) => DrawTextOnPath (text, path, offset, true, textAlign, font, paint); public void DrawTextOnPath (string text, SKPath path, float hOffset, float vOffset, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - DrawTextOnPath (text, path, new SKPoint (hOffset, vOffset), true, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + DrawTextOnPath (text, path, new SKPoint (hOffset, vOffset), true, paint.GetLegacyTextAlign (), font, paint); public void DrawTextOnPath (string text, SKPath path, float hOffset, float vOffset, SKTextAlign textAlign, SKFont font, SKPaint paint) => DrawTextOnPath (text, path, new SKPoint (hOffset, vOffset), true, textAlign, font, paint); public void DrawTextOnPath (string text, SKPath path, SKPoint offset, bool warpGlyphs, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - DrawTextOnPath (text, path, offset, warpGlyphs, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + DrawTextOnPath (text, path, offset, warpGlyphs, paint.GetLegacyTextAlign (), font, paint); public void DrawTextOnPath (string text, SKPath path, SKPoint offset, bool warpGlyphs, SKTextAlign textAlign, SKFont font, SKPaint paint) { @@ -981,25 +965,19 @@ public void DrawRoundRectDifference (SKRoundRect outer, SKRoundRect inner, SKPai // DrawAtlas public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint = null) => -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, null, paint); public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKSamplingOptions sampling, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, sampling, null, paint); public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKPaint paint = null) => -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, null, paint); public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, null, paint); public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint = null) => -#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' - DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, &cullRect, paint); -#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.' + DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.GetLegacyFilterQualitySampling () ?? SKSamplingOptions.Default, &cullRect, paint); public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect cullRect, SKPaint paint = null) => DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, &cullRect, paint); diff --git a/binding/SkiaSharp/SKImage.cs b/binding/SkiaSharp/SKImage.cs index d5e5e36f7c7..b7d2e38fe5c 100644 --- a/binding/SkiaSharp/SKImage.cs +++ b/binding/SkiaSharp/SKImage.cs @@ -409,14 +409,14 @@ public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKMatr public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling) => ToShader (tileX, tileY, sampling, null); - [Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling) instead.", error: true)] public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKFilterQuality quality) => ToShader (tileX, tileY, quality.ToSamplingOptions(), null); public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix localMatrix) => ToShader (tileX, tileY, sampling, &localMatrix); - [Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")] + [Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix localMatrix) instead.", error: true)] public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKFilterQuality quality, SKMatrix localMatrix) => ToShader (tileX, tileY, quality.ToSamplingOptions(), &localMatrix); @@ -515,11 +515,11 @@ public bool ReadPixels (SKPixmap pixmap, int srcX, int srcY, SKImageCachingHint // ScalePixels - [Obsolete("Use ScalePixels(SKPixmap dst, SKSamplingOptions sampling) instead.")] + [Obsolete("Use ScalePixels(SKPixmap dst, SKSamplingOptions sampling) instead.", error: true)] public bool ScalePixels (SKPixmap dst, SKFilterQuality quality) => ScalePixels (dst, quality.ToSamplingOptions ()); - [Obsolete("Use ScalePixels(SKPixmap dst, SKSamplingOptions sampling, SKImageCachingHint cachingHint) instead.")] + [Obsolete("Use ScalePixels(SKPixmap dst, SKSamplingOptions sampling, SKImageCachingHint cachingHint) instead.", error: true)] public bool ScalePixels (SKPixmap dst, SKFilterQuality quality, SKImageCachingHint cachingHint) => ScalePixels (dst, quality.ToSamplingOptions (), cachingHint); diff --git a/binding/SkiaSharp/SKImageInfo.cs b/binding/SkiaSharp/SKImageInfo.cs index 3a930c11837..4501f864f32 100644 --- a/binding/SkiaSharp/SKImageInfo.cs +++ b/binding/SkiaSharp/SKImageInfo.cs @@ -109,11 +109,11 @@ public SKImageInfo (int width, int height, SKColorType colorType, SKAlphaType al public readonly int BitsPerPixel => BytesPerPixel * 8; - public readonly int BytesSize => Width * Height * BytesPerPixel; + public readonly int BytesSize => checked(Width * Height * BytesPerPixel); public readonly long BytesSize64 => (long)Width * (long)Height * (long)BytesPerPixel; - public readonly int RowBytes => Width * BytesPerPixel; + public readonly int RowBytes => checked(Width * BytesPerPixel); public readonly long RowBytes64 => (long)Width * (long)BytesPerPixel; @@ -128,7 +128,7 @@ public SKImageInfo (int width, int height, SKColorType colorType, SKAlphaType al internal readonly int GetPixelBytesOffset (int x, int y) => ColorType == SKColorType.Unknown ? 0 - : y * RowBytes + (x << ColorType.GetBitShiftPerPixel ()); + : checked(y * RowBytes + (x << ColorType.GetBitShiftPerPixel ())); public readonly SKImageInfo WithSize (SKSizeI size) => WithSize (size.Width, size.Height); diff --git a/binding/SkiaSharp/SKPaint.cs b/binding/SkiaSharp/SKPaint.cs index 4ad8e2b0abb..a100d51a930 100644 --- a/binding/SkiaSharp/SKPaint.cs +++ b/binding/SkiaSharp/SKPaint.cs @@ -24,7 +24,7 @@ public enum SKFilterQuality public static partial class SkiaExtensions { - [Obsolete ($"Use {nameof (SKSamplingOptions)} instead.")] + [Obsolete ($"Use {nameof (SKSamplingOptions)} instead.", error: true)] public static SKSamplingOptions ToSamplingOptions (this SKFilterQuality quality) => quality switch { SKFilterQuality.None => new SKSamplingOptions (SKFilterMode.Nearest, SKMipmapMode.None), @@ -37,7 +37,6 @@ public static SKSamplingOptions ToSamplingOptions (this SKFilterQuality quality) public unsafe class SKPaint : SKObject, ISKSkipObjectRegistration { - [Obsolete] private SKFont font; // Shared template that backs SKPaint()'s default font and SKPaint.Reset()'s @@ -69,7 +68,7 @@ public SKPaint () } } - [Obsolete ($"Use {nameof (SKFont)} instead.")] + [Obsolete ($"Use {nameof (SKFont)} instead.", error: true)] public SKPaint (SKFont font) : this (IntPtr.Zero, true) { @@ -112,43 +111,43 @@ public bool IsDither { set => SkiaApi.sk_paint_set_dither (Handle, value); } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.LinearMetrics)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.LinearMetrics)} instead.", error: true)] public bool IsLinearText { get => GetFont ().LinearMetrics; set => GetFont ().LinearMetrics = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Subpixel)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Subpixel)} instead.", error: true)] public bool SubpixelText { get => GetFont ().Subpixel; set => GetFont ().Subpixel = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Edging)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Edging)} instead.", error: true)] public bool LcdRenderText { get => SkiaApi.sk_compatpaint_get_lcd_render_text (Handle); set => SkiaApi.sk_compatpaint_set_lcd_render_text (Handle, value); } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.EmbeddedBitmaps)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.EmbeddedBitmaps)} instead.", error: true)] public bool IsEmbeddedBitmapText { get => GetFont ().EmbeddedBitmaps; set => GetFont ().EmbeddedBitmaps = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ForceAutoHinting)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ForceAutoHinting)} instead.", error: true)] public bool IsAutohinted { get => GetFont ().ForceAutoHinting; set => GetFont ().ForceAutoHinting = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Hinting)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Hinting)} instead.", error: true)] public SKPaintHinting HintingLevel { get => (SKPaintHinting)GetFont ().Hinting; set => GetFont ().Hinting = (SKFontHinting)value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Embolden)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Embolden)} instead.", error: true)] public bool FakeBoldText { get => GetFont ().Embolden; set => GetFont ().Embolden = value; @@ -231,43 +230,43 @@ public SKBlender Blender { set => SkiaApi.sk_paint_set_blender (Handle, value == null ? IntPtr.Zero : value.Handle); } - [Obsolete ($"Use {nameof (SKSamplingOptions)} instead.")] + [Obsolete ($"Use {nameof (SKSamplingOptions)} instead.", error: true)] public SKFilterQuality FilterQuality { get => (SKFilterQuality)SkiaApi.sk_compatpaint_get_filter_quality (Handle); set => SkiaApi.sk_compatpaint_set_filter_quality (Handle, (int)value); } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Typeface)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Typeface)} instead.", error: true)] public SKTypeface Typeface { get => GetFont ().Typeface; set => GetFont ().Typeface = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Size)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Size)} instead.", error: true)] public float TextSize { get => GetFont ().Size; set => GetFont ().Size = value; } - [Obsolete ($"Use {nameof (SKTextAlign)} method overloads instead.")] + [Obsolete ($"Use {nameof (SKTextAlign)} method overloads instead.", error: true)] public SKTextAlign TextAlign { get => SkiaApi.sk_compatpaint_get_text_align (Handle); set => SkiaApi.sk_compatpaint_set_text_align (Handle, value); } - [Obsolete ($"Use {nameof (SKTextEncoding)} method overloads instead.")] + [Obsolete ($"Use {nameof (SKTextEncoding)} method overloads instead.", error: true)] public SKTextEncoding TextEncoding { get => SkiaApi.sk_compatpaint_get_text_encoding (Handle); set => SkiaApi.sk_compatpaint_set_text_encoding (Handle, value); } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ScaleX)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ScaleX)} instead.", error: true)] public float TextScaleX { get => GetFont ().ScaleX; set => GetFont ().ScaleX = value; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.SkewX)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.SkewX)} instead.", error: true)] public float TextSkewX { get => GetFont ().SkewX; set => GetFont ().SkewX = value; @@ -280,20 +279,20 @@ public SKPathEffect PathEffect { // FontSpacing - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Spacing)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Spacing)} instead.", error: true)] public float FontSpacing => GetFont ().Spacing; // FontMetrics - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Metrics)} instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.Metrics)} instead.", error: true)] public SKFontMetrics FontMetrics { get { return GetFont ().Metrics; } } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetFontMetrics)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetFontMetrics)}() instead.", error: true)] public float GetFontMetrics (out SKFontMetrics metrics) => GetFont ().GetFontMetrics (out metrics); @@ -304,65 +303,65 @@ public SKPaint Clone () => // MeasureText - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (string text) => GetFont ().MeasureText (text, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (ReadOnlySpan text) => GetFont ().MeasureText (text, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (byte[] text) => GetFont ().MeasureText (text, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (ReadOnlySpan text) => GetFont ().MeasureText (text, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (IntPtr buffer, int length) => GetFont ().MeasureText (buffer, length, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (IntPtr buffer, IntPtr length) => GetFont ().MeasureText (buffer, (int)length, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (string text, ref SKRect bounds) => GetFont ().MeasureText (text, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (ReadOnlySpan text, ref SKRect bounds) => GetFont ().MeasureText (text, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (byte[] text, ref SKRect bounds) => GetFont ().MeasureText (text, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (ReadOnlySpan text, ref SKRect bounds) => GetFont ().MeasureText (text, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (IntPtr buffer, int length, ref SKRect bounds) => GetFont ().MeasureText (buffer, length, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.MeasureText)}() instead.", error: true)] public float MeasureText (IntPtr buffer, IntPtr length, ref SKRect bounds) => GetFont ().MeasureText (buffer, (int)length, TextEncoding, out bounds, this); // BreakText - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (string text, float maxWidth) => GetFont ().BreakText (text, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (string text, float maxWidth, out float measuredWidth) => GetFont ().BreakText (text, maxWidth, out measuredWidth, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (string text, float maxWidth, out float measuredWidth, out string measuredText) { if (text == null) @@ -381,97 +380,97 @@ public long BreakText (string text, float maxWidth, out float measuredWidth, out return charsRead; } - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (ReadOnlySpan text, float maxWidth) => GetFont ().BreakText (text, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (ReadOnlySpan text, float maxWidth, out float measuredWidth) => GetFont ().BreakText (text, maxWidth, out measuredWidth, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (byte[] text, float maxWidth) => GetFont ().BreakText (text, TextEncoding, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (byte[] text, float maxWidth, out float measuredWidth) => GetFont ().BreakText (text, TextEncoding, maxWidth, out measuredWidth, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (ReadOnlySpan text, float maxWidth) => GetFont ().BreakText (text, TextEncoding, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (ReadOnlySpan text, float maxWidth, out float measuredWidth) => GetFont ().BreakText (text, TextEncoding, maxWidth, out measuredWidth, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (IntPtr buffer, int length, float maxWidth) => GetFont ().BreakText (buffer, length, TextEncoding, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (IntPtr buffer, int length, float maxWidth, out float measuredWidth) => GetFont ().BreakText (buffer, length, TextEncoding, maxWidth, out measuredWidth, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (IntPtr buffer, IntPtr length, float maxWidth) => GetFont ().BreakText (buffer, (int)length, TextEncoding, maxWidth, out _, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.BreakText)}() instead.", error: true)] public long BreakText (IntPtr buffer, IntPtr length, float maxWidth, out float measuredWidth) => GetFont ().BreakText (buffer, (int)length, TextEncoding, maxWidth, out measuredWidth, this); // GetTextPath - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (string text, float x, float y) => GetFont ().GetTextPath (text, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (ReadOnlySpan text, float x, float y) => GetFont ().GetTextPath (text, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (byte[] text, float x, float y) => GetFont ().GetTextPath (text, TextEncoding, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (ReadOnlySpan text, float x, float y) => GetFont ().GetTextPath (text, TextEncoding, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (IntPtr buffer, int length, float x, float y) => GetFont ().GetTextPath (buffer, length, TextEncoding, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (IntPtr buffer, IntPtr length, float x, float y) => GetFont ().GetTextPath (buffer, (int)length, TextEncoding, new SKPoint (x, y)); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (string text, SKPoint[] points) => GetFont ().GetTextPath (text, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (ReadOnlySpan text, ReadOnlySpan points) => GetFont ().GetTextPath (text, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (byte[] text, SKPoint[] points) => GetFont ().GetTextPath (text, TextEncoding, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (ReadOnlySpan text, ReadOnlySpan points) => GetFont ().GetTextPath (text, TextEncoding, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (IntPtr buffer, int length, SKPoint[] points) => GetFont ().GetTextPath (buffer, length, TextEncoding, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (IntPtr buffer, int length, ReadOnlySpan points) => GetFont ().GetTextPath (buffer, length, TextEncoding, points); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetTextPath)}() instead.", error: true)] public SKPath GetTextPath (IntPtr buffer, IntPtr length, SKPoint[] points) => GetFont ().GetTextPath (buffer, (int)length, TextEncoding, points); @@ -570,197 +569,197 @@ private bool GetFillPath (SKPath src, SKPathBuilder dst, SKRect* cullRect, SKMat // CountGlyphs - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (string text) => GetFont ().CountGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (ReadOnlySpan text) => GetFont ().CountGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (byte[] text) => GetFont ().CountGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (ReadOnlySpan text) => GetFont ().CountGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (IntPtr text, int length) => GetFont ().CountGlyphs (text, length, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.CountGlyphs)}() instead.", error: true)] public int CountGlyphs (IntPtr text, IntPtr length) => GetFont ().CountGlyphs (text, (int)length, TextEncoding); // GetGlyphs - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (string text) => GetFont ().GetGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (ReadOnlySpan text) => GetFont ().GetGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (byte[] text) => GetFont ().GetGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (ReadOnlySpan text) => GetFont ().GetGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (IntPtr text, int length) => GetFont ().GetGlyphs (text, length, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphs)}() instead.", error: true)] public ushort[] GetGlyphs (IntPtr text, IntPtr length) => GetFont ().GetGlyphs (text, (int)length, TextEncoding); // ContainsGlyphs - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (string text) => GetFont ().ContainsGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (ReadOnlySpan text) => GetFont ().ContainsGlyphs (text); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (byte[] text) => GetFont ().ContainsGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (ReadOnlySpan text) => GetFont ().ContainsGlyphs (text, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (IntPtr text, int length) => GetFont ().ContainsGlyphs (text, length, TextEncoding); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.ContainsGlyphs)}() instead.", error: true)] public bool ContainsGlyphs (IntPtr text, IntPtr length) => GetFont ().ContainsGlyphs (text, (int)length, TextEncoding); // GetGlyphPositions - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.", error: true)] public SKPoint[] GetGlyphPositions (string text, SKPoint origin = default) => GetFont ().GetGlyphPositions (text, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.", error: true)] public SKPoint[] GetGlyphPositions (ReadOnlySpan text, SKPoint origin = default) => GetFont ().GetGlyphPositions (text, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.", error: true)] public SKPoint[] GetGlyphPositions (ReadOnlySpan text, SKPoint origin = default) => GetFont ().GetGlyphPositions (text, TextEncoding, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphPositions)}() instead.", error: true)] public SKPoint[] GetGlyphPositions (IntPtr text, int length, SKPoint origin = default) => GetFont ().GetGlyphPositions (text, length, TextEncoding, origin); // GetGlyphOffsets - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.", error: true)] public float[] GetGlyphOffsets (string text, float origin = 0f) => GetFont ().GetGlyphOffsets (text, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.", error: true)] public float[] GetGlyphOffsets (ReadOnlySpan text, float origin = 0f) => GetFont ().GetGlyphOffsets (text, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.", error: true)] public float[] GetGlyphOffsets (ReadOnlySpan text, float origin = 0f) => GetFont ().GetGlyphOffsets (text, TextEncoding, origin); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphOffsets)}() instead.", error: true)] public float[] GetGlyphOffsets (IntPtr text, int length, float origin = 0f) => GetFont ().GetGlyphOffsets (text, length, TextEncoding, origin); // GetGlyphWidths - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (string text) => GetFont ().GetGlyphWidths (text, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (ReadOnlySpan text) => GetFont ().GetGlyphWidths (text, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (byte[] text) => GetFont ().GetGlyphWidths (text, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (ReadOnlySpan text) => GetFont ().GetGlyphWidths (text, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (IntPtr text, int length) => GetFont ().GetGlyphWidths (text, length, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (IntPtr text, IntPtr length) => GetFont ().GetGlyphWidths (text, (int)length, TextEncoding, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (string text, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (ReadOnlySpan text, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (byte[] text, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (ReadOnlySpan text, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (IntPtr text, int length, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, length, TextEncoding, out bounds, this); - [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.")] + [Obsolete ($"Use {nameof (SKFont)}.{nameof (SKFont.GetGlyphWidths)}() instead.", error: true)] public float[] GetGlyphWidths (IntPtr text, IntPtr length, out SKRect[] bounds) => GetFont ().GetGlyphWidths (text, (int)length, TextEncoding, out bounds, this); // GetTextIntercepts - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (string text, float x, float y, float upperBounds, float lowerBounds) => GetTextIntercepts (text.AsSpan (), x, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (ReadOnlySpan text, float x, float y, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.Create (text, GetFont (), new SKPoint (x, y)); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (byte[] text, float x, float y, float upperBounds, float lowerBounds) => GetTextIntercepts (text.AsSpan (), x, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (ReadOnlySpan text, float x, float y, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.Create (text, TextEncoding, GetFont (), new SKPoint (x, y)); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (IntPtr text, IntPtr length, float x, float y, float upperBounds, float lowerBounds) => GetTextIntercepts (text, (int)length, x, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (IntPtr text, int length, float x, float y, float upperBounds, float lowerBounds) { if (text == IntPtr.Zero && length != 0) @@ -772,7 +771,7 @@ public float[] GetTextIntercepts (IntPtr text, int length, float x, float y, flo // GetTextIntercepts (SKTextBlob) - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetTextIntercepts (SKTextBlob text, float upperBounds, float lowerBounds) { if (text == null) @@ -783,33 +782,33 @@ public float[] GetTextIntercepts (SKTextBlob text, float upperBounds, float lowe // GetPositionedTextIntercepts - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (string text, SKPoint[] positions, float upperBounds, float lowerBounds) => GetPositionedTextIntercepts (text.AsSpan (), positions, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (ReadOnlySpan text, ReadOnlySpan positions, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.CreatePositioned (text, GetFont (), positions); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (byte[] text, SKPoint[] positions, float upperBounds, float lowerBounds) => GetPositionedTextIntercepts (text.AsSpan (), positions, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (ReadOnlySpan text, ReadOnlySpan positions, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.CreatePositioned (text, TextEncoding, GetFont (), positions); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (IntPtr text, int length, SKPoint[] positions, float upperBounds, float lowerBounds) => GetPositionedTextIntercepts (text, (IntPtr)length, positions, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetPositionedTextIntercepts (IntPtr text, IntPtr length, SKPoint[] positions, float upperBounds, float lowerBounds) { if (text == IntPtr.Zero && length != IntPtr.Zero) @@ -821,33 +820,33 @@ public float[] GetPositionedTextIntercepts (IntPtr text, IntPtr length, SKPoint[ // GetHorizontalTextIntercepts - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (string text, float[] xpositions, float y, float upperBounds, float lowerBounds) => GetHorizontalTextIntercepts (text.AsSpan (), xpositions, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (ReadOnlySpan text, ReadOnlySpan xpositions, float y, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.CreateHorizontal (text, GetFont (), xpositions, y); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (byte[] text, float[] xpositions, float y, float upperBounds, float lowerBounds) => GetHorizontalTextIntercepts (text.AsSpan (), xpositions, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (ReadOnlySpan text, ReadOnlySpan xpositions, float y, float upperBounds, float lowerBounds) { using var blob = SKTextBlob.CreateHorizontal (text, TextEncoding, GetFont (), xpositions, y); return blob.GetIntercepts (upperBounds, lowerBounds, this); } - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (IntPtr text, int length, float[] xpositions, float y, float upperBounds, float lowerBounds) => GetHorizontalTextIntercepts (text, (IntPtr)length, xpositions, y, upperBounds, lowerBounds); - [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.")] + [Obsolete ($"Use {nameof (SKTextBlob)}.{nameof (SKTextBlob.GetIntercepts)}() instead.", error: true)] public float[] GetHorizontalTextIntercepts (IntPtr text, IntPtr length, float[] xpositions, float y, float upperBounds, float lowerBounds) { if (text == IntPtr.Zero && length != IntPtr.Zero) @@ -859,14 +858,43 @@ public float[] GetHorizontalTextIntercepts (IntPtr text, IntPtr length, float[] // Font - [Obsolete ($"Use {nameof (SKFont)} instead.")] + [Obsolete ($"Use {nameof (SKFont)} instead.", error: true)] public SKFont ToFont () => SKFont.GetObject (SkiaApi.sk_compatpaint_make_font (Handle)); - [Obsolete ($"Use {nameof (SKFont)} instead.")] + [Obsolete ($"Use {nameof (SKFont)} instead.", error: true)] internal SKFont GetFont () => font ??= OwnedBy (SKFont.GetObject (SkiaApi.sk_compatpaint_get_font (Handle), false), this); + // Internal compat-paint bypass helpers used by the non-obsolete public APIs + // in SKCanvas (DrawImage/DrawAtlas/DrawText) and SkiaSharp.HarfBuzz that + // still respect the legacy paint.FilterQuality / paint.TextAlign / + // paint.TextEncoding / paint.GetFont state. These mirror the obsolete + // properties but avoid the CS0619 compile error and ref-assembly stripping + // when called from a non-obsolete context. Exposed to SkiaSharp.HarfBuzz + // via InternalsVisibleTo. Remove together with SkCompatPaint in Phase 2 + // of #3732. + internal SKTextAlign GetLegacyTextAlign () => + SkiaApi.sk_compatpaint_get_text_align (Handle); + + internal SKTextEncoding GetLegacyTextEncoding () => + SkiaApi.sk_compatpaint_get_text_encoding (Handle); + + internal SKFont GetLegacyFont () => + font ??= OwnedBy (SKFont.GetObject (SkiaApi.sk_compatpaint_get_font (Handle), false), this); + + internal SKSamplingOptions GetLegacyFilterQualitySampling () + { + var quality = SkiaApi.sk_compatpaint_get_filter_quality (Handle); + return quality switch { + 0 => new SKSamplingOptions (SKFilterMode.Nearest, SKMipmapMode.None), + 1 => new SKSamplingOptions (SKFilterMode.Linear, SKMipmapMode.None), + 2 => new SKSamplingOptions (SKFilterMode.Linear, SKMipmapMode.Linear), + 3 => new SKSamplingOptions (SKCubicResampler.Mitchell), + _ => throw new ArgumentOutOfRangeException (nameof (quality), $"Unknown filter quality: '{quality}'"), + }; + } + // internal static SKPaint GetObject (IntPtr handle) => diff --git a/binding/SkiaSharp/SKPixmap.cs b/binding/SkiaSharp/SKPixmap.cs index 19df483f730..7ec88b841ec 100644 --- a/binding/SkiaSharp/SKPixmap.cs +++ b/binding/SkiaSharp/SKPixmap.cs @@ -156,10 +156,10 @@ public unsafe Span GetPixelSpan (int x, int y) if (bpp != size) throw new ArgumentException ($"Size of T ({size}) is not the same as the size of each pixel ({bpp}).", nameof (T)); - spanLength = info.Width * info.Height; + spanLength = checked(info.Width * info.Height); if (x != 0 || y != 0) - spanOffset = y * info.Height + x; + spanOffset = checked(y * info.Height + x); } var addr = SkiaApi.sk_pixmap_get_writable_addr (Handle); @@ -186,7 +186,7 @@ public float GetPixelAlpha (int x, int y) => // ScalePixels - [Obsolete ("Use ScalePixels(SKPixmap destination, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use ScalePixels(SKPixmap destination, SKSamplingOptions sampling) instead.", error: true)] public bool ScalePixels (SKPixmap destination, SKFilterQuality quality) => ScalePixels (destination, quality.ToSamplingOptions ()); diff --git a/binding/SkiaSharp/SKShader.cs b/binding/SkiaSharp/SKShader.cs index 8f1e9cb6cb9..93b676c0bc6 100644 --- a/binding/SkiaSharp/SKShader.cs +++ b/binding/SkiaSharp/SKShader.cs @@ -80,7 +80,7 @@ public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderT public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) => src?.ToShader (tmx, tmy, sampling) ?? throw new ArgumentNullException (nameof (src)); - [Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.")] + [Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.", error: true)] public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality) => src?.ToShader (tmx, tmy, quality.ToSamplingOptions()) ?? throw new ArgumentNullException (nameof (src)); @@ -90,7 +90,7 @@ public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderT public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) => src?.ToShader (tmx, tmy, sampling, localMatrix) ?? throw new ArgumentNullException (nameof (src)); - [Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")] + [Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.", error: true)] public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality, SKMatrix localMatrix) => src?.ToShader (tmx, tmy, quality.ToSamplingOptions(), localMatrix) ?? throw new ArgumentNullException (nameof (src)); diff --git a/samples/Gallery/Shared/Samples/AnimatedWebpEncoderSample.cs b/samples/Gallery/Shared/Samples/AnimatedWebpEncoderSample.cs index 0e69ddcd83e..c0d4c20c0d0 100644 --- a/samples/Gallery/Shared/Samples/AnimatedWebpEncoderSample.cs +++ b/samples/Gallery/Shared/Samples/AnimatedWebpEncoderSample.cs @@ -209,10 +209,10 @@ private static void DrawAnimationFrame( IsAntialias = true, MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, 6), }; - canvas.DrawText(ch, x, y, font, glowPaint); + canvas.DrawText(ch, x, y, SKTextAlign.Left, font, glowPaint); // letter - canvas.DrawText(ch, x, y, font, textPaint); + canvas.DrawText(ch, x, y, SKTextAlign.Left, font, textPaint); x += charW; } } diff --git a/samples/Gallery/Shared/Samples/CanvasTransformsSample.cs b/samples/Gallery/Shared/Samples/CanvasTransformsSample.cs index 5d43ce8612c..2bd762fdc5e 100644 --- a/samples/Gallery/Shared/Samples/CanvasTransformsSample.cs +++ b/samples/Gallery/Shared/Samples/CanvasTransformsSample.cs @@ -180,7 +180,7 @@ private void DrawMatrixInfo(SKCanvas canvas) using var font = new SKFont(SKTypeface.Default, 14); using var headerFont = new SKFont(SKTypeface.Default, 13); - canvas.DrawText("Transform Matrix:", 10, 22, headerFont, textPaint); + canvas.DrawText("Transform Matrix:", 10, 22, SKTextAlign.Left, headerFont, textPaint); var vals = new[] { @@ -194,7 +194,7 @@ private void DrawMatrixInfo(SKCanvas canvas) for (var row = 0; row < 3; row++) { var line = $"│ {vals[row * 3],8:F2} {vals[row * 3 + 1],8:F2} {vals[row * 3 + 2],8:F2} │"; - canvas.DrawText(line, 12, startY + row * lineH, font, textPaint); + canvas.DrawText(line, 12, startY + row * lineH, SKTextAlign.Left, font, textPaint); } } } diff --git a/samples/Gallery/Shared/Samples/ColorFontSample.cs b/samples/Gallery/Shared/Samples/ColorFontSample.cs index ad053c131ff..40fa39e85aa 100644 --- a/samples/Gallery/Shared/Samples/ColorFontSample.cs +++ b/samples/Gallery/Shared/Samples/ColorFontSample.cs @@ -79,7 +79,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) // Draw the sample text centered font.MeasureText(text, out var bounds, paint); -canvas.DrawText(text, x - bounds.MidX, y, font, paint); +canvas.DrawText(text, x - bounds.MidX, y, SKTextAlign.Left, font, paint); // Draw palette info below using var infoFont = new SKFont(SKTypeface.Default, 14); @@ -87,7 +87,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) var info = $"Palette {paletteIndex + 1} of {paletteCount}"; infoFont.MeasureText(info, out var infoBounds, infoPaint); -canvas.DrawText(info, x - infoBounds.MidX, height * 0.45f, infoFont, infoPaint); +canvas.DrawText(info, x - infoBounds.MidX, height * 0.45f, SKTextAlign.Left, infoFont, infoPaint); // Draw palette spectrum at the bottom DrawPaletteSpectrum(canvas, width, height); @@ -119,14 +119,14 @@ private void DrawPaletteSpectrum(SKCanvas canvas, int width, int height) using var pFont = new SKFont(pTypeface, spectrumSize); pFont.MeasureText(spectrumText, out var b, paint); -canvas.DrawText(spectrumText, cx - b.MidX, cy, pFont, paint); +canvas.DrawText(spectrumText, cx - b.MidX, cy, SKTextAlign.Left, pFont, paint); var label = $"{i + 1}"; labelFont.MeasureText(label, out var lb, labelPaint); using var namePaint = i == paletteIndex ? new SKPaint { Color = SKColors.Black, IsAntialias = true } : new SKPaint { Color = new SKColor(0xAA, 0xAA, 0xAA), IsAntialias = true }; -canvas.DrawText(label, cx - lb.MidX, cy + b.Height + 16, labelFont, namePaint); +canvas.DrawText(label, cx - lb.MidX, cy + b.Height + 16, SKTextAlign.Left, labelFont, namePaint); } } diff --git a/samples/Gallery/Shared/Samples/GifPlayerSample.cs b/samples/Gallery/Shared/Samples/GifPlayerSample.cs index 5bae4d0a7d7..c268e8d3128 100644 --- a/samples/Gallery/Shared/Samples/GifPlayerSample.cs +++ b/samples/Gallery/Shared/Samples/GifPlayerSample.cs @@ -128,6 +128,6 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) using var textPaint = new SKPaint { IsAntialias = true, Color = SKColors.White }; using var font = new SKFont(SampleMedia.Fonts.Default, 14); var statusText = playing ? "▶" : "⏸"; - canvas.DrawText($"{statusText} Frame {currentFrame + 1}/{frames.Length} Speed: {speed:F2}x", 10, height - 10, font, textPaint); + canvas.DrawText($"{statusText} Frame {currentFrame + 1}/{frames.Length} Speed: {speed:F2}x", 10, height - 10, SKTextAlign.Left, font, textPaint); } } diff --git a/samples/Gallery/Shared/Samples/HeroImageSample.cs b/samples/Gallery/Shared/Samples/HeroImageSample.cs index 155312f7c77..7addda80ac4 100644 --- a/samples/Gallery/Shared/Samples/HeroImageSample.cs +++ b/samples/Gallery/Shared/Samples/HeroImageSample.cs @@ -274,7 +274,7 @@ private void DrawText(SKCanvas canvas, int width, int height, SKRect logoCard) Shader = titleShader, IsAntialias = true, }; - canvas.DrawText(titleText, titleX, titleY, titleFont, titlePaint); + canvas.DrawText(titleText, titleX, titleY, SKTextAlign.Left, titleFont, titlePaint); } private static void DrawFrostedCard(SKCanvas canvas, SKImage bgSnapshot, SKRect cardRect) diff --git a/samples/Gallery/Shared/Samples/ImageDecoderSample.cs b/samples/Gallery/Shared/Samples/ImageDecoderSample.cs index 8347e7f5858..db619fdeef0 100644 --- a/samples/Gallery/Shared/Samples/ImageDecoderSample.cs +++ b/samples/Gallery/Shared/Samples/ImageDecoderSample.cs @@ -213,7 +213,7 @@ private static void DrawMetadata(SKCanvas canvas, int width, int height, SKCodec var y = boxTop + padding + fontSize; foreach (var line in lines) { - canvas.DrawText(line, boxLeft + padding, y, font, textPaint); + canvas.DrawText(line, boxLeft + padding, y, SKTextAlign.Left, font, textPaint); y += lineHeight; } } diff --git a/samples/Gallery/Shared/Samples/PathEffectsSamplerSample.cs b/samples/Gallery/Shared/Samples/PathEffectsSamplerSample.cs index 2a2a190b2ea..32a7936138d 100644 --- a/samples/Gallery/Shared/Samples/PathEffectsSamplerSample.cs +++ b/samples/Gallery/Shared/Samples/PathEffectsSamplerSample.cs @@ -95,7 +95,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) using (var labelPaint = new SKPaint { Color = new SKColor(0xFF555555), IsAntialias = true }) { var labelW = labelFont.MeasureText(effects[i].Name); - canvas.DrawText(effects[i].Name, cx - labelW / 2f, row * cellH + 22, labelFont, labelPaint); + canvas.DrawText(effects[i].Name, cx - labelW / 2f, row * cellH + 22, SKTextAlign.Left, labelFont, labelPaint); } // Create the base path diff --git a/samples/Gallery/Shared/Samples/PdfComposerSample.cs b/samples/Gallery/Shared/Samples/PdfComposerSample.cs index 12ee7606594..f2167c2488d 100644 --- a/samples/Gallery/Shared/Samples/PdfComposerSample.cs +++ b/samples/Gallery/Shared/Samples/PdfComposerSample.cs @@ -145,7 +145,7 @@ private static void DrawBackToTocLink(SKCanvas canvas, float pageWidth, float pa var textWidth = font.MeasureText(text); var x = (pageWidth - textWidth) / 2; var y = pageHeight - 40; - canvas.DrawText(text, x, y, font, paint); + canvas.DrawText(text, x, y, SKTextAlign.Left, font, paint); using var underline = new SKPaint { IsAntialias = true, Color = LinkColor, StrokeWidth = 0.5f, IsStroke = true }; canvas.DrawLine(x, y + 2, x + textWidth, y + 2, underline); @@ -204,7 +204,7 @@ private static void DrawCoverPage(SKCanvas canvas, float pageWidth, float pageHe var x = 100f; foreach (var (text, dest) in entries) { - canvas.DrawText(text, x, y, tocFont, tocPaint); + canvas.DrawText(text, x, y, SKTextAlign.Left, tocFont, tocPaint); var tw = tocFont.MeasureText(text); canvas.DrawLine(x, y + 2, x + tw, y + 2, tocUnderline); canvas.DrawLinkDestinationAnnotation(new SKRect(x, y - 16, x + tw, y + 4), dest)?.Dispose(); @@ -218,7 +218,7 @@ private static void DrawCoverPage(SKCanvas canvas, float pageWidth, float pageHe var urlW = footerFont.MeasureText(url); var urlX = (pageWidth - urlW) / 2; var urlY = pageHeight - 50; - canvas.DrawText(url, urlX, urlY, footerFont, footerPaint); + canvas.DrawText(url, urlX, urlY, SKTextAlign.Left, footerFont, footerPaint); canvas.DrawUrlAnnotation(new SKRect(urlX, urlY - 12, urlX + urlW, urlY + 4), url)?.Dispose(); } @@ -313,22 +313,22 @@ private static void DrawTextPage(SKCanvas canvas, float pageWidth, float pageHei using var bodyPaint = new SKPaint { IsAntialias = true, Color = BodyColor }; // Different sizes - canvas.DrawText("Text Sizes", margin, y, sectionFont, sectionPaint); + canvas.DrawText("Text Sizes", margin, y, SKTextAlign.Left, sectionFont, sectionPaint); y += 10; foreach (var size in new[] { 12, 24, 36, 48 }) { using var sizedFont = new SKFont(SampleMedia.Fonts.Default, size); y += size + 8; - canvas.DrawText($"{size}pt Sample Text", margin, y, sizedFont, bodyPaint); + canvas.DrawText($"{size}pt Sample Text", margin, y, SKTextAlign.Left, sizedFont, bodyPaint); } y += 40; // Text styles - canvas.DrawText("Text Styles", margin, y, sectionFont, sectionPaint); + canvas.DrawText("Text Styles", margin, y, SKTextAlign.Left, sectionFont, sectionPaint); y += 30; using var styleFont = new SKFont(SampleMedia.Fonts.Default, 20); - canvas.DrawText("Normal text style", margin, y, styleFont, bodyPaint); + canvas.DrawText("Normal text style", margin, y, SKTextAlign.Left, styleFont, bodyPaint); y += 30; using var boldPaint = new SKPaint @@ -338,22 +338,22 @@ private static void DrawTextPage(SKCanvas canvas, float pageWidth, float pageHei Style = SKPaintStyle.StrokeAndFill, StrokeWidth = 1.0f, }; - canvas.DrawText("Bold text style (stroke)", margin, y, styleFont, boldPaint); + canvas.DrawText("Bold text style (stroke)", margin, y, SKTextAlign.Left, styleFont, boldPaint); y += 30; using var italicFont = new SKFont(SampleMedia.Fonts.Default, 20, 1, -0.25f); - canvas.DrawText("Italic text style (skew)", margin, y, italicFont, bodyPaint); + canvas.DrawText("Italic text style (skew)", margin, y, SKTextAlign.Left, italicFont, bodyPaint); y += 50; // Alignment - canvas.DrawText("Text Alignment", margin, y, sectionFont, sectionPaint); + canvas.DrawText("Text Alignment", margin, y, SKTextAlign.Left, sectionFont, sectionPaint); y += 30; using var alignFont = new SKFont(SampleMedia.Fonts.Default, 16); using var guidePaint = new SKPaint { IsAntialias = true, Color = LightGray, StrokeWidth = 1, IsStroke = true }; canvas.DrawLine(pageWidth / 2, y - 16, pageWidth / 2, y + 60, guidePaint); - canvas.DrawText("Left-aligned text", margin, y, alignFont, bodyPaint); + canvas.DrawText("Left-aligned text", margin, y, SKTextAlign.Left, alignFont, bodyPaint); y += 24; canvas.DrawText("Center-aligned text", pageWidth / 2, y, SKTextAlign.Center, alignFont, bodyPaint); y += 24; @@ -376,7 +376,7 @@ private static void DrawImagesPage(SKCanvas canvas, float pageWidth, float pageH // Description using var descFont = new SKFont(SampleMedia.Fonts.Default, 13); using var descPaint = new SKPaint { IsAntialias = true, Color = BodyColor }; - canvas.DrawText("SkiaSharp can decode and embed bitmap images in PDF documents.", margin, y, descFont, descPaint); + canvas.DrawText("SkiaSharp can decode and embed bitmap images in PDF documents.", margin, y, SKTextAlign.Left, descFont, descPaint); y += 30; // Load and draw baboon image @@ -393,7 +393,7 @@ private static void DrawImagesPage(SKCanvas canvas, float pageWidth, float pageH // Label using var labelFont = new SKFont(SampleMedia.Fonts.Default, 11); using var labelPaint = new SKPaint { IsAntialias = true, Color = SubtitleColor }; - canvas.DrawText($"baboon.png ({baboonBitmap.Width}×{baboonBitmap.Height})", margin, y + imgSize + 16, labelFont, labelPaint); + canvas.DrawText($"baboon.png ({baboonBitmap.Width}×{baboonBitmap.Height})", margin, y + imgSize + 16, SKTextAlign.Left, labelFont, labelPaint); // Draw the same image with effects on the right side var rightX = margin + imgSize + 30; @@ -409,7 +409,7 @@ private static void DrawImagesPage(SKCanvas canvas, float pageWidth, float pageH }); using var grayPaint = new SKPaint { ColorFilter = grayFilter }; canvas.DrawBitmap(baboonBitmap, SKRect.Create(rightX, y, smallSize, smallSize), grayPaint); - canvas.DrawText("Grayscale filter", rightX, y + smallSize + 16, labelFont, labelPaint); + canvas.DrawText("Grayscale filter", rightX, y + smallSize + 16, SKTextAlign.Left, labelFont, labelPaint); // Sepia version using var sepiaFilter = SKColorFilter.CreateColorMatrix(new float[] @@ -421,7 +421,7 @@ private static void DrawImagesPage(SKCanvas canvas, float pageWidth, float pageH }); using var sepiaPaint = new SKPaint { ColorFilter = sepiaFilter }; canvas.DrawBitmap(baboonBitmap, SKRect.Create(rightX, y + smallSize + 30, smallSize, smallSize), sepiaPaint); - canvas.DrawText("Sepia filter", rightX, y + smallSize * 2 + 46, labelFont, labelPaint); + canvas.DrawText("Sepia filter", rightX, y + smallSize * 2 + 46, SKTextAlign.Left, labelFont, labelPaint); y += imgSize + 40; } @@ -439,7 +439,7 @@ private static void DrawImagesPage(SKCanvas canvas, float pageWidth, float pageH using var cwLabel = new SKFont(SampleMedia.Fonts.Default, 11); using var cwPaint = new SKPaint { IsAntialias = true, Color = SubtitleColor }; - canvas.DrawText($"color-wheel.png ({cwBitmap.Width}×{cwBitmap.Height})", margin, y + cwSize + 16, cwLabel, cwPaint); + canvas.DrawText($"color-wheel.png ({cwBitmap.Width}×{cwBitmap.Height})", margin, y + cwSize + 16, SKTextAlign.Left, cwLabel, cwPaint); } } diff --git a/samples/Gallery/Shared/Samples/PerlinNoiseTexturesSample.cs b/samples/Gallery/Shared/Samples/PerlinNoiseTexturesSample.cs index 1a6138a1df7..73290b19d4b 100644 --- a/samples/Gallery/Shared/Samples/PerlinNoiseTexturesSample.cs +++ b/samples/Gallery/Shared/Samples/PerlinNoiseTexturesSample.cs @@ -112,8 +112,8 @@ private void DrawRawComparison(SKCanvas canvas, int width, int height, int numOc var turbLabel = "Turbulence"; var flw = labelFont.MeasureText(fractalLabel); var tlw = labelFont.MeasureText(turbLabel); - canvas.DrawText(fractalLabel, halfW / 2f - flw / 2f, 21, labelFont, labelPaint); - canvas.DrawText(turbLabel, halfW + halfW / 2f - tlw / 2f, 21, labelFont, labelPaint); + canvas.DrawText(fractalLabel, halfW / 2f - flw / 2f, 21, SKTextAlign.Left, labelFont, labelPaint); + canvas.DrawText(turbLabel, halfW + halfW / 2f - tlw / 2f, 21, SKTextAlign.Left, labelFont, labelPaint); } private void DrawTexturePreset(SKCanvas canvas, int width, int height, int numOctaves) @@ -138,7 +138,7 @@ private void DrawTexturePreset(SKCanvas canvas, int width, int height, int numOc using var labelFont = new SKFont { Size = 14 }; using var labelPaint = new SKPaint { Color = SKColors.White, IsAntialias = true }; - canvas.DrawText(Presets[presetIndex], 16, 28, labelFont, labelPaint); + canvas.DrawText(Presets[presetIndex], 16, 28, SKTextAlign.Left, labelFont, labelPaint); } private SKColorFilter? CreatePresetColorFilter() diff --git a/samples/Gallery/Shared/Samples/ShaderCrossFadeSample.cs b/samples/Gallery/Shared/Samples/ShaderCrossFadeSample.cs index 736919f6019..e703d8ebe05 100644 --- a/samples/Gallery/Shared/Samples/ShaderCrossFadeSample.cs +++ b/samples/Gallery/Shared/Samples/ShaderCrossFadeSample.cs @@ -212,13 +212,13 @@ private void DrawOverlay(SKCanvas canvas, int width, int height) using var font = new SKFont { Size = 15 }; using var paint = new SKPaint { Color = SKColors.White, IsAntialias = true }; - canvas.DrawText("Runtime Shader Threshold Cross-Fade", 12, 20, font, paint); + canvas.DrawText("Runtime Shader Threshold Cross-Fade", 12, 20, SKTextAlign.Left, font, paint); using var smallFont = new SKFont { Size = 12 }; paint.Color = new SKColor(200, 200, 200); canvas.DrawText( $"threshold: {threshold:F2} noise: {noiseScale:F1} softness: {edgeSoftness:F2}", - 12, 42, smallFont, paint); + 12, 42, SKTextAlign.Left, smallFont, paint); } private void DrawError(SKCanvas canvas, int width) diff --git a/samples/Gallery/Shared/Samples/SmartTextUnderlineSample.cs b/samples/Gallery/Shared/Samples/SmartTextUnderlineSample.cs index d50f65fae34..bcc931c552e 100644 --- a/samples/Gallery/Shared/Samples/SmartTextUnderlineSample.cs +++ b/samples/Gallery/Shared/Samples/SmartTextUnderlineSample.cs @@ -96,7 +96,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) DrawLabel(canvas, "Naïve underline (no descender gaps):", 12, baseY - textSize * 0.8f, bgColor); using var naiveTextPaint = new SKPaint { Color = textColor, IsAntialias = true }; - canvas.DrawText(text, x, baseY, font, naiveTextPaint); + canvas.DrawText(text, x, baseY, SKTextAlign.Left, font, naiveTextPaint); var naiveUnderlineY = baseY + underlineOffset; using var naiveLinePaint = new SKPaint @@ -115,7 +115,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) DrawLabel(canvas, "Smart underline (gaps around descenders):", 12, smartY - textSize * 0.8f, bgColor); using var textPaint = new SKPaint { Color = textColor, IsAntialias = true }; - canvas.DrawText(text, x, smartY, font, textPaint); + canvas.DrawText(text, x, smartY, SKTextAlign.Left, font, textPaint); // Build a text blob so we can use GetIntercepts using var blob = SKTextBlob.Create(text, font, new SKPoint(x, smartY)); @@ -183,7 +183,7 @@ private static void DrawLabel(SKCanvas canvas, string text, float x, float y, SK Color = isDark ? new SKColor(180, 180, 180) : new SKColor(100, 100, 100), IsAntialias = true, }; - canvas.DrawText(text, x, y, labelFont, labelPaint); + canvas.DrawText(text, x, y, SKTextAlign.Left, labelFont, labelPaint); } private static void DrawFooter(SKCanvas canvas, int width, int height, int gapCount, SKColor bg) @@ -197,6 +197,6 @@ private static void DrawFooter(SKCanvas canvas, int width, int height, int gapCo }; var info = $"GetIntercepts() found {gapCount} descender crossing{(gapCount != 1 ? "s" : "")}"; var tw = footerFont.MeasureText(info); - canvas.DrawText(info, (width - tw) / 2f, height - 16, footerFont, footerPaint); + canvas.DrawText(info, (width - tw) / 2f, height - 16, SKTextAlign.Left, footerFont, footerPaint); } } diff --git a/samples/Gallery/Shared/Samples/TextLabSample.cs b/samples/Gallery/Shared/Samples/TextLabSample.cs index e5d4c500151..0ff3db834fb 100644 --- a/samples/Gallery/Shared/Samples/TextLabSample.cs +++ b/samples/Gallery/Shared/Samples/TextLabSample.cs @@ -179,11 +179,11 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) IsAntialias = true, }; labelPaint.Color = SKColors.Blue; - canvas.DrawText("baseline", 4, y - 4, labelFont, labelPaint); + canvas.DrawText("baseline", 4, y - 4, SKTextAlign.Left, labelFont, labelPaint); labelPaint.Color = SKColors.Green; - canvas.DrawText("ascent", 4, y + metrics.Ascent - 4, labelFont, labelPaint); + canvas.DrawText("ascent", 4, y + metrics.Ascent - 4, SKTextAlign.Left, labelFont, labelPaint); labelPaint.Color = SKColors.Orange; - canvas.DrawText("descent", 4, y + metrics.Descent - 4, labelFont, labelPaint); + canvas.DrawText("descent", 4, y + metrics.Descent - 4, SKTextAlign.Left, labelFont, labelPaint); } } diff --git a/samples/Gallery/Shared/Samples/TextOnPathSample.cs b/samples/Gallery/Shared/Samples/TextOnPathSample.cs index 8a16b5bc477..6840d3735a9 100644 --- a/samples/Gallery/Shared/Samples/TextOnPathSample.cs +++ b/samples/Gallery/Shared/Samples/TextOnPathSample.cs @@ -107,7 +107,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) // Draw labels using var labelPaint = new SKPaint { IsAntialias = true, Color = SKColors.White }; using var labelFont = new SKFont(SKTypeface.Default, 14); - canvas.DrawText($"Shape: {PathShapes[pathShapeIndex]} Warp: {(warpGlyphs ? "on" : "off")} Offset: {textOffset:F2}", 10, 20, labelFont, labelPaint); + canvas.DrawText($"Shape: {PathShapes[pathShapeIndex]} Warp: {(warpGlyphs ? "on" : "off")} Offset: {textOffset:F2}", 10, 20, SKTextAlign.Left, labelFont, labelPaint); } private static SKPath CreateCirclePath(float cx, float cy, float radius) diff --git a/samples/Gallery/Shared/Samples/TextToPathSample.cs b/samples/Gallery/Shared/Samples/TextToPathSample.cs index 72d7706d3c9..054f2e3a929 100644 --- a/samples/Gallery/Shared/Samples/TextToPathSample.cs +++ b/samples/Gallery/Shared/Samples/TextToPathSample.cs @@ -106,7 +106,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) Color = SKColors.Black.WithAlpha(40), IsAntialias = true, }; - canvas.DrawText(text, x, y, font, textPaint); + canvas.DrawText(text, x, y, SKTextAlign.Left, font, textPaint); } // Draw the glyph outlines (the raw text path) @@ -163,7 +163,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) IsAntialias = true, }; var info = $"Path points: {textPath.PointCount} Text size: {textSize:F0} Stroke: {strokeWidth:F1}"; - canvas.DrawText(info, 12, height - 12, infoFont, infoPaint); + canvas.DrawText(info, 12, height - 12, SKTextAlign.Left, infoFont, infoPaint); } protected override System.Threading.Tasks.Task OnInit() diff --git a/samples/Gallery/Shared/Samples/ThreeDSample.cs b/samples/Gallery/Shared/Samples/ThreeDSample.cs index 5496a4e75ab..a90bf5978b5 100644 --- a/samples/Gallery/Shared/Samples/ThreeDSample.cs +++ b/samples/Gallery/Shared/Samples/ThreeDSample.cs @@ -210,13 +210,13 @@ private static void DrawAxes(SKCanvas canvas, float axisLength) axisPaint.Color = new SKColor(239, 68, 68); canvas.DrawLine(0, 0, axisLength, 0, axisPaint); textPaint.Color = axisPaint.Color; - canvas.DrawText("X", axisLength + 5, 5, font, textPaint); + canvas.DrawText("X", axisLength + 5, 5, SKTextAlign.Left, font, textPaint); // Y axis (green) — draw along +Y axisPaint.Color = new SKColor(34, 197, 94); canvas.DrawLine(0, 0, 0, axisLength, axisPaint); textPaint.Color = axisPaint.Color; - canvas.DrawText("Y", 5, axisLength + 15, font, textPaint); + canvas.DrawText("Y", 5, axisLength + 15, SKTextAlign.Left, font, textPaint); } private void DrawMatrixInfo(SKCanvas canvas, SKMatrix44 rotation) @@ -235,7 +235,7 @@ private void DrawMatrixInfo(SKCanvas canvas, SKMatrix44 rotation) using var font = new SKFont(SKTypeface.Default, 11); using var headerFont = new SKFont(SKTypeface.Default, 11); - canvas.DrawText("4×4 Transform Matrix:", 14, 22, headerFont, textPaint); + canvas.DrawText("4×4 Transform Matrix:", 14, 22, SKTextAlign.Left, headerFont, textPaint); textPaint.Color = new SKColor(180, 180, 180); var startY = 38f; @@ -243,7 +243,7 @@ private void DrawMatrixInfo(SKCanvas canvas, SKMatrix44 rotation) for (var row = 0; row < 4; row++) { var line = $"│ {rotation[row, 0],7:F3} {rotation[row, 1],7:F3} {rotation[row, 2],7:F3} {rotation[row, 3],7:F3} │"; - canvas.DrawText(line, 14, startY + row * lineH, font, textPaint); + canvas.DrawText(line, 14, startY + row * lineH, SKTextAlign.Left, font, textPaint); } textPaint.Color = new SKColor(120, 120, 120); @@ -251,6 +251,6 @@ private void DrawMatrixInfo(SKCanvas canvas, SKMatrix44 rotation) var info = $"X:{rotateX:F1}° Y:{rotateY:F1}° Z:{rotateZ:F1}° S:{scale:F1} Z:{translateZ:F0} {Projections[projectionIndex]}"; if (projectionIndex == 1) info += $" d:{perspDepth:F0}"; - canvas.DrawText(info, 14, startY + 4 * lineH + 4, font, textPaint); + canvas.DrawText(info, 14, startY + 4 * lineH + 4, SKTextAlign.Left, font, textPaint); } } diff --git a/samples/Gallery/Shared/Samples/VariableFontSample.cs b/samples/Gallery/Shared/Samples/VariableFontSample.cs index 16e51509ec4..2c9117ef30b 100644 --- a/samples/Gallery/Shared/Samples/VariableFontSample.cs +++ b/samples/Gallery/Shared/Samples/VariableFontSample.cs @@ -84,7 +84,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) // Draw the sample text centered font.MeasureText(text, out var bounds, paint); - canvas.DrawText(text, x - bounds.MidX, y, font, paint); + canvas.DrawText(text, x - bounds.MidX, y, SKTextAlign.Left, font, paint); // Draw axis info below using var infoFont = new SKFont(typeface, Math.Max(14, textSize * 0.35f)); @@ -92,7 +92,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) var info = $"wght: {weight:F0} opsz: {opticalSize:F0}"; infoFont.MeasureText(info, out var infoBounds, infoPaint); - canvas.DrawText(info, x - infoBounds.MidX, y + bounds.Height + 40, infoFont, infoPaint); + canvas.DrawText(info, x - infoBounds.MidX, y + bounds.Height + 40, SKTextAlign.Left, infoFont, infoPaint); // Draw weight spectrum at the bottom DrawWeightSpectrum(canvas, width, height, typeface); @@ -133,12 +133,12 @@ private void DrawWeightSpectrum(SKCanvas canvas, int width, int height, SKTypefa }; f.MeasureText(spectrumText, out var b, p); - canvas.DrawText(spectrumText, cx - b.MidX, spectrumY, f, p); + canvas.DrawText(spectrumText, cx - b.MidX, spectrumY, SKTextAlign.Left, f, p); // Weight label var label = $"{w:F0}"; labelFont.MeasureText(label, out var lb, labelPaint); - canvas.DrawText(label, cx - lb.MidX, spectrumY + b.Height + 16, labelFont, labelPaint); + canvas.DrawText(label, cx - lb.MidX, spectrumY + b.Height + 16, SKTextAlign.Left, labelFont, labelPaint); } } diff --git a/samples/Gallery/Shared/Samples/WideGamutP3Sample.cs b/samples/Gallery/Shared/Samples/WideGamutP3Sample.cs index b72c6d92859..6506cdf6d07 100644 --- a/samples/Gallery/Shared/Samples/WideGamutP3Sample.cs +++ b/samples/Gallery/Shared/Samples/WideGamutP3Sample.cs @@ -113,13 +113,13 @@ private void DrawSwatches(SKCanvas canvas, int width, int height) // Labels var labelW = labelFont.MeasureText(swatch.Label); - canvas.DrawText(swatch.Label, x + swatchW / 2f - labelW / 2f, headerH + swatchH + 12, labelFont, labelPaint); + canvas.DrawText(swatch.Label, x + swatchW / 2f - labelW / 2f, headerH + swatchH + 12, SKTextAlign.Left, labelFont, labelPaint); } // Row labels labelPaint.Color = new SKColor(180, 180, 180); - canvas.DrawText("sRGB", margin, headerH - 6, smallFont, labelPaint); - canvas.DrawText("Display P3", margin, headerH + swatchH + 32, smallFont, labelPaint); + canvas.DrawText("sRGB", margin, headerH - 6, SKTextAlign.Left, smallFont, labelPaint); + canvas.DrawText("Display P3", margin, headerH + swatchH + 32, SKTextAlign.Left, smallFont, labelPaint); } private void DrawGradientComparison(SKCanvas canvas, int width, int height) @@ -145,7 +145,7 @@ private void DrawGradientRow(SKCanvas canvas, string label, float x, float y, fl { using var labelFont = new SKFont { Size = 13 }; using var labelPaint = new SKPaint { Color = new SKColor(180, 180, 180), IsAntialias = true }; - canvas.DrawText(label, x, y - 6, labelFont, labelPaint); + canvas.DrawText(label, x, y - 6, SKTextAlign.Left, labelFont, labelPaint); var rect = new SKRect(x, y, x + w, y + h); @@ -278,29 +278,29 @@ private void DrawGamutMap(SKCanvas canvas, int width, int height) using var vertPaint = new SKPaint { IsAntialias = true }; vertPaint.Color = new SKColor(0xFFE74C3C); - canvas.DrawText("sRGB R", srgbR.X + 6, srgbR.Y + 4, vertFont, vertPaint); - canvas.DrawText("G", srgbG.X - 4, srgbG.Y - 8, vertFont, vertPaint); - canvas.DrawText("B", srgbB.X - 14, srgbB.Y + 16, vertFont, vertPaint); + canvas.DrawText("sRGB R", srgbR.X + 6, srgbR.Y + 4, SKTextAlign.Left, vertFont, vertPaint); + canvas.DrawText("G", srgbG.X - 4, srgbG.Y - 8, SKTextAlign.Left, vertFont, vertPaint); + canvas.DrawText("B", srgbB.X - 14, srgbB.Y + 16, SKTextAlign.Left, vertFont, vertPaint); vertPaint.Color = new SKColor(0xFF5DADE2); - canvas.DrawText("P3 R", p3R.X + 6, p3R.Y - 8, vertFont, vertPaint); - canvas.DrawText("G", p3G.X + 8, p3G.Y - 4, vertFont, vertPaint); + canvas.DrawText("P3 R", p3R.X + 6, p3R.Y - 8, SKTextAlign.Left, vertFont, vertPaint); + canvas.DrawText("G", p3G.X + 8, p3G.Y - 4, SKTextAlign.Left, vertFont, vertPaint); // White point var wp = MapChromaticity(0.3127f, 0.3290f, cx, cy, size); using (var wpPaint = new SKPaint { Color = SKColors.White, IsAntialias = true }) canvas.DrawCircle(wp, 4, wpPaint); - canvas.DrawText("D65", wp.X + 6, wp.Y - 4, vertFont, new SKPaint { Color = SKColors.White, IsAntialias = true }); + canvas.DrawText("D65", wp.X + 6, wp.Y - 4, SKTextAlign.Left, vertFont, new SKPaint { Color = SKColors.White, IsAntialias = true }); // Legend var legendY = height - 40f; using var legendFont = new SKFont { Size = 12 }; using (var legendPaint = new SKPaint { Color = new SKColor(0xFFE74C3C), IsAntialias = true }) - canvas.DrawText("— — sRGB", 20, legendY, legendFont, legendPaint); + canvas.DrawText("— — sRGB", 20, legendY, SKTextAlign.Left, legendFont, legendPaint); using (var legendPaint = new SKPaint { Color = new SKColor(0xFF5DADE2), IsAntialias = true }) - canvas.DrawText("——— Display P3", 120, legendY, legendFont, legendPaint); + canvas.DrawText("——— Display P3", 120, legendY, SKTextAlign.Left, legendFont, legendPaint); } private static void DrawCIEBackground(SKCanvas canvas, float cx, float cy, float size) @@ -356,6 +356,6 @@ private static void DrawTitle(SKCanvas canvas, int width, string text) using var titleFont = new SKFont { Size = 16 }; using var titlePaint = new SKPaint { Color = SKColors.White, IsAntialias = true }; var tw = titleFont.MeasureText(text); - canvas.DrawText(text, (width - tw) / 2f, 30, titleFont, titlePaint); + canvas.DrawText(text, (width - tw) / 2f, 30, SKTextAlign.Left, titleFont, titlePaint); } } diff --git a/samples/Gallery/Shared/Samples/WorldTextSample.cs b/samples/Gallery/Shared/Samples/WorldTextSample.cs index 7c63debfac8..78ad76d91bd 100644 --- a/samples/Gallery/Shared/Samples/WorldTextSample.cs +++ b/samples/Gallery/Shared/Samples/WorldTextSample.cs @@ -110,7 +110,7 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) var y = 60f; // Title - canvas.DrawText($"Script: {scriptName}", x, y, labelFont, labelPaint); + canvas.DrawText($"Script: {scriptName}", x, y, SKTextAlign.Left, labelFont, labelPaint); y += 50; if (!useEmbedded) @@ -118,14 +118,14 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) // Platform note for scripts that need system fonts using var warnFont = new SKFont(GetEmbeddedTypeface(), 13); using var warnPaint = new SKPaint { IsAntialias = true, Color = new SKColor(180, 100, 0) }; - canvas.DrawText("⚠ Requires system fonts — may not render on all platforms (e.g. WASM).", x, y, warnFont, warnPaint); + canvas.DrawText("⚠ Requires system fonts — may not render on all platforms (e.g. WASM).", x, y, SKTextAlign.Left, warnFont, warnPaint); y += 25; } if (ShowComparison[scriptIndex]) { // Shaped text (primary) - canvas.DrawText("▸ Shaped (HarfBuzz):", x, y, labelFont, labelPaint); + canvas.DrawText("▸ Shaped (HarfBuzz):", x, y, SKTextAlign.Left, labelFont, labelPaint); y += textSize + 10; using var shaper = new SKShaper(typeface); canvas.DrawShapedText(shaper, text, x, y, font, textPaint); @@ -138,20 +138,20 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) // Unshaped text (secondary) using var dimPaint = new SKPaint { IsAntialias = true, Color = new SKColor(0, 0, 0, 128) }; - canvas.DrawText("▸ Unshaped (no shaping):", x, y, labelFont, labelPaint); + canvas.DrawText("▸ Unshaped (no shaping):", x, y, SKTextAlign.Left, labelFont, labelPaint); y += textSize + 10; - canvas.DrawText(text, x, y, font, dimPaint); + canvas.DrawText(text, x, y, SKTextAlign.Left, font, dimPaint); y += textSize + 20; // Note using var noteFont = new SKFont(GetEmbeddedTypeface(), 13); using var notePaint = new SKPaint { IsAntialias = true, Color = new SKColor(120, 120, 120) }; - canvas.DrawText("Note: Shaping fixes ligatures and bidirectional text layout.", x, y, noteFont, notePaint); + canvas.DrawText("Note: Shaping fixes ligatures and bidirectional text layout.", x, y, SKTextAlign.Left, noteFont, notePaint); } else { // Just show shaped version for scripts where difference is invisible - canvas.DrawText("▸ Shaped text:", x, y, labelFont, labelPaint); + canvas.DrawText("▸ Shaped text:", x, y, SKTextAlign.Left, labelFont, labelPaint); y += textSize + 10; using var shaper = new SKShaper(typeface); canvas.DrawShapedText(shaper, text, x, y, font, textPaint); @@ -159,9 +159,9 @@ protected override void OnDrawSample(SKCanvas canvas, int width, int height) using var noteFont = new SKFont(GetEmbeddedTypeface(), 13); using var notePaint = new SKPaint { IsAntialias = true, Color = new SKColor(120, 120, 120) }; - canvas.DrawText($"Shaping for {scriptName} text produces identical output to unshaped.", x, y, noteFont, notePaint); + canvas.DrawText($"Shaping for {scriptName} text produces identical output to unshaped.", x, y, SKTextAlign.Left, noteFont, notePaint); y += 20; - canvas.DrawText("Select Arabic or Hebrew to see a visible difference.", x, y, noteFont, notePaint); + canvas.DrawText("Select Arabic or Hebrew to see a visible difference.", x, y, SKTextAlign.Left, noteFont, notePaint); } } finally diff --git a/samples/SkiaFiddle/Fiddle/BuiltinFiddleCompiler.cs b/samples/SkiaFiddle/Fiddle/BuiltinFiddleCompiler.cs index d48079e5249..712d76e4dec 100644 --- a/samples/SkiaFiddle/Fiddle/BuiltinFiddleCompiler.cs +++ b/samples/SkiaFiddle/Fiddle/BuiltinFiddleCompiler.cs @@ -46,6 +46,6 @@ private static void DrawDefault(SKCanvas canvas, int width, int height, double t using var font = new SKFont(SKTypeface.Default, 28) { Embolden = true }; const string text = "Hello SkiaFiddle"; var w = font.MeasureText(text); - canvas.DrawText(text, cx - w / 2, cy - r - 24, font, paint); + canvas.DrawText(text, cx - w / 2, cy - r - 24, SKTextAlign.Left, font, paint); } } diff --git a/samples/SkiaFiddle/Fiddle/FiddleCanvas.cs b/samples/SkiaFiddle/Fiddle/FiddleCanvas.cs index d9e88c7cede..2f0c2dd5551 100644 --- a/samples/SkiaFiddle/Fiddle/FiddleCanvas.cs +++ b/samples/SkiaFiddle/Fiddle/FiddleCanvas.cs @@ -142,7 +142,7 @@ private static void DrawPlaceholder(SKCanvas canvas, int width, int height) var textWidth = font.MeasureText(msg); var x = (width - textWidth) / 2; var y = (height - (metrics.Ascent + metrics.Descent)) / 2; - canvas.DrawText(msg, x, y, font, textPaint); + canvas.DrawText(msg, x, y, SKTextAlign.Left, font, textPaint); } private void DrawError(SKCanvas canvas, int width, int height) @@ -152,7 +152,7 @@ private void DrawError(SKCanvas canvas, int width, int height) using var titleFont = new SKFont(SKTypeface.Default, 18) { Embolden = true }; using var titlePaint = new SKPaint { Color = new SKColor(0xFF, 0x6B, 0x6B), IsAntialias = true }; - canvas.DrawText("Error", 24, 40, titleFont, titlePaint); + canvas.DrawText("Error", 24, 40, SKTextAlign.Left, titleFont, titlePaint); using var msgFont = new SKFont(SKTypeface.Default, 13); using var msgPaint = new SKPaint { Color = new SKColor(0xFF, 0xC8, 0xC8), IsAntialias = true }; @@ -169,7 +169,7 @@ private static void WrapAndDraw(SKCanvas canvas, string text, float x, float y, { if (font.MeasureText(text) <= maxWidth) { - canvas.DrawText(text, x, y, font, paint); + canvas.DrawText(text, x, y, SKTextAlign.Left, font, paint); return; } @@ -180,7 +180,7 @@ private static void WrapAndDraw(SKCanvas canvas, string text, float x, float y, var trial = line.Length == 0 ? word : line + " " + word; if (font.MeasureText(trial) > maxWidth && line.Length > 0) { - canvas.DrawText(line, x, y, font, paint); + canvas.DrawText(line, x, y, SKTextAlign.Left, font, paint); y += 22; line = word; } @@ -190,6 +190,6 @@ private static void WrapAndDraw(SKCanvas canvas, string text, float x, float y, } } if (line.Length > 0) - canvas.DrawText(line, x, y, font, paint); + canvas.DrawText(line, x, y, SKTextAlign.Left, font, paint); } } diff --git a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/CanvasExtensions.cs b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/CanvasExtensions.cs index 8b39ae75d90..f599ecd150a 100644 --- a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/CanvasExtensions.cs +++ b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/CanvasExtensions.cs @@ -6,24 +6,20 @@ public static class CanvasExtensions { [Obsolete("Use DrawShapedText(string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] public static void DrawShapedText(this SKCanvas canvas, string text, SKPoint p, SKPaint paint) => - canvas.DrawShapedText(text, p.X, p.Y, paint.TextAlign, paint.GetFont(), paint); + canvas.DrawShapedText(text, p.X, p.Y, paint.GetLegacyTextAlign(), paint.GetLegacyFont(), paint); public static void DrawShapedText(this SKCanvas canvas, string text, SKPoint p, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - canvas.DrawShapedText(text, p.X, p.Y, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + canvas.DrawShapedText(text, p.X, p.Y, paint.GetLegacyTextAlign(), font, paint); public static void DrawShapedText(this SKCanvas canvas, string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) => canvas.DrawShapedText(text, p.X, p.Y, textAlign, font, paint); [Obsolete("Use DrawShapedText(string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] public static void DrawShapedText(this SKCanvas canvas, string text, float x, float y, SKPaint paint) => - canvas.DrawShapedText(text, x, y, paint.TextAlign, paint.GetFont(), paint); + canvas.DrawShapedText(text, x, y, paint.GetLegacyTextAlign(), paint.GetLegacyFont(), paint); public static void DrawShapedText(this SKCanvas canvas, string text, float x, float y, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - canvas.DrawShapedText(text, x, y, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + canvas.DrawShapedText(text, x, y, paint.GetLegacyTextAlign(), font, paint); public static void DrawShapedText(this SKCanvas canvas, string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) { @@ -36,24 +32,20 @@ public static void DrawShapedText(this SKCanvas canvas, string text, float x, fl [Obsolete("Use DrawShapedText(SKShaper shaper, string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, SKPoint p, SKPaint paint) => - canvas.DrawShapedText(shaper, text, p.X, p.Y, paint.TextAlign, paint.GetFont(), paint); + canvas.DrawShapedText(shaper, text, p.X, p.Y, paint.GetLegacyTextAlign(), paint.GetLegacyFont(), paint); public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, SKPoint p, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - canvas.DrawShapedText(shaper, text, p.X, p.Y, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + canvas.DrawShapedText(shaper, text, p.X, p.Y, paint.GetLegacyTextAlign(), font, paint); public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, SKPoint p, SKTextAlign textAlign, SKFont font, SKPaint paint) => canvas.DrawShapedText(shaper, text, p.X, p.Y, textAlign, font, paint); [Obsolete("Use DrawShapedText(SKShaper shaper, string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) instead.")] public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, float x, float y, SKPaint paint) => - canvas.DrawShapedText(shaper, text, x, y, paint.TextAlign, paint.GetFont(), paint); + canvas.DrawShapedText(shaper, text, x, y, paint.GetLegacyTextAlign(), paint.GetLegacyFont(), paint); public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, float x, float y, SKFont font, SKPaint paint) => -#pragma warning disable CS0618 // Type or member is obsolete (TODO: replace paint.TextAlign with SKTextAlign.Left) - canvas.DrawShapedText(shaper, text, x, y, paint.TextAlign, font, paint); -#pragma warning restore CS0618 // Type or member is obsolete + canvas.DrawShapedText(shaper, text, x, y, paint.GetLegacyTextAlign(), font, paint); public static void DrawShapedText(this SKCanvas canvas, SKShaper shaper, string text, float x, float y, SKTextAlign textAlign, SKFont font, SKPaint paint) { diff --git a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SKShaper.cs b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SKShaper.cs index ae6998dd785..f40ce8fcb54 100644 --- a/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SKShaper.cs +++ b/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SKShaper.cs @@ -42,11 +42,11 @@ public void Dispose() [Obsolete("Use Shape(Buffer buffer, SKFont font) instead.")] public Result Shape(Buffer buffer, SKPaint paint) => - Shape(buffer, 0, 0, paint.GetFont()); + Shape(buffer, 0, 0, paint.GetLegacyFont()); [Obsolete("Use Shape(Buffer buffer, float xOffset, float yOffset, SKFont font) instead.")] public Result Shape(Buffer buffer, float xOffset, float yOffset, SKPaint paint) => - Shape(buffer, xOffset, yOffset, paint.GetFont()); + Shape(buffer, xOffset, yOffset, paint.GetLegacyFont()); public Result Shape(Buffer buffer, SKFont font) => Shape(buffer, 0, 0, font); @@ -102,7 +102,7 @@ public Result Shape(Buffer buffer, float xOffset, float yOffset, SKFont font) [Obsolete("Use Shape(string text, SKFont font) instead.")] public Result Shape(string text, SKPaint paint) => - Shape(text, 0, 0, paint.GetFont()); + Shape(text, 0, 0, paint.GetLegacyFont()); [Obsolete("Use Shape(string text, float xOffset, float yOffset, SKFont font) instead.")] public Result Shape(string text, float xOffset, float yOffset, SKPaint paint) @@ -114,7 +114,7 @@ public Result Shape(string text, float xOffset, float yOffset, SKPaint paint) using var buffer = new Buffer(); - switch (paint.TextEncoding) + switch (paint.GetLegacyTextEncoding()) { case SKTextEncoding.Utf8: buffer.AddUtf8(text); diff --git a/tests/Tests/SkiaSharp/SKBasicTypesTest.cs b/tests/Tests/SkiaSharp/SKBasicTypesTest.cs index 216c6f36d4d..cf0e886141d 100644 --- a/tests/Tests/SkiaSharp/SKBasicTypesTest.cs +++ b/tests/Tests/SkiaSharp/SKBasicTypesTest.cs @@ -19,6 +19,44 @@ public void MethodsDoNotModifySource() Assert.Equal(SKColorType.Rgb565, info.ColorType); Assert.Equal(SKColorType.Gray8, copy.ColorType); } + + [SkippableFact] + public void BytesSizeThrowsOnInt32Overflow() + { + // Width*Height*BytesPerPixel = 65536*65536*4 = 17179869184, which wraps to 0 + // as int32. Without the overflow check, downstream callers (SKImage.Create, + // SKCodec.GetPixels) would allocate a zero-sized buffer that native code + // then writes ~17 GB into. Guard with checked() so this throws instead. + var info = new SKImageInfo(65536, 65536, SKColorType.Bgra8888); + + Assert.Throws(() => info.BytesSize); + + // The 64-bit variant still returns the correct value. + Assert.Equal(17179869184L, info.BytesSize64); + } + + [SkippableFact] + public void RowBytesThrowsOnInt32Overflow() + { + // Width=2^30, BytesPerPixel=4 -> RowBytes mathematical product = 2^32, + // which wraps to 0 as int32. Must throw rather than silently corrupt. + var info = new SKImageInfo(1 << 30, 1, SKColorType.Bgra8888); + + Assert.Throws(() => info.RowBytes); + + Assert.Equal(1L << 32, info.RowBytes64); + } + + [SkippableFact] + public void BytesSizeIsExactForLargeButValidDimensions() + { + // Just under the int32 boundary - must compute exactly, not throw. + // 23170*23170*4 = 2147395600 < int.MaxValue. + var info = new SKImageInfo(23170, 23170, SKColorType.Bgra8888); + + Assert.Equal(2147395600, info.BytesSize); + Assert.Equal(2147395600L, info.BytesSize64); + } } public class SKRectTest : SKTest diff --git a/tests/Tests/SkiaSharp/SKCanvasTest.cs b/tests/Tests/SkiaSharp/SKCanvasTest.cs index b1b9d818a30..c2e36fa47b5 100644 --- a/tests/Tests/SkiaSharp/SKCanvasTest.cs +++ b/tests/Tests/SkiaSharp/SKCanvasTest.cs @@ -230,7 +230,7 @@ public void CanDrawText() using (var paint = new SKPaint()) using (var font = new SKFont()) { - canvas.DrawText("text", 150, 175, font, paint); + canvas.DrawText("text", 150, 175, SKTextAlign.Left, font, paint); } } @@ -242,7 +242,7 @@ public void CanDrawEmptyText() using (var paint = new SKPaint()) using (var font = new SKFont()) { - canvas.DrawText("", 150, 175, font, paint); + canvas.DrawText("", 150, 175, SKTextAlign.Left, font, paint); } } diff --git a/tests/Tests/SkiaSharp/SKManagedStreamTest.cs b/tests/Tests/SkiaSharp/SKManagedStreamTest.cs index cdc466fae69..94071469874 100644 --- a/tests/Tests/SkiaSharp/SKManagedStreamTest.cs +++ b/tests/Tests/SkiaSharp/SKManagedStreamTest.cs @@ -299,7 +299,7 @@ public void ManagedStreamIsNotCollectedPrematurely() foreach (var pair in paintList) { for (var i = 0; i < 100; i++) - pageCanvas.DrawText("Text", 0, 5 * i, pair.Font, pair.Paint); + pageCanvas.DrawText("Text", 0, 5 * i, SKTextAlign.Left, pair.Font, pair.Paint); } document.EndPage(); diff --git a/tests/Tests/SkiaSharp/SKPaintTest.cs b/tests/Tests/SkiaSharp/SKPaintTest.cs index 7fe3174e4e8..6112dd7db7a 100644 --- a/tests/Tests/SkiaSharp/SKPaintTest.cs +++ b/tests/Tests/SkiaSharp/SKPaintTest.cs @@ -92,7 +92,7 @@ public void NonAntiAliasedTextOnScaledCanvasIsCorrect() { canvas.Clear(SKColors.White); canvas.Scale(1, 2); - canvas.DrawText("Skia", 10, 60, font, paint); + canvas.DrawText("Skia", 10, 60, SKTextAlign.Left, font, paint); try { @@ -115,7 +115,7 @@ public void NonAntiAliasedTextOnScaledCanvasIsCorrect() { canvas.Clear(SKColors.White); canvas.Scale(1, 2); - canvas.DrawText("Skia", 10, 60, font, paint); + canvas.DrawText("Skia", 10, 60, SKTextAlign.Left, font, paint); try { @@ -203,543 +203,6 @@ public void DrawTransparentImageWithHighFilterQualityWithPremul() Assert.Equal(landColor, bitmap.GetPixel(270, 270)); } } - - [Obsolete] - [SkippableTheory] - [InlineData(SKTextEncoding.Utf8, "ä", 2)] - [InlineData(SKTextEncoding.Utf8, "a", 1)] - [InlineData(SKTextEncoding.Utf16, "ä", 2)] - [InlineData(SKTextEncoding.Utf16, "a", 2)] - [InlineData(SKTextEncoding.Utf32, "ä", 4)] - [InlineData(SKTextEncoding.Utf32, "a", 4)] - [InlineData(SKTextEncoding.GlyphId, "ä", 2)] - [InlineData(SKTextEncoding.GlyphId, "a", 2)] - public void BreakTextReturnsTheCorrectNumberOfBytes(SKTextEncoding encoding, string text, int extectedRead) - { - var paint = new SKPaint(); - paint.TextEncoding = encoding; - - // get bytes - var bytes = encoding == SKTextEncoding.GlyphId - ? GetGlyphBytes(text) - : StringUtilities.GetEncodedText(text, encoding); - - var read = paint.BreakText(bytes, 50.0f, out var measured); - Assert.Equal(extectedRead, read); - Assert.True(measured > 0); - - byte[] GetGlyphBytes(string text) - { - var glyphs = paint.GetGlyphs(text); - var bytes = new byte[Buffer.ByteLength(glyphs)]; - Buffer.BlockCopy(glyphs, 0, bytes, 0, bytes.Length); - return bytes; - } - } - - [Obsolete] - [SkippableFact] - public void BreakTextSucceedsForEmtptyString() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Equal(0, paint.BreakText("", 50.0f)); - } - - [Obsolete] - [SkippableFact] - public void BreakTextSucceedsForNullPointerZeroLength() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Equal(0, paint.BreakText(IntPtr.Zero, IntPtr.Zero, 50.0f)); - Assert.Equal(0, paint.BreakText(IntPtr.Zero, 0, 50.0f)); - } - - [Obsolete] - [SkippableFact] - public void BreakTextThrowsForNullPointer() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Throws(() => paint.BreakText(IntPtr.Zero, (IntPtr)123, 50.0f)); - Assert.Throws(() => paint.BreakText(IntPtr.Zero, 123, 50.0f)); - } - - [Obsolete] - [SkippableFact] - public void BreakTextReturnsTheCorrectNumberOfCharacters() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - Assert.Equal(1, paint.BreakText("ä", 50.0f)); - Assert.Equal(1, paint.BreakText("a", 50.0f)); - - paint.TextEncoding = SKTextEncoding.Utf16; - Assert.Equal(1, paint.BreakText("ä", 50.0f)); - Assert.Equal(1, paint.BreakText("a", 50.0f)); - - paint.TextEncoding = SKTextEncoding.Utf32; - Assert.Equal(1, paint.BreakText("ä", 50.0f)); - Assert.Equal(1, paint.BreakText("a", 50.0f)); - } - - [Obsolete] - [SkippableTheory] - [InlineData(-1)] - [InlineData(1 << 17)] - public void BreakTextWidthIsEqualToMeasureTextWidth(int textSize) - { - var font = new SKPaint(); - - if (textSize >= 0) - font.TextSize = textSize; - - var text = - "The ultimate measure of a man is not where he stands in moments of comfort " + - "and convenience, but where he stands at times of challenge and controversy."; - var length = text.Length; - - var width = font.MeasureText(text); - - var length2 = font.BreakText(text, width, out var mm); - - Assert.Equal(length, length2); - Assert.Equal(width, mm); - } - - [Obsolete] - [SkippableTheory] - [InlineData(-1)] - [InlineData(1 << 17)] - public void BreakTextHandlesLongText(int textSize) - { - var font = new SKPaint(); - - if (textSize >= 0) - font.TextSize = textSize; - - var text = string.Concat(Enumerable.Repeat('a', 1024)); - - var width = font.MeasureText(text); - - var length = font.BreakText(text, width, out var mm); - - Assert.Equal(1024, length); - Assert.Equal(width, mm); - } - - [Obsolete] - [SkippableTheory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(1 << 17)] - public void BreakTextHasCorrectLogic(int textSize) - { - var font = new SKPaint(); - - if (textSize >= 0) - font.TextSize = textSize; - - var text = "sdfkljAKLDFJKEWkldfjlk#$%&sdfs.dsj"; - var length = text.Length; - var width = font.MeasureText(text); - - var mm = 0f; - var nn = 0L; - var step = Math.Max(width / 10f, 1f); - for (float w = 0; w <= width; w += step) - { - var n = font.BreakText(text, w, out var m); - - Assert.True(n <= length); - Assert.True(m <= width); - - if (n == 0) - { - Assert.Equal(0, m); - } - else if (n == nn) - { - Assert.Equal(mm, m); - } - else - { - Assert.True(n > nn); - Assert.True(m > mm); - } - nn = n; - mm = m; - } - } - - [Obsolete] - [SkippableFact] - public void PlainGlyphsReturnsTheCorrectNumberOfCharacters() - { - const string text = "Hello World!"; - - var paint = new SKPaint(); - - Assert.Equal(text.Length, paint.CountGlyphs(text)); - Assert.Equal(text.Length, paint.GetGlyphs(text).Length); - } - - [Obsolete] - [Trait(Traits.Category.Key, Traits.Category.Values.MatchCharacter)] - [SkippableFact] - public void UnicodeGlyphsReturnsTheCorrectNumberOfCharacters() - { - SkipOnPlatform(IsBrowser, "WASM has no system fonts with emoji support"); - - const string text = "🚀"; - var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32); - - var typeface = SKFontManager.Default.MatchCharacter(emojiChar); - Assert.NotNull(typeface); - - var paint = new SKPaint(); - paint.TextEncoding = SKTextEncoding.Utf32; - paint.Typeface = typeface; - - Assert.Equal(1, paint.CountGlyphs(text)); - Assert.Single(paint.GetGlyphs(text)); - Assert.NotEqual(0, paint.GetGlyphs(text)[0]); - } - - [Obsolete] - [SkippableFact] - public void ContainsTextIsCorrect() - { - const string text = "A"; - - var paint = new SKPaint(); - paint.TextEncoding = SKTextEncoding.Utf32; - paint.Typeface = SKTypeface.Default; - - Assert.True(paint.ContainsGlyphs(text)); - } - - [Obsolete] - [Trait(Traits.Category.Key, Traits.Category.Values.MatchCharacter)] - [SkippableFact] - public void ContainsUnicodeTextIsCorrect() - { - SkipOnPlatform(IsBrowser, "WASM has no system fonts with emoji support"); - - const string text = "🚀"; - var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32); - - var paint = new SKPaint(); - paint.TextEncoding = SKTextEncoding.Utf32; - - // use the default typeface (which shouldn't have the emojis) - paint.Typeface = SKTypeface.Default; - - Assert.False(paint.ContainsGlyphs(text)); - - // find a font with the character - var typeface = SKFontManager.Default.MatchCharacter(emojiChar); - Assert.NotNull(typeface); - paint.Typeface = typeface; - - Assert.True(paint.ContainsGlyphs(text)); - } - - [Obsolete] - [SkippableFact] - public void CanMeasureBadUnicodeText() - { - using var paint = new SKPaint(); - - var rect = SKRect.Empty; - var width = paint.MeasureText("\ud83c", ref rect); - - Assert.Equal(0, width); - } - - [Obsolete] - [SkippableFact] - public void MeasureTextMeasuresTheText() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - var width8 = paint.MeasureText("Hello World!"); - - paint.TextEncoding = SKTextEncoding.Utf16; - var width16 = paint.MeasureText("Hello World!"); - - paint.TextEncoding = SKTextEncoding.Utf32; - var width32 = paint.MeasureText("Hello World!"); - - Assert.True(width8 > 0); - Assert.Equal(width8, width16); - Assert.Equal(width8, width32); - } - - [Obsolete] - [SkippableFact] - public void MeasureTextReturnsTheBounds() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - var bounds8 = new SKRect(); - var width8 = paint.MeasureText("Hello World!", ref bounds8); - - paint.TextEncoding = SKTextEncoding.Utf16; - var bounds16 = new SKRect(); - var width16 = paint.MeasureText("Hello World!", ref bounds16); - - paint.TextEncoding = SKTextEncoding.Utf32; - var bounds32 = new SKRect(); - var width32 = paint.MeasureText("Hello World!", ref bounds32); - - Assert.True(width8 > 0); - Assert.Equal(width8, width16); - Assert.Equal(width8, width32); - - Assert.NotEqual(SKRect.Empty, bounds8); - Assert.Equal(bounds8, bounds16); - Assert.Equal(bounds8, bounds32); - } - - [Obsolete] - [SkippableFact] - public void MeasureTextSucceedsForEmtptyString() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Equal(0, paint.MeasureText("")); - } - - [Obsolete] - [SkippableFact] - public void MeasureTextSucceedsForNullPointerZeroLength() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Equal(0, paint.MeasureText(IntPtr.Zero, IntPtr.Zero)); - Assert.Equal(0, paint.MeasureText(IntPtr.Zero, 0)); - } - - [Obsolete] - [SkippableFact] - public void MeasureTextThrowsForNullPointer() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.Throws(() => paint.MeasureText(IntPtr.Zero, (IntPtr)123)); - Assert.Throws(() => paint.MeasureText(IntPtr.Zero, 123)); - } - - [Obsolete] - [SkippableFact] - public void GetGlyphWidthsReturnsTheCorrectAmount() - { - var paint = new SKPaint(); - - var widths = paint.GetGlyphWidths("Hello World!", out var bounds); - - Assert.Equal(widths.Length, bounds.Length); - } - - [Obsolete] - [SkippableFact] - public void GetGlyphWidthsAreCorrect() - { - SkipOnPlatform(IsBrowser, "WASM has no system fonts for glyph width measurement"); - - var paint = new SKPaint(); - - var widths = paint.GetGlyphWidths("Hello World!", out var bounds); - - // make sure the 'l' glyphs are the same width - Assert.True(widths[2] > 0); - Assert.True(widths[2] == widths[3]); - Assert.True(widths[2] == widths[9]); - - // make sure the 'l' bounds are the same size - Assert.False(bounds[2].IsEmpty); - Assert.True(bounds[2] == bounds[3]); - Assert.True(bounds[2] == bounds[9]); - - // make sure the 'l' and 'W' glyphs are NOT the same width - Assert.True(widths[2] != widths[6]); - - // make sure the 'l' and 'W' bounds are NOT the same width - Assert.True(bounds[2] != bounds[6]); - } - - [Obsolete] - [SkippableFact] - public unsafe void TextInterceptsAreFoundCorrectly() - { - var text = "|"; - - var paint = new SKPaint(); - paint.TextSize = 100; - - var widths = paint.GetTextIntercepts(text, 50, 100, 0, 100); - Assert.Equal(2, widths.Length); - - var diff = widths[1] - widths[0]; - - var textPath = paint.GetTextPath(text, 0, 0); - var pathWidth = textPath.TightBounds.Width; - - Assert.Equal((double)pathWidth, (double)diff, 2); - } - - [Obsolete] - [SkippableFact] - public void GetTextPathSucceedsForEmtptyString() - { - var paint = new SKPaint(); - - paint.TextEncoding = SKTextEncoding.Utf8; - - Assert.NotNull(paint.GetTextPath("", 0, 0)); - } - - [Obsolete] - [SkippableTheory] - [InlineData(true, true, SKFontEdging.SubpixelAntialias)] - [InlineData(false, true, SKFontEdging.Alias)] - [InlineData(true, false, SKFontEdging.Antialias)] - [InlineData(false, false, SKFontEdging.Alias)] - public void UpdatingPropertiesIsAntialiasLcdRenderText(bool isAntialias, bool lcd, SKFontEdging newEdging) - { - var paint = new SKPaint(); - - paint.IsAntialias = isAntialias; - paint.LcdRenderText = lcd; - - Assert.Equal(newEdging, paint.GetFont().Edging); - } - - [Obsolete] - [SkippableTheory] - [InlineData(true, true, SKFontEdging.SubpixelAntialias)] - [InlineData(false, true, SKFontEdging.Alias)] - [InlineData(true, false, SKFontEdging.Antialias)] - [InlineData(false, false, SKFontEdging.Alias)] - public void UpdatingPropertiesLcdRenderTextIsAntialias(bool isAntialias, bool lcd, SKFontEdging newEdging) - { - var paint = new SKPaint(); - - paint.LcdRenderText = lcd; - paint.IsAntialias = isAntialias; - - Assert.Equal(newEdging, paint.GetFont().Edging); - } - - [Obsolete] - [SkippableFact] - public void PaintWithSubpixelEdgingIsPreserved() - { - var font = new SKFont(); - font.Edging = SKFontEdging.SubpixelAntialias; - - var paint = new SKPaint(font); - - Assert.True(paint.LcdRenderText); - Assert.False(paint.IsAntialias); - Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging); - - paint.IsAntialias = true; - - Assert.True(paint.LcdRenderText); - Assert.True(paint.IsAntialias); - Assert.Equal(SKFontEdging.SubpixelAntialias, paint.GetFont().Edging); - } - - [Obsolete] - [SkippableFact] - public void PaintWithAntialiasEdgingIsPreserved() - { - var font = new SKFont(); - font.Edging = SKFontEdging.Antialias; - - var paint = new SKPaint(font); - - Assert.False(paint.LcdRenderText); - Assert.False(paint.IsAntialias); - Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging); - - paint.IsAntialias = true; - - Assert.False(paint.LcdRenderText); - Assert.True(paint.IsAntialias); - Assert.Equal(SKFontEdging.Antialias, paint.GetFont().Edging); - } - - [Obsolete] - [SkippableFact] - public void PaintWithAliasEdgingIsPreserved() - { - var font = new SKFont(); - font.Edging = SKFontEdging.Alias; - - var paint = new SKPaint(font); - - Assert.False(paint.LcdRenderText); - Assert.False(paint.IsAntialias); - Assert.Equal(SKFontEdging.Alias, paint.GetFont().Edging); - - paint.IsAntialias = true; - - Assert.False(paint.LcdRenderText); - Assert.True(paint.IsAntialias); - Assert.Equal(SKFontEdging.Antialias, paint.GetFont().Edging); - } - - [Obsolete] - [SkippableTheory] - [InlineData("CourierNew.ttf")] - [InlineData("Distortable.ttf")] - [InlineData("Funkster.ttf")] - [InlineData("HangingS.ttf")] - [InlineData("ReallyBigA.ttf")] - [InlineData("Roboto.woff2")] - [InlineData("RobotoMono.woff2")] - [InlineData("Roboto2-Regular_NoEmbed.ttf")] - [InlineData("segoeui.ttf")] - [InlineData("上田雅美.ttf")] - public void CanSetTypefacesWithoutCrashing(string fontfile) - { - using var paint = new SKPaint(); - - using var typeface = SKTypeface.FromFile(Path.Combine(PathToFonts, fontfile)); - paint.Typeface = typeface; - - // In Skia m132, attempting to load woff2 files will still create a non-null typeface - // with an empty family name - if (typeface == null || string.IsNullOrEmpty(typeface?.FamilyName)) - { - var result = paint.Typeface; - Assert.True(result == null || ReferenceEquals(result, typeface) || string.IsNullOrEmpty(result?.FamilyName)); - } - else - { - Assert.Same(typeface, paint.Typeface); - } - } - [SkippableFact] public void Clone() { @@ -747,37 +210,5 @@ public void Clone() using var clonedPaint = paint.Clone(); using var clonedPaint2 = paint.Clone(); } - - // Default typeface behavior - - [Obsolete] - [SkippableFact] - public void DefaultPaintCanMeasureText() - { - var paint = new SKPaint(); - var width = paint.MeasureText("Hello World!"); - Assert.True(width > 0); - } - - [Obsolete] - [SkippableFact] - public void DefaultPaintTypefaceIsDefault() - { - var paint = new SKPaint(); - Assert.NotNull(paint.Typeface); - Assert.False(paint.Typeface.IsEmpty); - Assert.Equal(SKTypeface.Default.FamilyName, paint.Typeface.FamilyName); - } - - [Obsolete] - [SkippableFact] - public void PaintResetPreservesDefaultTypeface() - { - var paint = new SKPaint(); - paint.Typeface = SKTypeface.FromFile(Path.Combine(PathToFonts, "Roboto2-Regular_NoEmbed.ttf")); - paint.Reset(); - Assert.NotNull(paint.Typeface); - Assert.False(paint.Typeface.IsEmpty); - } } } diff --git a/tests/Tests/SkiaSharp/SKVariableFontRenderingTest.cs b/tests/Tests/SkiaSharp/SKVariableFontRenderingTest.cs index 8946a1528b4..2684af09a04 100644 --- a/tests/Tests/SkiaSharp/SKVariableFontRenderingTest.cs +++ b/tests/Tests/SkiaSharp/SKVariableFontRenderingTest.cs @@ -17,7 +17,7 @@ private static byte[] RenderTextToBitmapBytes (SKTypeface typeface, string text, using var paint = new SKPaint { Color = SKColors.Black, IsAntialias = true }; canvas.Clear (SKColors.White); - canvas.DrawText (text, 10, height / 2 + fontSize / 3, font, paint); + canvas.DrawText (text, 10, height / 2 + fontSize / 3, SKTextAlign.Left, font, paint); canvas.Flush (); return bmp.Bytes;