From e90a9f93f2e7fd4d30dc8a58d6641415332d9585 Mon Sep 17 00:00:00 2001 From: falkolab Date: Tue, 2 Sep 2014 16:16:46 +0400 Subject: [PATCH] Fix to display icons with code > 0xFFFF --- Resources/lib/IconicFont.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Resources/lib/IconicFont.js b/Resources/lib/IconicFont.js index 8de3d6c..a7fb049 100644 --- a/Resources/lib/IconicFont.js +++ b/Resources/lib/IconicFont.js @@ -1,3 +1,12 @@ +function fixedFromCharCode (codePt) { + if (codePt > 0xFFFF) { + codePt -= 0x10000; + return String.fromCharCode(0xD800 + (codePt >> 10), 0xDC00 + (codePt & 0x3FF)); + } else { + return String.fromCharCode(codePt); + } +} + function IconicFont(params) { params = params || {}; @@ -28,7 +37,7 @@ IconicFont.prototype.icon = function(param){ } for (var i = 0; i < param.length; i++) { - result.push(String.fromCharCode(this._font.charcode[param[i]])); + result.push(fixedFromCharCode(this._font.charcode[param[i]])); } return result.join('');