TextCentering inside Canvas PlayN

為{幸葍}努か 提交于 2019-12-24 13:13:02

问题


I have one little problem: I am trying go center a given text inside a Canvas with PlayN. I do not have any FontMetrics, because GWT does not offer one, and simple repositioning depending of character number and fontsize just does not works :(..

Can somebody please help


回答1:


Use Graphics.layoutText to create a TextLayout.

TextLayout provides the width and height of the text, which you can use to position it however you like and render it into a Canvas using Canvas.drawText(TextLayout,x,y).



来源:https://stackoverflow.com/questions/9211089/textcentering-inside-canvas-playn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!