// Unicode Private Use Area
var kCmapGlyphOffset = 0xE000;
+var kSizeOfGlyphArea = 0x1900;
+
+//start of CJK block
+var kUnicodeCJKStart = 0x2E80;
// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
// except for Type 3 fonts
}
var encoding = properties.encoding, i;
+
+ // offsetting glyphs to avoid problematic unicode ranges should only be
+ // done for fonts with a medium-sized glyph count otherwise we could
+ // overflow the glyph range or overwrite existing glyph positions
+ var cmapGlyphOffset = numGlyphs < kSizeOfGlyphArea ? kCmapGlyphOffset : 0;
+
for (i in encoding) {
if (encoding.hasOwnProperty(i)) {
var unicode = encoding[i].unicode;
- if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
- encoding[i].unicode = unicode += kCmapGlyphOffset;
+ if (unicode <= 0x1f || (unicode >= 127 && unicode <= kUnicodeCJKStart))
+ encoding[i].unicode = unicode += cmapGlyphOffset;
}
}
var glyphs = [];
for (i = 1; i < numGlyphs; i++) {
glyphs.push({
- unicode: i <= 0x1f || (i >= 127 && i <= 255) ?
- i + kCmapGlyphOffset : i
+ unicode: i <= 0x1f || (i >= 127 && i < kUnicodeCJKStart) ?
+ i + cmapGlyphOffset : i
});
}
cmap.data = createCMapTable(glyphs);