文字绘制

竖向文字 http://events.jianshu.io/p/8cbb8422225e https://stackoverflow.com/questions/27631736/meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font

文字居中显示 #

如果想要文字居中显示,肯定是以中心线(虚线)为 x 轴了,但是现在是以 baseline 为 x 轴,只需要计算出中心线和 baseline 之间的距离即可(中心线与 baseline 之间的距离 = 中心线到底部的距离 - descent)。

首先,中心线到底部的距离是 = 整个文字的高度 / 2 ;即(-ascent + descent)/ 2

中心线与 baseline 之间的距离 = (-ascent + descent)/ 2 - descent ;即 (-ascent-descent) / 2

然后,只需要在 drawText 时候将 y 参数向上提高中心线与 baseline 之间的距离即可 https://blog.csdn.net/qq_17085163/article/details/103848441