I want to draw rich text like iOS's Attributed Text or Xamarin.Forms's FormattedString
with SkiaSharp, but I can't find how to.
I found the DrawText
method, but it's for simple text rendering with one color and one font. No mixed colors and/or fonts and no styles like bold, italic, strike-through, or underline.
Do I have to do it with my own rich text rendering logic?
This is doable using the
SKPaint
type. Basically, as you draw, you set the properties on the paint:and then you can draw:
I hope this helps!
For other effects, you can use the
SKShader
andSKMaskFilter
types. This does a blur:EDIT
After some time, it seems we actually have a much better way to draw text - and not just the basic underlines. I would whole-heartedly recommend this library by Brad Robinson: https://github.com/toptensoftware/RichTextKit
I mean, just look at that beautiful thing!