I want to align text right. To do this I need to know how long a text will be in the pdf before writing. When I know the length of the text string I can position it more left or right depending of the length. I use different types of fonts with different font styles (BOLD,REGULAR).
How I can figure out what length a text string will occupy?
You can use PDFontTools.getGlyphWidthEncoded to compute the run length of a given string. The string must be encoded using the font encoding before.