Bug in ofTrueTypeFont?

Hey, So I’ve been working on a multi-line text input box with auto-word wrapping and that fun stuff. Things are working pretty good… but I am running into a problem with ofTrueTypeFont’s stringWidth method.

Basically I am querying it pretty quickly when I am seeing how many characters I can fit on a line… I get to a point where after 2 lines of a non-breaking (ie. no whitespace between characters) string, it crashes out trying to access c[index].

I attached a screen capture of the stack trace from when it crashes.

Wondering if anyone else has seen this before?

![](http://forum.openframeworks.cc/uploads/default/544/Picture 3.png)


i’m testing this, but cannot get it to crash. do you have some code?

It seems like I have just come across the same or a closely related issue.
My application compiles fine on three machines:

_MacBook Pro 3,1
2.4 Ghz Intel Core 2 Duo - 4GB RAM
running 10.5.8

Macmini 3,1
2 GHz Intel Core 2 Duo - 3GB RAM
running 10.5.6

Recent MacBook Pro (don’t have specifics atm)
running 10.6.X_

but crashes on startup with the following machines:

2 Macminis, both
2.53 GHz Intel Core 2 Duo, 4GB RAM
running 10.6.3

with an ErrorReport that begins with:

ofTrueTypeFont::getStringBoundingBox(std::string, float, float) + 266
ofTrueTypeFont::stringWidth(std::string) + 57

I just mirrored the latest openFrameworks from github (ran 0.6 before) - hoping that this may
“naturally” make the problem disappear.

The issue seems to be directly related to the fonts I am using (they are not mainstream and in .lwfn format).
When I use a standard .ttf font it runs fine on all machines. I am curious what could cause the crash on
only one machine. Started working on some diagnostics and a workaround will let you know if I
come across anything related to the initial post.

Cheers, Marcus

Hey… thanks for the info Marcus. Just thought I’d say that I solved my issues and embarrassingly, it was a small logic error in my recursive algorithm. :oops:

The problem you are having does seem strange… I wonder, is it possible to convert the .lwfn format to a more-standard format? Perhaps it is something with the font file itself on the specific machine that is having the problems?

Either way, good luck with it!

Just to wrap up:

I received an .otf version of the font and everything works just fine.

Changes to the way Snow Leopard handles fonts seem to cause issues with PostScript Type 1 Fonts.
Below is a thread that discusses the issue.