Moving CID-2 hack in fixWidths
This commit is contained in:
		
							parent
							
								
									cbfbd93e7a
								
							
						
					
					
						commit
						cd63fce80b
					
				
							
								
								
									
										92
									
								
								fonts.js
									
									
									
									
									
								
							
							
						
						
									
										92
									
								
								fonts.js
									
									
									
									
									
								
							@ -1212,25 +1212,11 @@ var Font = (function Font() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var encoding = properties.encoding, i;
 | 
					        var encoding = properties.encoding, i;
 | 
				
			||||||
        if (!encoding[0]) {
 | 
					        for (i in encoding) {
 | 
				
			||||||
          // the font is directly characters to glyphs with no encoding
 | 
					          if (encoding.hasOwnProperty(i)) {
 | 
				
			||||||
          // so create an identity encoding
 | 
					            var unicode = encoding[i].unicode;
 | 
				
			||||||
          var widths = properties.widths;
 | 
					            if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
 | 
				
			||||||
          for (i = 0; i < numGlyphs; i++) {
 | 
					              encoding[i].unicode = unicode += kCmapGlyphOffset;
 | 
				
			||||||
            var width = widths[i];
 | 
					 | 
				
			||||||
            encoding[i] = {
 | 
					 | 
				
			||||||
              unicode: i <= 0x1f || (i >= 127 && i <= 255) ?
 | 
					 | 
				
			||||||
                i + kCmapGlyphOffset : i,
 | 
					 | 
				
			||||||
              width: isNum(width) ? width : properties.defaultWidth
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          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;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1407,6 +1393,10 @@ var Font = (function Font() {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fixWidths: function font_fixWidths(properties) {
 | 
					    fixWidths: function font_fixWidths(properties) {
 | 
				
			||||||
 | 
					      if (properties.type !== 'CIDFontType0' &&
 | 
				
			||||||
 | 
					          properties.type !== 'CIDFontType2')
 | 
				
			||||||
 | 
					          return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var encoding = properties.encoding;
 | 
					      var encoding = properties.encoding;
 | 
				
			||||||
      if (encoding[0])
 | 
					      if (encoding[0])
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
@ -1414,30 +1404,48 @@ var Font = (function Font() {
 | 
				
			|||||||
      if (!glyphsWidths)
 | 
					      if (!glyphsWidths)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      var defaultWidth = properties.defaultWidth;
 | 
				
			||||||
      var cidSystemInfo = properties.cidSystemInfo;
 | 
					      var cidSystemInfo = properties.cidSystemInfo;
 | 
				
			||||||
      var cidToUnicode;
 | 
					      var cidToUnicode;
 | 
				
			||||||
      if (cidSystemInfo) {
 | 
					      if (cidSystemInfo) {
 | 
				
			||||||
        cidToUnicode = CIDToUnicodeMaps[cidSystemInfo.registry +
 | 
					        cidToUnicode = CIDToUnicodeMaps[
 | 
				
			||||||
          '-' + cidSystemInfo.ordering];
 | 
					          cidSystemInfo.registry + '-' + cidSystemInfo.ordering];
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (!cidToUnicode)
 | 
					      if (!cidToUnicode) {
 | 
				
			||||||
 | 
					        // the font is directly characters to glyphs with no encoding
 | 
				
			||||||
 | 
					        // so create an identity encoding
 | 
				
			||||||
 | 
					        for (i = 0; i < 0xD800; i++) {
 | 
				
			||||||
 | 
					          var width = glyphsWidths[i];
 | 
				
			||||||
 | 
					          encoding[i] = {
 | 
				
			||||||
 | 
					            unicode: i,
 | 
				
			||||||
 | 
					            width: isNum(width) ? width : defaultWidth
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // skipping surrogates + 256-user defined
 | 
				
			||||||
 | 
					        for (i = 0xE100; i <= 0xFFFF; i++) {
 | 
				
			||||||
 | 
					          var width = glyphsWidths[i];
 | 
				
			||||||
 | 
					          encoding[i] = {
 | 
				
			||||||
 | 
					            unicode: i,
 | 
				
			||||||
 | 
					            width: isNum(width) ? width : defaultWidth
 | 
				
			||||||
 | 
					          };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      encoding[0] = { unicode: 0, width: 0 };
 | 
					      encoding[0] = { unicode: 0, width: 0 };
 | 
				
			||||||
      var glyph = 1, i, j, k;
 | 
					      var glyph = 1, i, j, k;
 | 
				
			||||||
      for (i = 0; i < cidToUnicode.length; ++i) {
 | 
					      for (i = 0; i < cidToUnicode.length; ++i) {
 | 
				
			||||||
        var unicode = cidToUnicode[i];
 | 
					        var unicode = cidToUnicode[i];
 | 
				
			||||||
 | 
					        var width;
 | 
				
			||||||
        if (isArray(unicode)) {
 | 
					        if (isArray(unicode)) {
 | 
				
			||||||
          if (glyph in glyphsWidths) {
 | 
					          var length = unicode.length;
 | 
				
			||||||
            var length = unicode.length;
 | 
					          width = glyphsWidths[glyph];
 | 
				
			||||||
            for (j = 0; j < length; j++) {
 | 
					          for (j = 0; j < length; j++) {
 | 
				
			||||||
              k = unicode[j];
 | 
					            k = unicode[j];
 | 
				
			||||||
              encoding[k] = {
 | 
					            encoding[k] = {
 | 
				
			||||||
                unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
 | 
					              unicode: k,
 | 
				
			||||||
                  k + kCmapGlyphOffset : k,
 | 
					              width: isNum(width) ? width : defaultWidth
 | 
				
			||||||
                width: glyphsWidths[glyph]
 | 
					            };
 | 
				
			||||||
              };
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          glyph++;
 | 
					          glyph++;
 | 
				
			||||||
        } else if (typeof unicode === 'object') {
 | 
					        } else if (typeof unicode === 'object') {
 | 
				
			||||||
@ -1445,24 +1453,20 @@ var Font = (function Font() {
 | 
				
			|||||||
          if (fillLength) {
 | 
					          if (fillLength) {
 | 
				
			||||||
            k = unicode.c;
 | 
					            k = unicode.c;
 | 
				
			||||||
            for (j = 0; j < fillLength; ++j) {
 | 
					            for (j = 0; j < fillLength; ++j) {
 | 
				
			||||||
              if (!(glyph in glyphsWidths))
 | 
					              width = glyphsWidths[glyph++];
 | 
				
			||||||
                continue;
 | 
					 | 
				
			||||||
              encoding[k] = {
 | 
					              encoding[k] = {
 | 
				
			||||||
                unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
 | 
					                unicode: k,
 | 
				
			||||||
                  k + kCmapGlyphOffset : k,
 | 
					                width: isNum(width) ? width : defaultWidth
 | 
				
			||||||
                width: glyphsWidths[glyph]
 | 
					 | 
				
			||||||
              };
 | 
					              };
 | 
				
			||||||
              k++;
 | 
					              k++;
 | 
				
			||||||
              glyph++;
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          } else
 | 
					          } else
 | 
				
			||||||
            glyph += unicode.s;
 | 
					            glyph += unicode.s;
 | 
				
			||||||
        } else if (unicode && (glyph in glyphsWidths)) {
 | 
					        } else if (unicode) {
 | 
				
			||||||
          k = unicode;
 | 
					          width = glyphsWidths[glyph++];
 | 
				
			||||||
          encoding[k] = {
 | 
					          encoding[unicode] = {
 | 
				
			||||||
            unicode: k <= 0x1f || (k >= 127 && k <= 255) ?
 | 
					            unicode: unicode,
 | 
				
			||||||
                  k + kCmapGlyphOffset : k,
 | 
					            width: isNum(width) ? width : defaultWidth
 | 
				
			||||||
            width: glyphsWidths[glyph++]
 | 
					 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
        } else
 | 
					        } else
 | 
				
			||||||
          glyph++;
 | 
					          glyph++;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user