mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 09:48:30 +08:00
kerning support added
This commit is contained in:
parent
52f1b91387
commit
091ee2d75c
19
konva.js
19
konva.js
@ -2,7 +2,7 @@
|
|||||||
* Konva JavaScript Framework v1.7.6
|
* Konva JavaScript Framework v1.7.6
|
||||||
* http://konvajs.github.io/
|
* http://konvajs.github.io/
|
||||||
* Licensed under the MIT
|
* Licensed under the MIT
|
||||||
* Date: Tue Feb 06 2018
|
* Date: Wed Feb 07 2018
|
||||||
*
|
*
|
||||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||||
@ -16696,6 +16696,7 @@
|
|||||||
var that = this;
|
var that = this;
|
||||||
this.dummyCanvas = Konva.Util.createCanvasElement();
|
this.dummyCanvas = Konva.Util.createCanvasElement();
|
||||||
this.dataArray = [];
|
this.dataArray = [];
|
||||||
|
this.getKerning = config.getKerning;
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Konva.Shape.call(this, config);
|
Konva.Shape.call(this, config);
|
||||||
@ -17079,11 +17080,19 @@
|
|||||||
|
|
||||||
var width = Konva.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
var width = Konva.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
// Note: Since glyphs are rendered one at a time, any kerning pair data built into the font will not be used.
|
|
||||||
// Can foresee having a rough pair table built in that the developer can override as needed.
|
|
||||||
|
|
||||||
var kern = 0;
|
var kern = 0;
|
||||||
// placeholder for future implementation
|
if (this.getKerning) {
|
||||||
|
try {
|
||||||
|
// getKerning is a user provided getter. Make sure it never breaks our logic
|
||||||
|
kern = this.getKerning(charArr[i - 1], charArr[i]) * this.fontSize();
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
kern = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p0.x += kern;
|
||||||
|
p1.x += kern;
|
||||||
|
|
||||||
var midpoint = Konva.Path.getPointOnLine(
|
var midpoint = Konva.Path.getPointOnLine(
|
||||||
kern + width / 2.0,
|
kern + width / 2.0,
|
||||||
|
8
konva.min.js
vendored
8
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -46,6 +46,7 @@
|
|||||||
var that = this;
|
var that = this;
|
||||||
this.dummyCanvas = Konva.Util.createCanvasElement();
|
this.dummyCanvas = Konva.Util.createCanvasElement();
|
||||||
this.dataArray = [];
|
this.dataArray = [];
|
||||||
|
this.getKerning = config.getKerning;
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Konva.Shape.call(this, config);
|
Konva.Shape.call(this, config);
|
||||||
@ -429,11 +430,19 @@
|
|||||||
|
|
||||||
var width = Konva.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
var width = Konva.Path.getLineLength(p0.x, p0.y, p1.x, p1.y);
|
||||||
|
|
||||||
// Note: Since glyphs are rendered one at a time, any kerning pair data built into the font will not be used.
|
|
||||||
// Can foresee having a rough pair table built in that the developer can override as needed.
|
|
||||||
|
|
||||||
var kern = 0;
|
var kern = 0;
|
||||||
// placeholder for future implementation
|
if (this.getKerning) {
|
||||||
|
try {
|
||||||
|
// getKerning is a user provided getter. Make sure it never breaks our logic
|
||||||
|
kern = this.getKerning(charArr[i - 1], charArr[i]) * this.fontSize();
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
kern = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p0.x += kern;
|
||||||
|
p1.x += kern;
|
||||||
|
|
||||||
var midpoint = Konva.Path.getPointOnLine(
|
var midpoint = Konva.Path.getPointOnLine(
|
||||||
kern + width / 2.0,
|
kern + width / 2.0,
|
||||||
|
Loading…
Reference in New Issue
Block a user