Permalink
Browse files

Fixed caret with line-height

  • Loading branch information...
tj committed Sep 7, 2011
1 parent 5aad662 commit 2924e9d9acdc5f78a8e0a30228f9982a750a2a2f
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/texty.js
View
@@ -597,11 +597,12 @@ Text.prototype.drawSelection = function(ctx, x, y, size, text){
Text.prototype.drawCaret = function(ctx, x, y, size, text){
if (!this.caret.visible) return;
var lines = text.substr(0, this.caret.pos).split('\n')
+ , lineHeight = this.lineHeight()
, len = lines.length
, line = lines[len - 1]
, px = size / 2
, caret = ctx.measureText(line).width + 2
- , y = y + --len * size;
+ , y = y + --len * lineHeight;
ctx.strokeStyle = this.caret._color;
ctx.beginPath();
ctx.moveTo(x + caret, y - px - 2);

0 comments on commit 2924e9d

Please sign in to comment.