SkiaSharp
SkiaSharp copied to clipboard
Add SKPaint.TextVerticalAlign
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.
Here is the same image with some custom offsets to try to overcome the lack of TextVerticalAlign
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.
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.
consider using RichTextKit for this
also please post some code