[Suggestion] Tweaks to official Sprite font

Discussion and feedback on Construct 2

Post » Sun Jul 07, 2013 10:46 pm

Would be awesome if I could set the Wrapping property to "none" for the new Sprite font object. Alternatively, (or additionally), it would be cool if the Character Width property as shown in the editor was actually called "Cell Width" and it could be referenced at runtime without having to specify a character in order to get width (the current character width implementation is useful as well, and I'm not suggesting it be removed).

In a nutshell, I'm creating a drawText function of my own that I can use in all of my projects. What seems intuitive to me is to create the sprite font object, set the text, and then set the width of the object to Self.textWidth to keep things tidy. TextWidth returns the width of the wrapped text, not the width as if all characters were left to right, and I understand why this functionality makes sense. However, if I have a project where I never want text to wrap, it would be cool to be able to just set it at the object level and then TextWidth always returns the cumulative width of all characters.

Now, assuming this is viewed as a low priority convenience request that can be worked around, I wanted to share a hurdle I encountered while trying to work around it :)

When creating the sprite font object, I thought I could just set the width to len(string)*[cell width of the sf object]. This basically enforces the no-wrapping behavior, and then I can set text and trim down the width with TextWidth. However, it's not possible to grab the cell width at runtime, it is only possible to grab the width of a specific charater. My workaround to the workaround is to create an instance variable called cellWidth and set it manually when the object is created, using a hard coded value that I must remember to update if I ever change the sprite font image.

Thanks for reading :)
Posts: 79
Reputation: 5,355

Return to Construct 2 General

Who is online

Users browsing this forum: Gelvard, Yahoo [Bot] and 9 guests