Jump to content

Determining Width of a PIXI.Text object


mwatt
 Share

Recommended Posts

When I read the width of a Text object it consistently reads the same, no matter what scaling is applied.  Is this normal?  I am trying to center a Text object within a canvas that is itself being centered and also scaled, and having difficulty.  I believe I recall reading that Text objects needed one frame of animation to run before their width property is correct.  Is this true?  If so, what technique is good to deal with this?

 

Also, any idea when the next version of Pixi.js will be released?

Link to comment
Share on other sites

Howdy,

 

Ah yes I remember this issue. It basically to do with text not getting rendered until its actually added to the stage. Because of that it means the width is not calculated until updateTransform has been called. This is definitely something that needs looking into.

 

I do have a fix in mind - it will involve overriding the width / height getter setters to see if the text is "dirty" or not. If it is then updateText() will be called. That should then set width and height to be correct.

 

For now I think calling updateTexture() manually should set width and height to be correct for you.

 

With regards to the next pixi release, we are working on webGL filters at the moment. Fun Fun! :)

Link to comment
Share on other sites

Mat,

 

Thank you so much for taking the time to reply.  Unfortunately neither updateText() nor updateTexture() of the PIXI.Text object (I wasn't sure which was right, so I tried both -singly and in conjunction) had any apparent affect on the reported width.  I tried adding these calls both before and after I added the Text object to the DisplayObjectContainer that handles my scaling.

 

But perhaps I labor under a misapprehension.  Maybe the reported width is, and should be, disconnected from the scaling?

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...