From 5afd963c8a62102591d6b60f31e354f51670a3af Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sun, 19 Jun 2011 15:14:07 -0700 Subject: [PATCH] handle surrogate pairs in glyph to unicode translation --- fonts.js | 6 +- glyphlist.js | 152 +++++++++++++++++++++++++-------------------------- 2 files changed, 81 insertions(+), 77 deletions(-) diff --git a/fonts.js b/fonts.js index 0c8725fb4..6cf9d6c1d 100644 --- a/fonts.js +++ b/fonts.js @@ -62,6 +62,10 @@ var Fonts = { var uc = encoding[ch]; if (uc instanceof Name) // we didn't convert the glyph yet uc = encoding[ch] = GlyphsUnicode[uc.name]; + if (uc > 0xffff) { // handle surrogate pairs + ret += String.fromCharCode(uc & 0xffff); + uc >>= 16; + } ret += String.fromCharCode(uc); } @@ -83,7 +87,7 @@ var Fonts = { var Font = function(aName, aFile, aProperties) { this.name = aName; - // If the font has already been decoded simply return + // If the font has already been decoded simply return it if (Fonts[aName]) { this.font = Fonts[aName].data; return; diff --git a/glyphlist.js b/glyphlist.js index 72a90431f..85ab876f9 100644 --- a/glyphlist.js +++ b/glyphlist.js @@ -1505,27 +1505,27 @@ var GlyphsUnicode = { dalet: 0x05D3, daletdagesh: 0xFB33, daletdageshhebrew: 0xFB33, - dalethatafpatah: "05D3 05B2", - dalethatafpatahhebrew: "05D3 05B2", - dalethatafsegol: "05D3 05B1", - dalethatafsegolhebrew: "05D3 05B1", + dalethatafpatah: 0x05D305B2, + dalethatafpatahhebrew: 0x05D305B2, + dalethatafsegol: 0x05D305B1, + dalethatafsegolhebrew: 0x05D305B1, dalethebrew: 0x05D3, - dalethiriq: "05D3 05B4", - dalethiriqhebrew: "05D3 05B4", - daletholam: "05D3 05B9", - daletholamhebrew: "05D3 05B9", - daletpatah: "05D3 05B7", - daletpatahhebrew: "05D3 05B7", - daletqamats: "05D3 05B8", - daletqamatshebrew: "05D3 05B8", - daletqubuts: "05D3 05BB", - daletqubutshebrew: "05D3 05BB", - daletsegol: "05D3 05B6", - daletsegolhebrew: "05D3 05B6", - daletsheva: "05D3 05B0", - daletshevahebrew: "05D3 05B0", - dalettsere: "05D3 05B5", - dalettserehebrew: "05D3 05B5", + dalethiriq: 0x05D305B4, + dalethiriqhebrew: 0x05D305B4, + daletholam: 0x05D305B9, + daletholamhebrew: 0x05D305B9, + daletpatah: 0x05D305B7, + daletpatahhebrew: 0x05D305B7, + daletqamats: 0x05D305B8, + daletqamatshebrew: 0x05D305B8, + daletqubuts: 0x05D305BB, + daletqubutshebrew: 0x05D305BB, + daletsegol: 0x05D305B6, + daletsegolhebrew: 0x05D305B6, + daletsheva: 0x05D305B0, + daletshevahebrew: 0x05D305B0, + dalettsere: 0x05D305B5, + dalettserehebrew: 0x05D305B5, dalfinalarabic: 0xFEAA, dammaarabic: 0x064F, dammalowarabic: 0x064F, @@ -1842,10 +1842,10 @@ var GlyphsUnicode = { finalkafdagesh: 0xFB3A, finalkafdageshhebrew: 0xFB3A, finalkafhebrew: 0x05DA, - finalkafqamats: "05DA 05B8", - finalkafqamatshebrew: "05DA 05B8", - finalkafsheva: "05DA 05B0", - finalkafshevahebrew: "05DA 05B0", + finalkafqamats: 0x05DA05B8, + finalkafqamatshebrew: 0x05DA05B8, + finalkafsheva: 0x05DA05B0, + finalkafshevahebrew: 0x05DA05B0, finalmem: 0x05DD, finalmemhebrew: 0x05DD, finalnun: 0x05DF, @@ -2034,14 +2034,14 @@ var GlyphsUnicode = { hakatakanahalfwidth: 0xFF8A, halantgurmukhi: 0x0A4D, hamzaarabic: 0x0621, - hamzadammaarabic: "0621 064F", - hamzadammatanarabic: "0621 064C", - hamzafathaarabic: "0621 064E", - hamzafathatanarabic: "0621 064B", + hamzadammaarabic: 0x0621064F, + hamzadammatanarabic: 0x0621064C, + hamzafathaarabic: 0x0621064E, + hamzafathatanarabic: 0x0621064B, hamzalowarabic: 0x0621, - hamzalowkasraarabic: "0621 0650", - hamzalowkasratanarabic: "0621 064D", - hamzasukunarabic: "0621 0652", + hamzalowkasraarabic: 0x06210650, + hamzalowkasratanarabic: 0x0621064D, + hamzasukunarabic: 0x06210652, hangulfiller: 0x3164, hardsigncyrillic: 0x044A, harpoonleftbarbup: 0x21BC, @@ -2473,10 +2473,10 @@ var GlyphsUnicode = { lameddagesh: 0xFB3C, lameddageshhebrew: 0xFB3C, lamedhebrew: 0x05DC, - lamedholam: "05DC 05B9", + lamedholam: 0x05DC05B9, lamedholamdagesh: "05DC 05B9 05BC", lamedholamdageshhebrew: "05DC 05B9 05BC", - lamedholamhebrew: "05DC 05B9", + lamedholamhebrew: 0x05DC05B9, lamfinalarabic: 0xFEDE, lamhahinitialarabic: 0xFCCA, laminitialarabic: 0xFEDF, @@ -2784,7 +2784,7 @@ var GlyphsUnicode = { noonfinalarabic: 0xFEE6, noonghunnaarabic: 0x06BA, noonghunnafinalarabic: 0xFB9F, - noonhehinitialarabic: "FEE7 FEEC", + noonhehinitialarabic: 0xFEE7FEEC, nooninitialarabic: 0xFEE7, noonjeeminitialarabic: 0xFCD2, noonjeemisolatedarabic: 0xFC4B, @@ -3156,27 +3156,27 @@ var GlyphsUnicode = { qof: 0x05E7, qofdagesh: 0xFB47, qofdageshhebrew: 0xFB47, - qofhatafpatah: "05E7 05B2", - qofhatafpatahhebrew: "05E7 05B2", - qofhatafsegol: "05E7 05B1", - qofhatafsegolhebrew: "05E7 05B1", + qofhatafpatah: 0x05E705B2, + qofhatafpatahhebrew: 0x05E705B2, + qofhatafsegol: 0x05E705B1, + qofhatafsegolhebrew: 0x05E705B1, qofhebrew: 0x05E7, - qofhiriq: "05E7 05B4", - qofhiriqhebrew: "05E7 05B4", - qofholam: "05E7 05B9", - qofholamhebrew: "05E7 05B9", - qofpatah: "05E7 05B7", - qofpatahhebrew: "05E7 05B7", - qofqamats: "05E7 05B8", - qofqamatshebrew: "05E7 05B8", - qofqubuts: "05E7 05BB", - qofqubutshebrew: "05E7 05BB", - qofsegol: "05E7 05B6", - qofsegolhebrew: "05E7 05B6", - qofsheva: "05E7 05B0", - qofshevahebrew: "05E7 05B0", - qoftsere: "05E7 05B5", - qoftserehebrew: "05E7 05B5", + qofhiriq: 0x05E705B4, + qofhiriqhebrew: 0x05E705B4, + qofholam: 0x05E705B9, + qofholamhebrew: 0x05E705B9, + qofpatah: 0x05E705B7, + qofpatahhebrew: 0x05E705B7, + qofqamats: 0x05E705B8, + qofqamatshebrew: 0x05E705B8, + qofqubuts: 0x05E705BB, + qofqubutshebrew: 0x05E705BB, + qofsegol: 0x05E705B6, + qofsegolhebrew: 0x05E705B6, + qofsheva: 0x05E705B0, + qofshevahebrew: 0x05E705B0, + qoftsere: 0x05E705B5, + qoftserehebrew: 0x05E705B5, qparen: 0x24AC, quarternote: 0x2669, qubuts: 0x05BB, @@ -3255,27 +3255,27 @@ var GlyphsUnicode = { rekatakanahalfwidth: 0xFF9A, resh: 0x05E8, reshdageshhebrew: 0xFB48, - reshhatafpatah: "05E8 05B2", - reshhatafpatahhebrew: "05E8 05B2", - reshhatafsegol: "05E8 05B1", - reshhatafsegolhebrew: "05E8 05B1", + reshhatafpatah: 0x05E805B2, + reshhatafpatahhebrew: 0x05E805B2, + reshhatafsegol: 0x05E805B1, + reshhatafsegolhebrew: 0x05E805B1, reshhebrew: 0x05E8, - reshhiriq: "05E8 05B4", - reshhiriqhebrew: "05E8 05B4", - reshholam: "05E8 05B9", - reshholamhebrew: "05E8 05B9", - reshpatah: "05E8 05B7", - reshpatahhebrew: "05E8 05B7", - reshqamats: "05E8 05B8", - reshqamatshebrew: "05E8 05B8", - reshqubuts: "05E8 05BB", - reshqubutshebrew: "05E8 05BB", - reshsegol: "05E8 05B6", - reshsegolhebrew: "05E8 05B6", - reshsheva: "05E8 05B0", - reshshevahebrew: "05E8 05B0", - reshtsere: "05E8 05B5", - reshtserehebrew: "05E8 05B5", + reshhiriq: 0x05E805B4, + reshhiriqhebrew: 0x05E805B4, + reshholam: 0x05E805B9, + reshholamhebrew: 0x05E805B9, + reshpatah: 0x05E805B7, + reshpatahhebrew: 0x05E805B7, + reshqamats: 0x05E805B8, + reshqamatshebrew: 0x05E805B8, + reshqubuts: 0x05E805BB, + reshqubutshebrew: 0x05E805BB, + reshsegol: 0x05E805B6, + reshsegolhebrew: 0x05E805B6, + reshsheva: 0x05E805B0, + reshshevahebrew: 0x05E805B0, + reshtsere: 0x05E805B5, + reshtserehebrew: 0x05E805B5, reversedtilde: 0x223D, reviahebrew: 0x0597, reviamugrashhebrew: 0x0597, @@ -3474,7 +3474,7 @@ var GlyphsUnicode = { shaddadammaarabic: 0xFC61, shaddadammatanarabic: 0xFC5E, shaddafathaarabic: 0xFC60, - shaddafathatanarabic: "0651 064B", + shaddafathatanarabic: 0x0651064B, shaddakasraarabic: 0xFC62, shaddakasratanarabic: 0xFC5F, shade: 0x2592, @@ -3671,7 +3671,7 @@ var GlyphsUnicode = { tchehfinalarabic: 0xFB7B, tchehinitialarabic: 0xFB7C, tchehmedialarabic: 0xFB7D, - tchehmeeminitialarabic: "FB7C FEE4", + tchehmeeminitialarabic: 0xFB7CFEE4, tcircle: 0x24E3, tcircumflexbelow: 0x1E71, tcommaaccent: 0x0163,