From 5c0219e745f00a8bf5cb2562cb54a42dfb0f2400 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 29 Mar 2018 11:46:02 -0400 Subject: [PATCH 1/2] Use scratch 2 default font --- src/components/paint-editor/paint-editor.css | 7 +++++-- src/helper/tools/text-tool.js | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/paint-editor/paint-editor.css b/src/components/paint-editor/paint-editor.css index e8592c7d..fc181524 100644 --- a/src/components/paint-editor/paint-editor.css +++ b/src/components/paint-editor/paint-editor.css @@ -208,8 +208,11 @@ $border-radius: 0.25rem; background: transparent; border: none; display: none; - font-family: Times; - font-size: 30px; + + /* @todo needs to match the text tool font/size */ + font-family: Helvetica; + font-size: 22px; + outline: none; overflow: hidden; padding: 0px; diff --git a/src/helper/tools/text-tool.js b/src/helper/tools/text-tool.js index f9c2dd26..8faa26f5 100644 --- a/src/helper/tools/text-tool.js +++ b/src/helper/tools/text-tool.js @@ -47,7 +47,7 @@ class TextTool extends paper.Tool { this.boundingBoxTool = new BoundingBoxTool(Modes.TEXT, setSelectedItems, clearSelectedItems, onUpdateSvg); this.nudgeTool = new NudgeTool(this.boundingBoxTool, onUpdateSvg); this.lastEvent = null; - + // We have to set these functions instead of just declaring them because // paper.js tools hook up the listeners in the setter functions. this.onMouseDown = this.handleMouseDown; @@ -193,8 +193,8 @@ class TextTool extends paper.Tool { this.textBox = new paper.PointText({ point: event.point, content: '', - font: 'Times', - fontSize: 30, + font: 'Helvetica', + fontSize: 22, fillColor: this.colorState.fillColor, // Default leading for both the HTML text area and paper.PointText // is 120%, but for some reason they are slightly off from each other. @@ -215,7 +215,7 @@ class TextTool extends paper.Tool { } handleMouseUp (event) { if (event.event.button > 0 || !this.active) return; // only first mouse button - + if (this.mode === TextTool.SELECT_MODE) { this.boundingBoxTool.onMouseUp(event); this.isBoundingBoxMode = null; @@ -234,7 +234,7 @@ class TextTool extends paper.Tool { // Ignore nudge if a text input field is focused return; } - + if (this.mode === TextTool.SELECT_MODE) { this.nudgeTool.onKeyUp(event); } From 449192ebb3fba70d8aee4a2e19cc7ec2d4f09f05 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 29 Mar 2018 11:46:56 -0400 Subject: [PATCH 2/2] Remove the preprocessing step of stripping newlines. It does not seem to be required anymore: I'm no longer seeing errors from the watermelon. It was breaking multiline text import from scratch 2 SVGs which use newlines. --- src/containers/paper-canvas.jsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/containers/paper-canvas.jsx b/src/containers/paper-canvas.jsx index f4b8209a..bac7ed42 100644 --- a/src/containers/paper-canvas.jsx +++ b/src/containers/paper-canvas.jsx @@ -86,13 +86,10 @@ class PaperCanvas extends React.Component { importSvg (svg, rotationCenterX, rotationCenterY) { const paperCanvas = this; // Pre-process SVG to prevent parsing errors (discussion from #213) - // 1. Remove newlines and tab characters, chrome will not load urls with them. - // https://www.chromestatus.com/feature/5735596811091968 - svg = svg.split(/[\n|\r|\t]/).join(''); - // 2. Remove svg: namespace on elements. + // 1. Remove svg: namespace on elements. svg = svg.split(/<\s*svg:/).join('<'); svg = svg.split(/<\/\s*svg:/).join(']*>/); if (svgAttrs && svgAttrs[0].indexOf('xmlns=') === -1) { svg = svg.replace(