11-24-2012 07:54 PM
Is there any way to access font metrics from with Cascades?
I need to know the width of a text string when rendered for a given font face, weight etc.
If I was using Java I'd access the FontMetrics class. For Cascades I assumed I would be able to find the lenth of a label or container as if it were about to be rendered, but I don't see an option.
What is the equivalent in Cascades?
11-25-2012 09:35 PM
I've found a work-around, but it's not nice :-(
I'm using bbutil.c from the "HelloWorldDisplay" NDK (not Cascades) example, and I've built a wrapper class around it.
That code creates a new screen_context and then loads the given font into memory. From that, it can calculate the string size (it does width and height). It works bit it's a heck of an overhead when Label already has access to the information internally. Surely there must be a simpler, more elegant solution from within Cascades?
The code I'm using effectively side-loads any font (it takes a font path), but there is no way to pass that into Label. Label only takes the face name e.g. "helvetica" an not the full path :-(
This problem is my experience with Cascase so far in microcosm. I can see the potential future benefits, but it's currently something of a rough diamond. I can't help feeling that the effort put into creating and maintaining Cascades would have been better spent helping Nokia/Digia to finish QT5 (which switches rendering to a separate thread like Cascades anyway).