String length in twips java

Is there any way to get the string length in twips ? java implementation would be good.

+3
source share
1 answer

You can get the width of char or String displayed in a specific font with FontMetrics.stringWidth(). This should be the size in points. The point is 20 tweets.

So this should work:

Font font = new Font("Arial", Font.PLAIN, 10);
FontMetrics fm = new FontMetrics(font);
int widthInTwips = fm.stringWidth("Hello World") * 20;
+9
source

Source: https://habr.com/ru/post/1773824/


All Articles