From 09281d6b2338ffc28392a08be65061194b9f8629 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 6 Jan 2016 12:14:56 -0800 Subject: [PATCH] fail and warn when spriteatlas is full ref #1633 --- js/symbol/bin_pack.js | 2 +- js/symbol/sprite_atlas.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/js/symbol/bin_pack.js b/js/symbol/bin_pack.js index 51119d71f9a..86fa1d13674 100644 --- a/js/symbol/bin_pack.js +++ b/js/symbol/bin_pack.js @@ -55,7 +55,7 @@ BinPack.prototype.allocate = function(width, height) { if (smallest < 0) { // There's no space left for this char. - return { x: -1, y: -1 }; + return { x: -1, y: -1, w: 0, h: 0 }; } this.free.splice(smallest, 1); diff --git a/js/symbol/sprite_atlas.js b/js/symbol/sprite_atlas.js index 41004b58e5c..f588e542140 100644 --- a/js/symbol/sprite_atlas.js +++ b/js/symbol/sprite_atlas.js @@ -119,6 +119,7 @@ SpriteAtlas.prototype.allocateImage = function(pixelWidth, pixelHeight) { // Add a 1px border around every image. var rect = this.bin.allocate(packWidth, packHeight); if (rect.w === 0) { + console.warn('SpriteAtlas out of space.'); return rect; }