PainKKKiller Posted April 6, 2017 Share Posted April 6, 2017 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! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Exca Posted April 6, 2017 Share Posted April 6, 2017 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. Quote Link to comment Share on other sites More sharing options...
PainKKKiller Posted April 6, 2017 Author Share Posted April 6, 2017 I tried it with this library https://github.com/PixelsCommander/pixi-sdf-text small fonts are blurry, it well scales up, but not good when scales down. Quote Link to comment Share on other sites More sharing options...
ludado Posted April 6, 2017 Share Posted April 6, 2017 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. Quote Link to comment Share on other sites More sharing options...
PainKKKiller Posted April 7, 2017 Author Share Posted April 7, 2017 @ludado thanks for link, I would like to see how this sulution looks, but server is down. Quote Link to comment Share on other sites More sharing options...
ludado Posted April 8, 2017 Share Posted April 8, 2017 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. Quote Link to comment Share on other sites More sharing options...
PainKKKiller Posted April 10, 2017 Author Share Posted April 10, 2017 Thanks for demo, it has big sized text, really wonder how ti looks on small font sizes. And anyway you have problems with server, sometimes I can enter your games sometimes don't. Quote Link to comment Share on other sites More sharing options...
Taz Posted April 10, 2017 Share Posted April 10, 2017 Here's a Code Pen you can play with, taken from an old project. It uses PIXI.Text and sets the font size according to window dimensions. EDIT: Upgraded to Pixi 4.5.0 PainKKKiller 1 Quote Link to comment Share on other sites More sharing options...
PainKKKiller Posted April 13, 2017 Author Share Posted April 13, 2017 Thanks a lot Taz, really nice demo! Quote Link to comment Share on other sites More sharing options...
dazzafact Posted April 7, 2022 Share Posted April 7, 2022 fx=demoText.width/demoText.height demoText.width =w demoText.height =w/fx http://www.jsfiddle.net/eq9paxob/3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.