Removes stringToArray
This commit is contained in:
parent
350556f085
commit
42771159ca
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals FONT_IDENTITY_MATRIX, FontType, warn, GlyphsUnicode, error, string32,
|
/* globals FONT_IDENTITY_MATRIX, FontType, warn, GlyphsUnicode, error, string32,
|
||||||
readUint32, stringToArray, Stream, FontRendererFactory, shadow,
|
readUint32, Stream, FontRendererFactory, shadow, stringToBytes,
|
||||||
bytesToString, info, assert, IdentityCMap, Name, CMapFactory, PDFJS,
|
bytesToString, info, assert, IdentityCMap, Name, CMapFactory, PDFJS,
|
||||||
isNum, Lexer, isArray, ISOAdobeCharset, ExpertCharset,
|
isNum, Lexer, isArray, ISOAdobeCharset, ExpertCharset,
|
||||||
ExpertSubsetCharset, Util */
|
ExpertSubsetCharset, Util */
|
||||||
@ -2821,10 +2821,9 @@ var Font = (function FontClosure() {
|
|||||||
string32(format31012.length / 12); // nGroups
|
string32(format31012.length / 12); // nGroups
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringToArray(cmap +
|
return cmap + '\x00\x04' + // format
|
||||||
'\x00\x04' + // format
|
string16(format314.length + 4) + // length
|
||||||
string16(format314.length + 4) + // length
|
format314 + header31012 + format31012;
|
||||||
format314 + header31012 + format31012);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateOS2Table(os2) {
|
function validateOS2Table(os2) {
|
||||||
@ -3318,7 +3317,7 @@ var Font = (function FontClosure() {
|
|||||||
for (i = 0; i < numMissing; i++) {
|
for (i = 0; i < numMissing; i++) {
|
||||||
entries += '\x00\x00';
|
entries += '\x00\x00';
|
||||||
}
|
}
|
||||||
metrics.data = stringToArray(entries);
|
metrics.data = entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4140,9 +4139,8 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
tables['OS/2'] = {
|
tables['OS/2'] = {
|
||||||
tag: 'OS/2',
|
tag: 'OS/2',
|
||||||
data: stringToArray(createOS2Table(properties,
|
data: createOS2Table(properties, newMapping.charCodeToGlyphId,
|
||||||
newMapping.charCodeToGlyphId,
|
override)
|
||||||
override))
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4150,7 +4148,7 @@ var Font = (function FontClosure() {
|
|||||||
if (!tables.post) {
|
if (!tables.post) {
|
||||||
tables.post = {
|
tables.post = {
|
||||||
tag: 'post',
|
tag: 'post',
|
||||||
data: stringToArray(createPostTable(properties))
|
data: createPostTable(properties)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4171,12 +4169,12 @@ var Font = (function FontClosure() {
|
|||||||
if (!tables.name) {
|
if (!tables.name) {
|
||||||
tables.name = {
|
tables.name = {
|
||||||
tag: 'name',
|
tag: 'name',
|
||||||
data: stringToArray(createNameTable(this.name))
|
data: createNameTable(this.name)
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// ... using existing 'name' table as prototype
|
// ... using existing 'name' table as prototype
|
||||||
var namePrototype = readNameTable(tables.name);
|
var namePrototype = readNameTable(tables.name);
|
||||||
tables.name.data = stringToArray(createNameTable(name, namePrototype));
|
tables.name.data = createNameTable(name, namePrototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = new OpenTypeFileBuilder(header.version);
|
var builder = new OpenTypeFileBuilder(header.version);
|
||||||
@ -4270,13 +4268,12 @@ var Font = (function FontClosure() {
|
|||||||
// PostScript Font Program
|
// PostScript Font Program
|
||||||
builder.addTable('CFF ', font.data);
|
builder.addTable('CFF ', font.data);
|
||||||
// OS/2 and Windows Specific metrics
|
// OS/2 and Windows Specific metrics
|
||||||
builder.addTable('OS/2', stringToArray(createOS2Table(properties,
|
builder.addTable('OS/2', createOS2Table(properties,
|
||||||
newMapping.charCodeToGlyphId)));
|
newMapping.charCodeToGlyphId));
|
||||||
// Character to glyphs mapping
|
// Character to glyphs mapping
|
||||||
builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId));
|
builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId));
|
||||||
// Font header
|
// Font header
|
||||||
builder.addTable('head', (function fontFieldsHead() {
|
builder.addTable('head',
|
||||||
return stringToArray(
|
|
||||||
'\x00\x01\x00\x00' + // Version number
|
'\x00\x01\x00\x00' + // Version number
|
||||||
'\x00\x00\x10\x00' + // fontRevision
|
'\x00\x00\x10\x00' + // fontRevision
|
||||||
'\x00\x00\x00\x00' + // checksumAdjustement
|
'\x00\x00\x00\x00' + // checksumAdjustement
|
||||||
@ -4294,11 +4291,9 @@ var Font = (function FontClosure() {
|
|||||||
'\x00\x00' + // fontDirectionHint
|
'\x00\x00' + // fontDirectionHint
|
||||||
'\x00\x00' + // indexToLocFormat
|
'\x00\x00' + // indexToLocFormat
|
||||||
'\x00\x00'); // glyphDataFormat
|
'\x00\x00'); // glyphDataFormat
|
||||||
})());
|
|
||||||
|
|
||||||
// Horizontal header
|
// Horizontal header
|
||||||
builder.addTable('hhea', (function fontFieldsHhea() {
|
builder.addTable('hhea',
|
||||||
return stringToArray(
|
|
||||||
'\x00\x01\x00\x00' + // Version number
|
'\x00\x01\x00\x00' + // Version number
|
||||||
safeString16(properties.ascent) + // Typographic Ascent
|
safeString16(properties.ascent) + // Typographic Ascent
|
||||||
safeString16(properties.descent) + // Typographic Descent
|
safeString16(properties.descent) + // Typographic Descent
|
||||||
@ -4317,7 +4312,6 @@ var Font = (function FontClosure() {
|
|||||||
'\x00\x00' + // -reserved-
|
'\x00\x00' + // -reserved-
|
||||||
'\x00\x00' + // metricDataFormat
|
'\x00\x00' + // metricDataFormat
|
||||||
string16(numGlyphs)); // Number of HMetrics
|
string16(numGlyphs)); // Number of HMetrics
|
||||||
})());
|
|
||||||
|
|
||||||
// Horizontal metrics
|
// Horizontal metrics
|
||||||
builder.addTable('hmtx', (function fontFieldsHmtx() {
|
builder.addTable('hmtx', (function fontFieldsHmtx() {
|
||||||
@ -4330,21 +4324,19 @@ var Font = (function FontClosure() {
|
|||||||
var width = 'width' in charstring ? charstring.width : 0;
|
var width = 'width' in charstring ? charstring.width : 0;
|
||||||
hmtx += string16(width) + string16(0);
|
hmtx += string16(width) + string16(0);
|
||||||
}
|
}
|
||||||
return stringToArray(hmtx);
|
return hmtx;
|
||||||
})());
|
})());
|
||||||
|
|
||||||
// Maximum profile
|
// Maximum profile
|
||||||
builder.addTable('maxp', (function fontFieldsMaxp() {
|
builder.addTable('maxp',
|
||||||
return stringToArray(
|
|
||||||
'\x00\x00\x50\x00' + // Version number
|
'\x00\x00\x50\x00' + // Version number
|
||||||
string16(numGlyphs)); // Num of glyphs
|
string16(numGlyphs)); // Num of glyphs
|
||||||
})());
|
|
||||||
|
|
||||||
// Naming tables
|
// Naming tables
|
||||||
builder.addTable('name', stringToArray(createNameTable(fontName)));
|
builder.addTable('name', createNameTable(fontName));
|
||||||
|
|
||||||
// PostScript informations
|
// PostScript informations
|
||||||
builder.addTable('post', stringToArray(createPostTable(properties)));
|
builder.addTable('post', createPostTable(properties));
|
||||||
|
|
||||||
return builder.toArray();
|
return builder.toArray();
|
||||||
},
|
},
|
||||||
@ -6896,7 +6888,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
|||||||
compileNameIndex: function CFFCompiler_compileNameIndex(names) {
|
compileNameIndex: function CFFCompiler_compileNameIndex(names) {
|
||||||
var nameIndex = new CFFIndex();
|
var nameIndex = new CFFIndex();
|
||||||
for (var i = 0, ii = names.length; i < ii; ++i) {
|
for (var i = 0, ii = names.length; i < ii; ++i) {
|
||||||
nameIndex.add(stringToArray(names[i]));
|
nameIndex.add(stringToBytes(names[i]));
|
||||||
}
|
}
|
||||||
return this.compileIndex(nameIndex);
|
return this.compileIndex(nameIndex);
|
||||||
},
|
},
|
||||||
@ -7021,7 +7013,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
|||||||
compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
|
compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
|
||||||
var stringIndex = new CFFIndex();
|
var stringIndex = new CFFIndex();
|
||||||
for (var i = 0, ii = strings.length; i < ii; ++i) {
|
for (var i = 0, ii = strings.length; i < ii; ++i) {
|
||||||
stringIndex.add(stringToArray(strings[i]));
|
stringIndex.add(stringToBytes(strings[i]));
|
||||||
}
|
}
|
||||||
return this.compileIndex(stringIndex);
|
return this.compileIndex(stringIndex);
|
||||||
},
|
},
|
||||||
|
@ -434,15 +434,6 @@ function bytesToString(bytes) {
|
|||||||
return strBuf.join('');
|
return strBuf.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function stringToArray(str) {
|
|
||||||
var length = str.length;
|
|
||||||
var array = new Uint16Array(length);
|
|
||||||
for (var i = 0; i < length; ++i) {
|
|
||||||
array[i] = str.charCodeAt(i);
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringToBytes(str) {
|
function stringToBytes(str) {
|
||||||
var length = str.length;
|
var length = str.length;
|
||||||
var bytes = new Uint8Array(length);
|
var bytes = new Uint8Array(length);
|
||||||
|
Loading…
Reference in New Issue
Block a user