Skip to main content
avid_body16B8
Legend
Oct 9, 2018 5:41 PM UTC
Answered

stage centered text also align center moves left on publish ANCC Canvas

What is the way to correct this problem? See the problem below. image1 is stage screenshot, image 2 is the published version. This is of course a dynamic text.

This topic is closed to new replies. Start a new post to keep the conversation going.
ClayUUIDCorrect answer
Legend
Oct 9, 2018 6:22 PM UTC

Greg's code is for correcting vertical text layout differences. I'm not sure why he posted it.

What font are you using? Do you get this horizontal difference when using more common fonts, like Arial or Times New Roman? There aren't any extra spaces on the left or right of either text, are there?

10 replies

Inspiring
Oct 9, 2018 5:48 PM UTC

Is this Firefox? If so try this code in first frame:

var firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

if (firefox && createjs)

{

createjs.Text.prototype._drawTextLine = function(ctx, text, y)

  {

  // Adjust text position only if textBaseline is "top"

  if (this.textBaseline === "top")

  {

  var lineHeight = this.lineHeight || this.getMeasuredLineHeight();

  y += lineHeight * 0.1; // decrease number to move font up and increase to move down

  }

  // Chrome 17 will fail to draw the text if the last param is included but null, so we feed it a large value instead:

  if (this.outline) { ctx.strokeText(text, 0, y, this.maxWidth||0xFFFF); }

  else { ctx.fillText(text, 0, y, this.maxWidth||0xFFFF); }

  };

}

Translate
avid_body16B8
Legend
Oct 9, 2018 6:13 PM UTC

FF, Chrome, Edge, Safari, Brave,...

Your code does not make any difference.

Translate
ClayUUIDCorrect answer
Legend
Oct 9, 2018 6:22 PM UTC

Greg's code is for correcting vertical text layout differences. I'm not sure why he posted it.

What font are you using? Do you get this horizontal difference when using more common fonts, like Arial or Times New Roman? There aren't any extra spaces on the left or right of either text, are there?

Translate