Your approach will not work if you change the font face or its style. Unless you're using monospaced fonts where the width of a character is the same regardless of the character and you can base your calculations on how many chars are in the string, the size of a string meter is not proportional with the length of the text.
A more suitable (though still not perfect, due to pixels vs points measurements) approach would be to use a transparent color string meter initially, get its size via the corresponding section variable parameters, then multiply its font size with the minimum between its desired width / actual width and its desired height / actual height (where / means division). Or something along these lines. Of course, whatever padding on the text will have to be accounted for as well.
As for the positioning, set it to the middle of the desired box and use StringAlign=CenterCenter. This will require basing whatever relative positioning afterwards on the proper r offset from that center, instead of the standard R relative positioning.
Just saying. If you're happy with the current approach or you don't change the font, you can very well keep it, though the text length can be found in other ways too (like replacing every character with "+1" and pass the resulting string to a Calc to compute that formula).
A more suitable (though still not perfect, due to pixels vs points measurements) approach would be to use a transparent color string meter initially, get its size via the corresponding section variable parameters, then multiply its font size with the minimum between its desired width / actual width and its desired height / actual height (where / means division). Or something along these lines. Of course, whatever padding on the text will have to be accounted for as well.
As for the positioning, set it to the middle of the desired box and use StringAlign=CenterCenter. This will require basing whatever relative positioning afterwards on the proper r offset from that center, instead of the standard R relative positioning.
Just saying. If you're happy with the current approach or you don't change the font, you can very well keep it, though the text length can be found in other ways too (like replacing every character with "+1" and pass the resulting string to a Calc to compute that formula).
Statistics: Posted by Yincognito — Today, 12:47 pm