From cab983f826bd1df59d62552179e5e45ede611b0d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 21 Jun 2013 09:53:28 -0600 Subject: [PATCH] We are guarnteed that all TextLiteral properties are defined (see #770) Instead of using the browser defaults, we use `ol.style.TextDefaults`. --- src/ol/renderer/canvas/canvasvectorrenderer.js | 16 +++------------- src/ol/style/text.js | 9 ++------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/ol/renderer/canvas/canvasvectorrenderer.js b/src/ol/renderer/canvas/canvasvectorrenderer.js index 02d4924b3c..183412b679 100644 --- a/src/ol/renderer/canvas/canvasvectorrenderer.js +++ b/src/ol/renderer/canvas/canvasvectorrenderer.js @@ -272,22 +272,12 @@ ol.renderer.canvas.VectorRenderer.prototype.renderPointFeatures_ = ol.renderer.canvas.VectorRenderer.prototype.renderText_ = function(features, text, texts) { var context = this.context_, - fontArray = [], - color = text.color, vecs, vec; - if (color) { - context.fillStyle = color; - } - if (goog.isDef(text.fontSize)) { - fontArray.push(text.fontSize + 'px'); - } - if (goog.isDef(text.fontFamily)) { - fontArray.push(text.fontFamily); - } - if (fontArray.length) { - context.font = fontArray.join(' '); + if (context.fillStyle !== text.color) { + context.fillStyle = text.color; } + context.font = text.fontSize + 'px ' + text.fontFamily; context.globalAlpha = text.opacity; // TODO: make alignments configurable diff --git a/src/ol/style/text.js b/src/ol/style/text.js index 0ffa64d391..200ce377b3 100644 --- a/src/ol/style/text.js +++ b/src/ol/style/text.js @@ -26,18 +26,13 @@ ol.style.TextLiteralOptions; */ ol.style.TextLiteral = function(options) { + goog.asserts.assertString(options.color, 'color must be a string'); /** @type {string} */ this.color = options.color; - if (goog.isDef(options.color)) { - goog.asserts.assertString(options.color, 'color must be a string'); - } + goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string'); /** @type {string} */ this.fontFamily = options.fontFamily; - if (goog.isDef(options.fontFamily)) { - goog.asserts.assertString(options.fontFamily, - 'fontFamily must be a string'); - } goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number'); /** @type {number} */