SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

Add SKPaint.TextVerticalAlign

Open begleysm opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

Currently SKPaint has a method to set the TextAlign (Left, Center, Right). It would be very helpful to have something like a TextVerticalAlign (Bottom, Middle, Top) to define vertically what TextAlign defines horizontally. I'm currently trying to align labels on a polar graph (as shown below) and the lack of something like TextVerticalAlign means that I have to either put in manual offsets that vary depending on the angle of the text label, or I need to create a function that varies that offset based on angle.

Here are some text labels with TextAlign set to Center that shows how, based on angle the relative alignment varies because the "anchor" for the text is at the bottom left corner. image

Here is the same image with some custom offsets to try to overcome the lack of TextVerticalAlign image

Describe the solution you'd like

I'd like to see a property added to SKPaint that implements TextVerticalAlign (Bottom, Middle, Top) that does, vertically, what TextAlign does horizontally. This would increase the number of "anchor points" for a block of text from 3 to 9. image image

Describe alternatives you've considered

Without this I have to enter in manual offsets to account for the lack of TextVerticalAlign. I've considered developing a function to calculate the appropriate offset for my use case based on angle and font size but it would be great if a capability like this was built in.

begleysm avatar Aug 29 '22 18:08 begleysm

consider using RichTextKit for this

mgood7123 avatar Sep 04 '22 13:09 mgood7123

also please post some code

mgood7123 avatar Sep 04 '22 13:09 mgood7123