Is there any trick available to to get the font name from a text object?
What about a text objects reference point?
Is there any trick available to to get the font name from a text object?
What about a text objects reference point?
Bump, is there stil no way of getting the font name of the font a text object uses? Feels like a pretty trivial problem, if the textObjects could just have a property called .font or something that stores the string name of the font it was assigned.
Hi @Skatan,
You can gather many properties about a display object using the “introspection” APIs, but the font used for the object is not a bundled property of that.
http://docs.coronalabs.com/daily/api/type/DisplayObject/introspection.html
If you need the font name, I suggest you simply set a string property yourself when you create the object (i.e. myTextObject.fontUsed = “Arial”), and since you can’t change the font of a pre-existing text object after it’s created, this property would remain static.
Take care,
Brent
Heya Brent,
Cool! Did not know about that api. Although currently I mostly use a table as the params for a display.newText and am able to get the font through the params table right now. But the problem is the native.newTextField for some reason creates a newText-object as well when you run it, and that newText object is created with the traditional arguments and not a params table, so I’m not able to catch the font of that new newText object the way I’m doing it right now.
The reason we’re in need of this functionality is because we’ve replaced the original newText function with our own, and are using … as the arguments table for our function, and since we can not get the font name from the … arguments and since newTextField seems to create the newText object using arguments rather than a table, we have no way of capturing the font name without perhaps accessing it as a property in the newText object after it has been created. We are in need of knowing the font regardless if the newText is used or not as otherwise we need to make exceptions for our function in certain circumstances and it would make it very prone to unexpected bugs
Might be good to include this as a feature in an upcoming build? As it’s a pretty trivial issue and just replaces the nil property value of obj.font with the actual font name/function that it was assigned. Will only be of benefit imo
Bump, is there stil no way of getting the font name of the font a text object uses? Feels like a pretty trivial problem, if the textObjects could just have a property called .font or something that stores the string name of the font it was assigned.
Hi @Skatan,
You can gather many properties about a display object using the “introspection” APIs, but the font used for the object is not a bundled property of that.
http://docs.coronalabs.com/daily/api/type/DisplayObject/introspection.html
If you need the font name, I suggest you simply set a string property yourself when you create the object (i.e. myTextObject.fontUsed = “Arial”), and since you can’t change the font of a pre-existing text object after it’s created, this property would remain static.
Take care,
Brent
Heya Brent,
Cool! Did not know about that api. Although currently I mostly use a table as the params for a display.newText and am able to get the font through the params table right now. But the problem is the native.newTextField for some reason creates a newText-object as well when you run it, and that newText object is created with the traditional arguments and not a params table, so I’m not able to catch the font of that new newText object the way I’m doing it right now.
The reason we’re in need of this functionality is because we’ve replaced the original newText function with our own, and are using … as the arguments table for our function, and since we can not get the font name from the … arguments and since newTextField seems to create the newText object using arguments rather than a table, we have no way of capturing the font name without perhaps accessing it as a property in the newText object after it has been created. We are in need of knowing the font regardless if the newText is used or not as otherwise we need to make exceptions for our function in certain circumstances and it would make it very prone to unexpected bugs
Might be good to include this as a feature in an upcoming build? As it’s a pretty trivial issue and just replaces the nil property value of obj.font with the actual font name/function that it was assigned. Will only be of benefit imo