Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Unable to align: "center" & html-tags messing with line-widths #19

Closed
rknDA1337 opened this issue Jan 2, 2017 · 6 comments
Closed

Unable to align: "center" & html-tags messing with line-widths #19

rknDA1337 opened this issue Jan 2, 2017 · 6 comments
Assignees

Comments

@rknDA1337
Copy link

Whatever I do, I can't get text to center automagically. The only working way is to strategically insert line breaks, but that's sadly not feasible for my project =( Anyone else experience this?

Also it looks like html tags mess with line widths:

No tags: http://i.imgur.com/nVKcC6L.png
Tags: http://i.imgur.com/Qhc8X1u.png

Really like this plugin btw! Keep up the great work!

@bluepichu bluepichu self-assigned this Jan 2, 2017
@bluepichu bluepichu added the Bug label Jan 2, 2017
@bluepichu
Copy link
Collaborator

bluepichu commented Jan 2, 2017

Those two problems definitely sound related, and I think the line-width problem is the same as #9 and #16. All three will probably be fixed with an override of the wordWrap method, which I'm going to try and get done sometime today.

bluepichu added a commit to bluepichu/pixi-multistyle-text that referenced this issue Jan 2, 2017
bluepichu added a commit to bluepichu/pixi-multistyle-text that referenced this issue Jan 2, 2017
@bluepichu
Copy link
Collaborator

@rknDA1337, could you provide more information regarding the centering issue? In particular, source might be helpful.

One potential source of error that I can think of is that the API changed at 0.4.0 - align for the entire text block is now taken from the default style, rather than from an additional object passed to the constructor.

@rknDA1337
Copy link
Author

rknDA1337 commented Jan 2, 2017

@bluepichu it could definitely be a problem on my end too. For reference I'm running pixi 4.2.3.

I've been following the updated api and I have experienced no other issues. I've tried changing most values or not using them at all to no avail. Here's the current code for my text:

this.content = new MultiStyleText(this.data.content,
         {
           default: {
             fontFamily: "DogeSans",
             fontSize: "24px",
             fontStyle: "bold",
             align: "center",
             fill: "#ffffff",
             stroke: "#b09054",
             strokeThickness: 4,
             lineJoin: "round",
             wordWrap: true,
             wordWrapWidth: 280
           },
           green: {
             fontFamily: "DogeSans",
             fontSize: "24px",
             fontStyle: "bold",
             fill: "#c9fcd0",
             stroke: "#b09054",
             strokeThickness: 4,
             lineJoin: "round"
           },
           red: {
             fontFamily: "DogeSans",
             fontSize: "24px",
             fontStyle: "bold",
             fill: "#fedede",
             stroke: "#b09054",
             strokeThickness: 4,
             lineJoin: "round"
           },
           blue: {
             fontFamily: "DogeSans",
             fontSize: "24px",
             fontStyle: "bold",
             fill: "#c6e8fb",
             stroke: "#b09054",
             strokeThickness: 4,
             lineJoin: "round"
           }
         }
   );

@bluepichu
Copy link
Collaborator

Surprisingly, it looks like strokeThickness is breaking alignment:

screenshot 2017-01-02 15 07 43

screenshot 2017-01-02 15 08 17

Also, protip, style inheritance works properly so you can shorten your styles significantly:

let textSample = new MultiStyleText("A <red>space rocket</red> is required to get to <blue>the moon</blue>.  The cost is <green>100,000</green> dogecoins.  Get help from the friendly shibes in order to acquire dogecoins faster!", {
	default: {
		fontFamily: "Arial",
		fontSize: "24px",
		fontStyle: "bold",
		align: "center",
		fill: "#ffffff",
		stroke: "#b09054",
		strokeThickness: 4,
		lineJoin: "round",
		wordWrap: true,
		wordWrapWidth: 280
	},
	green: {
		fill: "#c9fcd0"
	},
	red: {
		fill: "#fedede"
	},
	blue: {
		fill: "#c6e8fb"
	}
});

@bluepichu
Copy link
Collaborator

For tracking purposes, I'm closing this issue and filing it as a new issue. See #22.

@rknDA1337
Copy link
Author

Wow, nice work and pro tip indeed!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants