mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +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
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT
|
||||
* Date: Tue Feb 06 2018
|
||||
* Date: Wed Feb 07 2018
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||
@ -16696,6 +16696,7 @@
|
||||
var that = this;
|
||||
this.dummyCanvas = Konva.Util.createCanvasElement();
|
||||
this.dataArray = [];
|
||||
this.getKerning = config.getKerning;
|
||||
|
||||
// call super constructor
|
||||
Konva.Shape.call(this, config);
|
||||
@ -17079,11 +17080,19 @@
|
||||
|
||||
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;
|
||||
// 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(
|
||||
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;
|
||||
this.dummyCanvas = Konva.Util.createCanvasElement();
|
||||
this.dataArray = [];
|
||||
this.getKerning = config.getKerning;
|
||||
|
||||
// call super constructor
|
||||
Konva.Shape.call(this, config);
|
||||
@ -429,11 +430,19 @@
|
||||
|
||||
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;
|
||||
// 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(
|
||||
kern + width / 2.0,
|
||||
|
Loading…
Reference in New Issue
Block a user