1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Merge remote-tracking branch 'upstream/master' into style

Conflicts:
	src/image.js
	src/pattern.js
This commit is contained in:
Kalervo Kujala 2011-12-09 00:28:31 +02:00
commit cd01302de8
11 changed files with 78 additions and 52 deletions

View file

@ -884,6 +884,13 @@ var Font = (function FontClosure() {
String.fromCharCode(value & 0xff);
};
function safeString16(value) {
// clamp value to the 16-bit int range
value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
return String.fromCharCode((value >> 8) & 0xff) +
String.fromCharCode(value & 0xff);
};
function string32(value) {
return String.fromCharCode((value >> 24) & 0xff) +
String.fromCharCode((value >> 16) & 0xff) +
@ -1778,6 +1785,12 @@ var Font = (function FontClosure() {
}
properties.hasShortCmap = hasShortCmap;
// remove glyph references outside range of avaialable glyphs
for (var i = 0, ii = ids.length; i < ii; i++) {
if (ids[i] >= numGlyphs)
ids[i] = 0;
}
createGlyphNameMap(glyphs, ids, properties);
this.glyphNameMap = properties.glyphNameMap;
@ -1903,9 +1916,9 @@ var Font = (function FontClosure() {
'\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // creation date
'\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // modifification date
'\x00\x00' + // xMin
string16(properties.descent) + // yMin
safeString16(properties.descent) + // yMin
'\x0F\xFF' + // xMax
string16(properties.ascent) + // yMax
safeString16(properties.ascent) + // yMax
string16(properties.italicAngle ? 2 : 0) + // macStyle
'\x00\x11' + // lowestRecPPEM
'\x00\x00' + // fontDirectionHint
@ -1917,15 +1930,15 @@ var Font = (function FontClosure() {
'hhea': (function fontFieldsHhea() {
return stringToArray(
'\x00\x01\x00\x00' + // Version number
string16(properties.ascent) + // Typographic Ascent
string16(properties.descent) + // Typographic Descent
safeString16(properties.ascent) + // Typographic Ascent
safeString16(properties.descent) + // Typographic Descent
'\x00\x00' + // Line Gap
'\xFF\xFF' + // advanceWidthMax
'\x00\x00' + // minLeftSidebearing
'\x00\x00' + // minRightSidebearing
'\x00\x00' + // xMaxExtent
string16(properties.capHeight) + // caretSlopeRise
string16(Math.tan(properties.italicAngle) *
safeString16(properties.capHeight) + // caretSlopeRise
safeString16(Math.tan(properties.italicAngle) *
properties.xHeight) + // caretSlopeRun
'\x00\x00' + // caretOffset
'\x00\x00' + // -reserved-
@ -2095,9 +2108,9 @@ var Font = (function FontClosure() {
break;
case 'Type1':
var glyphName = this.differences[charcode] || this.encoding[charcode];
if (!isNum(width))
width = this.widths[glyphName];
if (this.noUnicodeAdaptation) {
if (!isNum(width))
width = this.widths[glyphName];
unicode = GlyphsUnicode[glyphName] || charcode;
break;
}
@ -2142,7 +2155,8 @@ var Font = (function FontClosure() {
break;
}
var unicodeChars = this.toUnicode ? this.toUnicode[charcode] : charcode;
var unicodeChars = !('toUnicode' in this) ? charcode :
this.toUnicode[charcode] || charcode;
if (typeof unicodeChars === 'number')
unicodeChars = String.fromCharCode(unicodeChars);