Jump to content

Scalable text for pixi.js


Recommended Posts

For my project I need quickly develop textfield which shows good quality while scaling. So far I see I can do it with approach I describe below:
1. Scale whole render and get koefficient of resize. Question is which approach for this task is better, now I do it with JS function on window.resize event, which use css transform and returns scale factor. But I suppose I need to do scaling within pixi to get control over process.
2. Redraw textfield on canvas changing font size according this scale factor, and adjust it's coordinates.

I would like to hear any thoughts on this subject, thanks in advance!

Link to comment
Share on other sites

There's one method of getting really smooth fonts with gpu. The method described here: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts

Not sure if pixi has anything similar.

With normal text-elements I have previously done it similarly as you said. On resize change the renderer + canvas size (renderer.resize(width, height)). Then just calculate how big the font should be and set the style of the font to match. It's not a pixel perfect method though.

Link to comment
Share on other sites

You have to do what you said on the point 2, change the font size according to the scale factor, and adjust it's coordinates. That's what I do on my games at ludado.com. All the texts in the games are managed this way. You can resize the game window and the texts never get blurry.

If you scale the texts they will eventually get blurry. 

Link to comment
Share on other sites

Upps, that's strange, I didn't detect any problems on our servers yesterday. Try again, please. It you try Yatzy Solitaire game for example, the texts in the menu or game buttons, or the scoreboard and help bubbles in the game are PIXI.Text objects, and managed this way. Whenever you resize the window, the scale factor is used to set a new font size.

Link to comment
Share on other sites

  • 4 years 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.

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.


  • Recently Browsing   0 members

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