Skip to content

Commit

Permalink
firefox scale fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
namniak committed Nov 29, 2015
1 parent 56bcbe6 commit be56fda
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
canvas-text-wrapper
=================
## v0.6.4
v0.6.5


## Syntax
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas-text-wrapper",
"version": "0.6.4",
"version": "0.6.5",
"ignore": [
"**/.*",
"**/*.log",
Expand Down
7 changes: 3 additions & 4 deletions canvas-text-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! canvas-text-wrapper
* https://github.com/namniak/canvas-text-wrapper
* Version: 0.6.4
* Version: 0.6.5
* MIT License (http://www.opensource.org/licenses/mit-license.html)
*/

Expand Down Expand Up @@ -53,7 +53,6 @@
canvas.height = canvasHeight * scale;
canvas.style.width = canvasWidth * scale * 0.5 + 'px';
canvas.style.height = canvasHeight * scale * 0.5 + 'px';
context.scale(scale, scale);

// restore context settings
for (var key in tempCtx) {
Expand All @@ -63,6 +62,8 @@

}
}

context.scale(scale, scale);
}

var EL_WIDTH = (!opts.fitParent ? canvas.width : canvas.parentNode.clientWidth) / scale;
Expand All @@ -78,13 +79,11 @@
var lineHeight = 0;
var fontParts;


setFont(fontSize);
setLineHeight();
validate();
render();


function setFont(fontSize) {
if (!fontParts) fontParts = (!opts.sizeToFill) ? opts.font.split(/\b\d+px\b/i) : context.font.split(/\b\d+px\b/i);
context.font = fontParts[0] + fontSize + 'px' + fontParts[1];
Expand Down
4 changes: 2 additions & 2 deletions canvas-text-wrapper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-text-wrapper",
"description": "Split canvas text into lines on specified rule with optional alignment, padding, and more. Supports HDPI screens.",
"version": "0.6.4",
"version": "0.6.5",
"license": "MIT",
"main": "canvas-text-wrapper.min.js",
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ gradient.addColorStop('0.7', 'purple');
ctx.fillStyle = gradient;

var opts = {
sizeToFill: true,
textAlign: 'center',
verticalAlign: 'middle',
paddingX: 20
sizeToFill: true,
textAlign: 'center',
verticalAlign: 'middle',
paddingX: 20
};

CanvasTextWrapper(canvas, 'What an awesome library!', opts);

0 comments on commit be56fda

Please sign in to comment.