`ofTrueTypeFont.stringWidth(str)` returns `-Inf`


#1

I’m trying to get the width of each word when I draw a sentence using a monotype font. So, I declared a ofTrueTypeFont, and load the font I want, then I use the stringWidth("Hello") to get the width but I only get -Inf back. I’ve also tried to use getStringBoundingBox() as well but I get (-Inf, -Inf). I’m wondering what I do wrong here, and what else can I use to get the width correctly?


#2

can you post the exact code and font that triggers this? it might be a bug in the width calculation for some cases


#3

I realized what I was doing wrong. I was passing the ofTrueTypeFont address to a class before loading the font and therefore I was not able to get a proper measurement.