Navinv789 Posted July 14, 2020 Share Posted July 14, 2020 Hello, I need help in drawing text vertically using using pixi. Ex: have to print text "NAME" in container as below; N A M E Ex 2: Text=" NAME PIXI" N P A I M X E I Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 14, 2020 Share Posted July 14, 2020 (edited) Hi! CSS has that property (text-orientation:upright), but its not possible to use in canvas2d text, so , pixi naturally doesnt support it. Two ways to do that 1. Make a text per each character. Manually position it. Say goodbye to performance if there are more than 200 characters. 2. Copy pixi text source and make your class that works vertically. Edited July 14, 2020 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
b10b Posted July 15, 2020 Share Posted July 15, 2020 A hacky approach could be to use a bitmap font, with each character pre-rotated -90 degrees. Construct the text as normal (using BitmapText) then rotate that +90 degrees. ? Quote Link to comment Share on other sites More sharing options...
opd Posted July 15, 2020 Share Posted July 15, 2020 (edited) To make your text appear as in the sample image, you can rotate the textfield. myTextField.rotation=-Math.PI/2; Alternatively, to make your text appear as in Ex1, you can start a new line after each character with \n myTextField.text='N\nA\nM\nE' Edited July 15, 2020 by opd Quote Link to comment Share on other sites More sharing options...
Navinv789 Posted July 25, 2020 Author Share Posted July 25, 2020 On 7/15/2020 at 10:15 AM, opd said: To make your text appear as in the sample image, you can rotate the textfield. myTextField.rotation=-Math.PI/2; Alternatively, to make your text appear as in Ex1, you can start a new line after each character with \n myTextField.text='N\nA\nM\nE' I am using PIXI.TextMetrics.measureText to check whethe the text will be accomodated in the given area or not. Based on the result I am changing the font size and performing word wrap operations. But with this solution both will fail. And Example 2 will not be working 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.