Open Youssef1313 opened 3 years ago
When drawing at 0,0 you are drawing outside the canvas bounds, which might result in a crash depending on the drawing context. For example, in case of a hardware-accelerated surface you'll crash 100%. When drawing text coordinates are the lower-left corner of the text, not top-left one.
Text is drawn at the baseline
The outlined crash is probably less-relevant with the deprecation of SKPaint.Font
. The overload I was using in this issue is now deprecated anyway.
Description
DrawShapedText
Code
Expected Behavior
No crash
Actual Behavior
Exception due to
paint.GetFont().Typeface
being null in:https://github.com/mono/SkiaSharp/blob/2ad29861d5a40d3bf78c28ab0a9cb02a8f0fe437/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/CanvasExtensions.cs#L10-L17
as the constructor doesn't accept null
https://github.com/mono/SkiaSharp/blob/2ad29861d5a40d3bf78c28ab0a9cb02a8f0fe437/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.Shared/SKShaper.cs#L15-L17
The code was working with
DrawText
, and I'm switching toDrawShapedText
to fix the RTL languages.Basic Information
Detailed IDE/OS information (click to expand)
``` PASTE ANY DETAILED VERSION INFO HERE ```Screenshots
Reproduction Link