[go: nahoru, domu]

Skip to content

Commit

Permalink
fast fix of fillText(...) text alignment in chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
brigadir committed Dec 19, 2018
1 parent b7e5253 commit 08efac3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"homepage": "https://github.com/barmalei/zebra",
"devDependencies": {
"gulp": "latest",
"gulp": "3.9.1",
"gulp-concat": "latest",
"gulp-expect-file": "latest",
"gulp-jshint": "latest",
Expand Down
20 changes: 11 additions & 9 deletions src/js/web/web.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ zebkit.package("web", function(pkg, Class) {
// TODO: top works not good in FF and it is better don't use it
// So, ascent has to be taking in account as it was implemented
// before
if (zebkit.isFF === true) {
//if (zebkit.isFF === true) {
// FF works properly only with "middle" text base line
if (ctx.textBaseline !== "middle") {
ctx.textBaseline = "middle";
Expand All @@ -309,21 +309,23 @@ zebkit.package("web", function(pkg, Class) {
if (ctx._fillText === undefined) {
ctx._fillText = ctx.fillText;
ctx.fillText = function() {
var height = (arguments.length > 4) ? arguments[4].height
: zebkit.environment.fontMetrics(this.font).height;
this._fillText(arguments[0], arguments[1], arguments[2] + Math.floor(height / 2), arguments[3]);
var height = arguments.length > 4 ? arguments[4].height
: zebkit.environment.fontMetrics(this.font).height;
this._fillText(arguments[0],
arguments[1],
arguments[2] + Math.floor(height / 2), arguments[3]);
};

ctx._strokeText = ctx.strokeText;
ctx.strokeText = function() {
var height = (arguments.length > 4) ? arguments[4].height
: zebkit.environment.fontMetrics(this.font).height;
var height = arguments.length > 4 ? arguments[4].height
: zebkit.environment.fontMetrics(this.font).height;
this._strokeText(arguments[0], arguments[1], arguments[2] + Math.floor(height / 2), arguments[3]);
};
}
} else if (ctx.textBaseline !== "top") {
ctx.textBaseline = "top";
}
// } else if (ctx.textBaseline !== "top") {
// ctx.textBaseline = "top";
// }

return ctx;
};
Expand Down

0 comments on commit 08efac3

Please sign in to comment.