Browse Source

Fixed {fill,stroke}Text() shadow support

v1.x
Tj Holowaychuk 15 years ago
parent
commit
5837a86dd0
  1. 6
      src/CanvasRenderingContext2d.cc
  2. 14
      test/public/tests.js

6
src/CanvasRenderingContext2d.cc

@ -982,8 +982,7 @@ Context2d::FillText(const Arguments &args) {
context->savePath(); context->savePath();
context->setTextPath(*str, x, y); context->setTextPath(*str, x, y);
SET_SOURCE(context->state->fill); context->fill();
cairo_fill(ctx);
context->restorePath(); context->restorePath();
return Undefined(); return Undefined();
@ -1010,8 +1009,7 @@ Context2d::StrokeText(const Arguments &args) {
context->savePath(); context->savePath();
context->setTextPath(*str, x, y); context->setTextPath(*str, x, y);
SET_SOURCE(context->state->stroke); context->stroke();
cairo_stroke(ctx);
context->restorePath(); context->restorePath();
return Undefined(); return Undefined();

14
test/public/tests.js

@ -1186,12 +1186,22 @@ tests['shadow globalAlpha'] = function(ctx){
ctx.stroke(); ctx.stroke();
}; };
tests['shadow text'] = function(ctx){ tests['shadow fillText()'] = function(ctx){
ctx.shadowColor = '#00c'; ctx.shadowColor = '#00c';
ctx.shadowBlur = 2; ctx.shadowBlur = 2;
ctx.shadowOffsetX = 8; ctx.shadowOffsetX = 8;
ctx.shadowOffsetY = 8; ctx.shadowOffsetY = 8;
ctx.textAlign = 'center'; ctx.textAlign = 'center';
ctx.font = '20px Arial'; ctx.font = '35px Arial';
ctx.fillText("Shadow", 100, 100); ctx.fillText("Shadow", 100, 100);
}; };
tests['shadow strokeText()'] = function(ctx){
ctx.shadowColor = '#00c';
ctx.shadowBlur = 2;
ctx.shadowOffsetX = 8;
ctx.shadowOffsetY = 8;
ctx.textAlign = 'center';
ctx.font = '35px Arial';
ctx.strokeText("Shadow", 100, 100);
};

Loading…
Cancel
Save