From 5a9e4c1708d851df623891575c6958f8db153ec8 Mon Sep 17 00:00:00 2001 From: Ron Kok Date: Sun, 27 May 2018 20:11:59 -0700 Subject: [PATCH] Fix wide character spacing (#1371) * Fix wide character spacing Fixes issue #1360 * Add test * Use concat --- src/buildCommon.js | 3 ++- test/katex-spec.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/buildCommon.js b/src/buildCommon.js index 1a15ef51..e8f39453 100644 --- a/src/buildCommon.js +++ b/src/buildCommon.js @@ -238,7 +238,8 @@ const makeOrd = function( if (value.charCodeAt(0) === 0xD835) { // surrogate pairs get special treatment const [wideFontName, wideFontClass] = wideCharacterFont(value, mode); - return makeSymbol(value, wideFontName, mode, options, [wideFontClass]); + return makeSymbol(value, wideFontName, mode, options, + classes.concat(wideFontClass)); } else if (fontOrFamily) { let fontName; let fontClasses; diff --git a/test/katex-spec.js b/test/katex-spec.js index 406421a3..eb351deb 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -1548,6 +1548,16 @@ describe("An HTML font tree-builder", function() { expect(markup).toContain(span); }); + it("should render wide characters with mord and with the correct font", function() { + const markup = katex.renderToString(String.fromCharCode(0xD835, 0xDC00)); + expect(markup).toContain("A"); + + const phrase1 = getBuilt(String.fromCharCode(0xD835, 0xDC00) + + " = " + String.fromCharCode(0xD835, 0xDC1A))[0]; + const phrase2 = getBuilt("\\mathbf A = \\mathbf a")[0]; + expect(phrase1).toEqual(phrase2); + }); + it("should throw TypeError when the expression is of the wrong type", function() { expect(function() { katex.renderToString({badInputType: "yes"});