Fix text shadow messing up size of bounding box.

Fix text shadow appearing under text background.
This commit is contained in:
kangax 2012-07-11 01:52:52 +02:00
parent ae45281d18
commit 66247a7b1c
6 changed files with 19 additions and 21 deletions

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2012, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.8.30" };
var fabric = fabric || { version: "0.8.31" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;

17
dist/all.js vendored
View file

@ -1,7 +1,7 @@
/* build: `node build.js modules=ALL` */
/*! Fabric.js Copyright 2008-2012, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.8.30" };
var fabric = fabric || { version: "0.8.31" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
@ -1167,10 +1167,10 @@ Cufon.registerEngine('canvas', (function() {
var x = size.convertFrom(parseFloat(shadow.offX));
var y = size.convertFrom(parseFloat(shadow.offY));
shadowOffsets[i] = [ x, y ];
if (y < expandTop) expandTop = y;
if (x > expandRight) expandRight = x;
if (y > expandBottom) expandBottom = y;
if (x < expandLeft) expandLeft = x;
//if (y < expandTop) expandTop = y;
//if (x > expandRight) expandRight = x;
//if (y > expandBottom) expandBottom = y;
//if (x < expandLeft) expandLeft = x;
}
}
@ -1280,7 +1280,7 @@ Cufon.registerEngine('canvas', (function() {
// we're at the center of an object and need to jump to the top left corner
// where first character is to be drawn
-expandLeft - ((1/scale * canvas.width) / 2) + (Cufon.fonts[font.family].offsetLeft || 0),
-expandTop - (Cufon.textOptions.height / scale) / 2
-expandTop - ((Cufon.textOptions.height / scale) / 2) + (Cufon.fonts[font.family].offsetTop || 0)
);
g.lineWidth = font.face['underline-thickness'];
@ -1475,6 +1475,8 @@ Cufon.registerEngine('canvas', (function() {
}
}
g.save();
renderBackground();
if (shadows) {
for (var i = 0, l = shadows.length; i < l; ++i) {
var shadow = shadows[i];
@ -1484,9 +1486,6 @@ Cufon.registerEngine('canvas', (function() {
g.restore();
}
}
g.save();
renderBackground();
renderText();
g.restore();
g.restore();

4
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

View file

@ -660,10 +660,10 @@ Cufon.registerEngine('canvas', (function() {
var x = size.convertFrom(parseFloat(shadow.offX));
var y = size.convertFrom(parseFloat(shadow.offY));
shadowOffsets[i] = [ x, y ];
if (y < expandTop) expandTop = y;
if (x > expandRight) expandRight = x;
if (y > expandBottom) expandBottom = y;
if (x < expandLeft) expandLeft = x;
//if (y < expandTop) expandTop = y;
//if (x > expandRight) expandRight = x;
//if (y > expandBottom) expandBottom = y;
//if (x < expandLeft) expandLeft = x;
}
}
@ -773,7 +773,7 @@ Cufon.registerEngine('canvas', (function() {
// we're at the center of an object and need to jump to the top left corner
// where first character is to be drawn
-expandLeft - ((1/scale * canvas.width) / 2) + (Cufon.fonts[font.family].offsetLeft || 0),
-expandTop - (Cufon.textOptions.height / scale) / 2
-expandTop - ((Cufon.textOptions.height / scale) / 2) + (Cufon.fonts[font.family].offsetTop || 0)
);
g.lineWidth = font.face['underline-thickness'];
@ -968,6 +968,8 @@ Cufon.registerEngine('canvas', (function() {
}
}
g.save();
renderBackground();
if (shadows) {
for (var i = 0, l = shadows.length; i < l; ++i) {
var shadow = shadows[i];
@ -977,9 +979,6 @@ Cufon.registerEngine('canvas', (function() {
g.restore();
}
}
g.save();
renderBackground();
renderText();
g.restore();
g.restore();

View file

@ -1,7 +1,7 @@
{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"version": "0.8.30",
"version": "0.8.31",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
"repository": "git://github.com/kangax/fabric.js",