assigning one ofTrueTypeFont to another ofTrueTypeFont

Is this not legal?

**ofTrueTypeFont body;
ofTrueTypeFont soul;

body.loadFont(ofToString(“static/fonts/Aller/Aller_Std_Lt.ttf”), 48);
soul = body; // Error with this line

soul.drawString(“test”, 0, 0);**

it should be, what error are you getting?

Hey Arturo! I’m having difficult recreating the error.

The code example I provided was overly simplified. The read code uses function I created, ofTrueTypeFont fontManager::retrieveFont(string fonttype, float scaledownribbon); to provide a centralized place for other CPPs to access fonts. For example I would access this function from another CPP and assign it to a local variable in the CPP, calling something like this: finaltweets.usernamefont = featuredTweetFonts.retrieveFont(“finaltweets.usernamefont”, scaledownribbon); The . between finaltweets and usernamefont is a struct, which I am using as a way of organizing font information for specific types of fonts, kind of like CSS, I guess.

I think the error was occurring not do to any fault of OF, but to a poor design pattern on my part. Can you suggest an OF solution where if I wanted an entirely separate class to manage fonts across an application, I could do that?

your solution seems ok, it’s possible that there’s an error in the copy behaviour of ofTrueTypeFont so i would use ofPtr instead so there’s no copies which will also save some memory

Ah, thanks. And I’ll look into ofPtr.