From f68712ff24fb76de2aaa7d8a9a47a0dbd1ff0acc Mon Sep 17 00:00:00 2001 From: moz Date: Thu, 16 Mar 2017 17:07:36 +0100 Subject: [PATCH] same spacing between all lines. #5 --- src/main/web | 2 +- .../js-gen/transcript-configuration-faust.js | 3 +++ svg_rendering/page/js-gen/transcript-svg.js | 19 ++++++++++++++++++- svg_rendering/page/js-gen/transcript.js | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/web b/src/main/web index 794f227..1c7f9bc 160000 --- a/src/main/web +++ b/src/main/web @@ -1 +1 @@ -Subproject commit 794f227eace467a4e26adfd34393af4e80880cca +Subproject commit 1c7f9bc6474d6a12132355efda41c9a94e5e2c80 diff --git a/svg_rendering/page/js-gen/transcript-configuration-faust.js b/svg_rendering/page/js-gen/transcript-configuration-faust.js index ddbc004..3e4dd38 100644 --- a/svg_rendering/page/js-gen/transcript-configuration-faust.js +++ b/svg_rendering/page/js-gen/transcript-configuration-faust.js @@ -52,6 +52,9 @@ if(window.Faust === undefined) { // overlay : "overlay", overlay : "none", stripWhitespace : ['overw'], + // distance from top of one line to top of the following line + lineSpacingValue: "20", + lineSpacingUnit: "pt", initialize : function (layoutState) { layoutState.idMap = {}; }, diff --git a/svg_rendering/page/js-gen/transcript-svg.js b/svg_rendering/page/js-gen/transcript-svg.js index aa1fc60..0305d2c 100644 --- a/svg_rendering/page/js-gen/transcript-svg.js +++ b/svg_rendering/page/js-gen/transcript-svg.js @@ -152,7 +152,8 @@ if(window.FaustTranscript === undefined) { result.setAttribute('width', '0.1em'); result.setAttribute('style', 'visibility: hidden;'); //TODO dynamically calculate from context line height - var height = String(this.vSpaceHeight * 1.5) + 'em'; + var height = String(Faust.TranscriptConfiguration.lineSpacingValue * this.vSpaceHeight) + + Faust.TranscriptConfiguration.lineSpacingUnit; result.setAttribute('height', height); return result; }; @@ -200,6 +201,22 @@ if(window.FaustTranscript === undefined) { return line; }; + FaustTranscript.Line.prototype.getExt = function(coordRotation) { + var matrix = this.view.viewportElement.createSVGMatrix(); + // create artificial element with real line width but fixed height + var originalLineWidth = this.constructor.superclass.getExt.call(this, 0) + var extElement = this.svgDocument().createElementNS(SVG_NS, "rect"); + this.view.insertBefore(extElement, this.view.childNodes[0]); + extElement.setAttribute("width", originalLineWidth); + extElement.setAttribute("height", String(Faust.TranscriptConfiguration.lineSpacingValue) + + Faust.TranscriptConfiguration.lineSpacingUnit); + matrix = matrix.rotate(coordRotation); + var bbox = SvgUtils.boundingBox(extElement, matrix).width; + this.view.removeChild(extElement); + return bbox; + }; + + FaustTranscript.Text.prototype.createView = function() { // wrapper will contain text decorations var wrapper = this.svgDocument().createElementNS(SVG_NS, "g"); diff --git a/svg_rendering/page/js-gen/transcript.js b/svg_rendering/page/js-gen/transcript.js index fc70429..b5e7ff5 100644 --- a/svg_rendering/page/js-gen/transcript.js +++ b/svg_rendering/page/js-gen/transcript.js @@ -283,7 +283,7 @@ if(window.FaustTranscript === undefined) { if (this.previous()) { - var yourJoint = this.lineAttrs['interline'] ? 0.75 : 1.5;; + var yourJoint = this.lineAttrs['interline'] ? 0.5 : 1;; if (Faust.TranscriptConfiguration.overlay === "overlay") { //yourJoint = ("between" in this.lineAttrs)? 1 : 1; yourJoint = ("over" in this.lineAttrs)? 0.1 : yourJoint;