Add a createPostTable function and remove the useless join('') calls
This commit is contained in:
parent
7b454d403b
commit
59e178946a
64
fonts.js
64
fonts.js
@ -298,8 +298,7 @@ var Font = (function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function createOS2Table() {
|
function createOS2Table() {
|
||||||
var OS2 = stringToArray(
|
return "\x00\x03" + // version
|
||||||
"\x00\x03" + // version
|
|
||||||
"\x02\x24" + // xAvgCharWidth
|
"\x02\x24" + // xAvgCharWidth
|
||||||
"\x01\xF4" + // usWeightClass
|
"\x01\xF4" + // usWeightClass
|
||||||
"\x00\x05" + // usWidthClass
|
"\x00\x05" + // usWidthClass
|
||||||
@ -335,19 +334,23 @@ var Font = (function () {
|
|||||||
"\x00\x00" + // sCapHeight
|
"\x00\x00" + // sCapHeight
|
||||||
"\x00\x01" + // usDefaultChar
|
"\x00\x01" + // usDefaultChar
|
||||||
"\x00\xCD" + // usBreakChar
|
"\x00\xCD" + // usBreakChar
|
||||||
"\x00\x02" // usMaxContext
|
"\x00\x02"; // usMaxContext
|
||||||
);
|
};
|
||||||
return OS2;
|
|
||||||
|
function createPostTable() {
|
||||||
|
TODO("Fill with real values from the font dict");
|
||||||
|
|
||||||
|
return "\x00\x03\x00\x00" + // Version number
|
||||||
|
"\x00\x00\x01\x00" + // italicAngle
|
||||||
|
"\x00\x00" + // underlinePosition
|
||||||
|
"\x00\x00" + // underlineThickness
|
||||||
|
"\x00\x00\x00\x00" + // isFixedPitch
|
||||||
|
"\x00\x00\x00\x00" + // minMemType42
|
||||||
|
"\x00\x00\x00\x00" + // maxMemType42
|
||||||
|
"\x00\x00\x00\x00" + // minMemType1
|
||||||
|
"\x00\x00\x00\x00"; // maxMemType1
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A bunch of the OpenType code is duplicate between this class and the
|
|
||||||
* TrueType code, this is intentional and will merge in a future version
|
|
||||||
* where all the code relative to OpenType will probably have its own
|
|
||||||
* class and will take decision without the Fonts consent.
|
|
||||||
* But at the moment it allows to develop around the TrueType rewriting
|
|
||||||
* on the fly without messing up with the 'regular' Type1 to OTF conversion.
|
|
||||||
*/
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
name: null,
|
name: null,
|
||||||
font: null,
|
font: null,
|
||||||
@ -512,10 +515,9 @@ var Font = (function () {
|
|||||||
createOpenTypeHeader("\x00\x01\x00\x00", ttf, offsets, numTables);
|
createOpenTypeHeader("\x00\x01\x00\x00", ttf, offsets, numTables);
|
||||||
|
|
||||||
// Insert the missing table
|
// Insert the missing table
|
||||||
var OS2 = createOS2Table();
|
|
||||||
tables.push({
|
tables.push({
|
||||||
tag: "OS/2",
|
tag: "OS/2",
|
||||||
data: OS2
|
data: stringToArray(createOS2Table)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Replace the old CMAP table with a shiny new one
|
// Replace the old CMAP table with a shiny new one
|
||||||
@ -523,20 +525,9 @@ var Font = (function () {
|
|||||||
|
|
||||||
// Rewrite the 'post' table if needed
|
// Rewrite the 'post' table if needed
|
||||||
if (!post) {
|
if (!post) {
|
||||||
post =
|
tables.push({
|
||||||
"\x00\x03\x00\x00" + // Version number
|
|
||||||
"\x00\x00\x01\x00" + // italicAngle
|
|
||||||
"\x00\x00" + // underlinePosition
|
|
||||||
"\x00\x00" + // underlineThickness
|
|
||||||
"\x00\x00\x00\x00" + // isFixedPitch
|
|
||||||
"\x00\x00\x00\x00" + // minMemType42
|
|
||||||
"\x00\x00\x00\x00" + // maxMemType42
|
|
||||||
"\x00\x00\x00\x00" + // minMemType1
|
|
||||||
"\x00\x00\x00\x00"; // maxMemType1
|
|
||||||
|
|
||||||
tables.unshift({
|
|
||||||
tag: "post",
|
tag: "post",
|
||||||
data: stringToArray(post)
|
data: stringToArray(createPostTable())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +619,7 @@ var Font = (function () {
|
|||||||
font.data, // PostScript Font Program
|
font.data, // PostScript Font Program
|
||||||
OS2, // OS/2 and Windows Specific metrics
|
OS2, // OS/2 and Windows Specific metrics
|
||||||
cmap, // Character to glyphs mapping
|
cmap, // Character to glyphs mapping
|
||||||
head, // Font eader
|
head, // Font header
|
||||||
hhea, // Horizontal header
|
hhea, // Horizontal header
|
||||||
hmtx, // Horizontal metrics
|
hmtx, // Horizontal metrics
|
||||||
maxp, // Maximum profile
|
maxp, // Maximum profile
|
||||||
@ -728,17 +719,7 @@ var Font = (function () {
|
|||||||
createTableEntry(otf, offsets, "name", name);
|
createTableEntry(otf, offsets, "name", name);
|
||||||
|
|
||||||
/** POST */
|
/** POST */
|
||||||
// TODO: get those informations from the FontInfo structure
|
post = stringToArray(createPostTable());
|
||||||
post = "\x00\x03\x00\x00" + // Version number
|
|
||||||
"\x00\x00\x01\x00" + // italicAngle
|
|
||||||
"\x00\x00" + // underlinePosition
|
|
||||||
"\x00\x00" + // underlineThickness
|
|
||||||
"\x00\x00\x00\x00" + // isFixedPitch
|
|
||||||
"\x00\x00\x00\x00" + // minMemType42
|
|
||||||
"\x00\x00\x00\x00" + // maxMemType42
|
|
||||||
"\x00\x00\x00\x00" + // minMemType1
|
|
||||||
"\x00\x00\x00\x00"; // maxMemType1
|
|
||||||
post = stringToArray(post);
|
|
||||||
createTableEntry(otf, offsets, "post", post);
|
createTableEntry(otf, offsets, "post", post);
|
||||||
|
|
||||||
// Once all the table entries header are written, dump the data!
|
// Once all the table entries header are written, dump the data!
|
||||||
@ -1480,7 +1461,6 @@ CFF.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var charstringsIndex = this.createCFFIndexHeader([[0x40, 0x0E]].concat(glyphs), true);
|
var charstringsIndex = this.createCFFIndexHeader([[0x40, 0x0E]].concat(glyphs), true);
|
||||||
charstringsIndex = charstringsIndex.join(" ").split(" "); // XXX why?
|
|
||||||
|
|
||||||
//Top Dict Index
|
//Top Dict Index
|
||||||
var topDictIndex = [
|
var topDictIndex = [
|
||||||
@ -1514,7 +1494,6 @@ CFF.prototype = {
|
|||||||
var privateOffset = charstringsOffset + charstringsIndex.length;
|
var privateOffset = charstringsOffset + charstringsIndex.length;
|
||||||
topDictIndex = topDictIndex.concat(this.encodeNumber(privateOffset));
|
topDictIndex = topDictIndex.concat(this.encodeNumber(privateOffset));
|
||||||
topDictIndex.push(18); // Private
|
topDictIndex.push(18); // Private
|
||||||
topDictIndex = topDictIndex.join(" ").split(" ");
|
|
||||||
|
|
||||||
var indexes = [
|
var indexes = [
|
||||||
topDictIndex, stringsIndex,
|
topDictIndex, stringsIndex,
|
||||||
@ -1544,7 +1523,6 @@ CFF.prototype = {
|
|||||||
139, 12, 14,
|
139, 12, 14,
|
||||||
28, 0, 55, 19
|
28, 0, 55, 19
|
||||||
]);
|
]);
|
||||||
privateData = privateData.join(" ").split(" ");
|
|
||||||
cff.set(privateData, currentOffset);
|
cff.set(privateData, currentOffset);
|
||||||
currentOffset += privateData.length;
|
currentOffset += privateData.length;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user