Skip to main content
avid_body16B8
Legend
October 9, 2018
Answered

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

  • October 9, 2018
  • 1 reply
  • 1129 views

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 has been closed for replies.
Correct answer ClayUUID

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?

1 reply

Inspiring
October 9, 2018

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); }

  };

}

avid_body16B8
Legend
October 9, 2018

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

Your code does not make any difference.

ClayUUIDCorrect answer
Legend
October 9, 2018

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?