Digital Ronin Posted January 12, 2020 Share Posted January 12, 2020 (edited) How can I manuly apply two different styles to text? For example: Simple Text My code: const text = new PIXI.Text('Simple Text'); text .style = new PIXI.TextStyle ({ fill: 0x2d2c2f, fontSize:20 }); Edited January 12, 2020 by Digital Ronin Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 12, 2020 Share Posted January 12, 2020 Same question was asked 2 days ago in https://github.com/pixijs/pixi.js/issues/6323 Quote Link to comment Share on other sites More sharing options...
Digital Ronin Posted January 12, 2020 Author Share Posted January 12, 2020 (edited) 1 hour ago, ivan.popelyshev said: Same question was asked 2 days ago in https://github.com/pixijs/pixi.js/issues/6323 Thanks for replay. I found that solution with multystyle repo but it is not compatible with pixi v5. Is there a way to do it manualy, without library, I need it only for one line of text. Edited January 12, 2020 by Digital Ronin Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2020 Share Posted January 13, 2020 (edited) That one? https://github.com/tleunen/pixi-multistyle-text , not compatible with v5? You sure? Because @themoonrat thinks its compatible. Please confirm that plugin did not work for you and needs to be fixed. No, there's no packaged solution in pixijs. Edited January 13, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Digital Ronin Posted January 13, 2020 Author Share Posted January 13, 2020 (edited) 6 hours ago, ivan.popelyshev said: That one? https://github.com/tleunen/pixi-multistyle-text , not compatible with v5? You sure? Because @themoonrat thinks its compatible. Please confirm that plugin did not work for you and needs to be fixed. No, there's no packaged solution in pixijs. I tried to work with that plugin, but couldn't get it work since it required v4. Maybe I did something wrong, since I'm still newbie. Also you can check on this page https://github.com/tleunen/pixi-multistyle-text/issues/83 Edited January 13, 2020 by Digital Ronin Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2020 Share Posted January 13, 2020 (edited) OK, then it looks like you have to convert one of those two repos or wait while someone else does it. Or you can do one small string manually. Edited January 13, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
Digital Ronin Posted January 13, 2020 Author Share Posted January 13, 2020 2 minutes ago, ivan.popelyshev said: OK, then it looks like you have to convert one of those two repos or wait while someone else does it. Or you can do one small string manually. Yes, I would like to do it manually. I asked in this post how, since I couldn't find it. Can you show me on my code example? I think shoudn't be complicated, but i simply couldnt find it. I found that learning pixi from their documentation is a bit hard, since there is no much explanation. Thanks in advanece Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 13, 2020 Share Posted January 13, 2020 Put a number of Text's in container, set position of container like position of text you wanted, now fiddle with relative positions of those texts inside. Quote Link to comment Share on other sites More sharing options...
Digital Ronin Posted January 13, 2020 Author Share Posted January 13, 2020 Thanks. So basically I'm going to play with text positions. All right, it doesn't seem like the neatest way to do it but I guess it is possible. Quote Link to comment Share on other sites More sharing options...
jonforum Posted January 14, 2020 Share Posted January 14, 2020 (edited) it the good way to do, it will depending of your need. In simple context , if you need something very simple you can use without regex PIXI.TextMetrics.measureText() Metric are a pixi tool very powerful and can split for you arrays for you multistyle. Or in complexe a example, on my side i use regex to split string, and build a container and sprites with multiple text styles and motions worked with wordWrap! If this can help you to get a idea, here how i proceed on my side.https://github.com/djmisterjon/ANFT/blob/1bfda5a7a047ee2dcc963c59873f5f0b65b7c24c/js/game/global/texts.js#L239 Edited January 14, 2020 by jonforum ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Digital Ronin Posted January 14, 2020 Author Share Posted January 14, 2020 22 hours ago, jonforum said: it the good way to do, it will depending of your need. In simple context , if you need something very simple you can use without regex PIXI.TextMetrics.measureText() Metric are a pixi tool very powerful and can split for you arrays for you multistyle. Or in complexe a example, on my side i use regex to split string, and build a container and sprites with multiple text styles and motions worked with wordWrap! If this can help you to get a idea, here how i proceed on my side.https://github.com/djmisterjon/ANFT/blob/1bfda5a7a047ee2dcc963c59873f5f0b65b7c24c/js/game/global/texts.js#L239 Sorry for late response. I needed it for just for one line of text, so I did it manually with relative positioning. Anyway I would like to check and learn other methods, but this link you sent me is not active. Thanks anyway. Quote Link to comment Share on other sites More sharing options...
jonforum Posted January 15, 2020 Share Posted January 15, 2020 18 hours ago, Digital Ronin said: but this link you sent me is not active. Thanks anyway. oups sorry it because it was private repository, i switch to public , link should work now. 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.