tags:

views:

203

answers:

2

If I execute the following code the text is shown bad (it seems not aliased) and not right aligned why?

context.textBaseline = "top";
context.textAlign = "right";
context.fillStyle = "#F00";
context.font = "italic 30tpx sans-serif";
context.fillText("Lorem ipsum dolor sit amet", 50, 50);

I'm using FF 3.6...

A: 

I think Firefox doesn't know what you mean by "30tpx" and is ignoring your style. Also if you align right most of the text will be off the left of the screen -- maybe you mean to align right? Try this

  contexto.textAlign = "left";
  contexto.fillStyle = "#F00";
  contexto.font = "italic 30px sans-serif";
Aaron Watters
it was 30px and in the code I wrote it right...thanks however it does not work...I don't understand why if I align text to the right it goes out of the screen (on the left)!
xdevel2000
A: 

When you align right it draws the text from right to left, with the text ending at the x coordinate.

I you look at this example you can see how the different text align settings draw text in relation to the x coordinate. I've included you code as well.

Castrohenge