mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-18 02:21:07 +00:00
[BACK_INCOMPAT] Cufon rendered fabric.Text now has two properties: backgroundColor (whole bounding-box) and textBackgroundColor (textlines, same behavior as "old" fabric.Text#backgroundColor)
This commit is contained in:
parent
57d7861fc4
commit
8e45dd8046
2 changed files with 13 additions and 5 deletions
15
lib/cufon.js
15
lib/cufon.js
|
|
@ -819,10 +819,16 @@ Cufon.registerEngine('canvas', (function() {
|
|||
function renderBackground() {
|
||||
g.save();
|
||||
|
||||
g.fillStyle = options.backgroundColor;
|
||||
|
||||
var left = 0, lineNum = 0, boundaries = [{ left: 0 }];
|
||||
|
||||
if (options.backgroundColor) {
|
||||
g.save();
|
||||
g.fillStyle = options.backgroundColor;
|
||||
g.translate(0, font.ascent);
|
||||
g.fillRect(0, 0, width + 10, (-font.ascent + font.descent) * lines);
|
||||
g.restore();
|
||||
}
|
||||
|
||||
if (options.textAlign === 'right') {
|
||||
g.translate(lineOffsets[lineNum], 0);
|
||||
boundaries[0].left = lineOffsets[lineNum] * scale;
|
||||
|
|
@ -872,9 +878,10 @@ Cufon.registerEngine('canvas', (function() {
|
|||
|
||||
var charWidth = Number(glyph.w || font.w) + letterSpacing;
|
||||
|
||||
// only draw background when there's some kind of value
|
||||
if (options.backgroundColor) {
|
||||
// only draw text-background when there's some kind of value
|
||||
if (options.textBackgroundColor) {
|
||||
g.save();
|
||||
g.fillStyle = options.textBackgroundColor;
|
||||
g.translate(0, font.ascent);
|
||||
g.fillRect(0, 0, charWidth + 10, -font.ascent + font.descent);
|
||||
g.restore();
|
||||
|
|
|
|||
|
|
@ -225,7 +225,8 @@
|
|||
lineHeight: this.lineHeight,
|
||||
strokeStyle: this.strokeStyle,
|
||||
strokeWidth: this.strokeWidth,
|
||||
backgroundColor: this.backgroundColor
|
||||
backgroundColor: this.backgroundColor,
|
||||
textBackgroundColor: this.textBackgroundColor
|
||||
});
|
||||
|
||||
// update width, height
|
||||
|
|
|
|||
Loading…
Reference in a new issue