cache.font = font;
}
+ ctx.save();
+
ctx.font = font;
let longest = 0;
const ilen = arrayOfThings.length;
}
}
+ ctx.restore();
+
const gcLen = gc.length / 2;
if (gcLen > arrayOfThings.length) {
for (i = 0; i < gcLen; i++) {
let maxWidth, titleX, titleY;
let align;
- ctx.fillStyle = helpers.valueOrDefault(opts.fontColor, defaults.fontColor); // render in correct colour
- ctx.font = fontOpts.string;
-
// Horizontal
if (me.isHorizontal()) {
switch (opts.align) {
}
ctx.save();
+
+ ctx.fillStyle = helpers.valueOrDefault(opts.fontColor, defaults.fontColor); // render in correct colour
+ ctx.font = fontOpts.string;
+
ctx.translate(titleX, titleY);
ctx.rotate(rotation);
ctx.textAlign = align;
width = Math.max(width, ctx.measureText(line).width + widthPadding);
};
+ ctx.save();
+
ctx.font = helpers.fontString(titleFontSize, options.titleFontStyle, options.titleFontFamily);
helpers.each(tooltip.title, maxLineWidth);
ctx.font = helpers.fontString(footerFontSize, options.footerFontStyle, options.footerFontFamily);
helpers.each(tooltip.footer, maxLineWidth);
+ ctx.restore();
+
// Add padding
width += 2 * options.xPadding;
expect(helpers.canvas._longestText(context, font, arrayOfThings2D, {})).toEqual(80);
// We check to make sure we made the right calls to the canvas.
expect(context.getCalls()).toEqual([{
+ name: 'save',
+ args: []
+ }, {
name: 'measureText',
args: ['FooBar']
}, {
name: 'measureText',
args: ['Bar']
+ }, {
+ name: 'restore',
+ args: []
+ }, {
+ name: 'save',
+ args: []
}, {
name: 'measureText',
args: ['FooBar_1']
}, {
name: 'measureText',
args: ['Foo_1']
+ }, {
+ name: 'restore',
+ args: []
}]);
});
title.draw();
expect(context.getCalls()).toEqual([{
- name: 'setFillStyle',
- args: ['#666']
- }, {
name: 'save',
args: []
+ }, {
+ name: 'setFillStyle',
+ args: ['#666']
}, {
name: 'translate',
args: [300, 67.2]
title.draw();
expect(context.getCalls()).toEqual([{
- name: 'setFillStyle',
- args: ['#666']
- }, {
name: 'save',
args: []
+ }, {
+ name: 'setFillStyle',
+ args: ['#666']
}, {
name: 'translate',
args: [117.2, 250]
title.draw();
expect(context.getCalls()).toEqual([{
- name: 'setFillStyle',
- args: ['#666']
- }, {
name: 'save',
args: []
+ }, {
+ name: 'setFillStyle',
+ args: ['#666']
}, {
name: 'translate',
args: [117.2, 250]