Add a format100 table for Mac
This commit is contained in:
parent
3dcf65d9df
commit
3726686d22
44
fonts.js
44
fonts.js
@ -437,6 +437,24 @@ var Font = (function () {
|
||||
glyphs.push({ unicode: 0x0000 });
|
||||
var ranges = getRanges(glyphs);
|
||||
|
||||
var numTables = 2;
|
||||
var kFormat100ArraySize = 256;
|
||||
var cmap = "\x00\x00" + // version
|
||||
string16(numTables) + // numTables
|
||||
"\x00\x01" + // platformID
|
||||
"\x00\x00" + // encodingID
|
||||
string32(4 + numTables * 8) + // start of the table record
|
||||
"\x00\x03" + // platformID
|
||||
"\x00\x01" + // encodingID
|
||||
string32(4 + numTables * 8 + 6 + kFormat100ArraySize); // start of the table record
|
||||
|
||||
var format100 = "\x00\x00" + // format
|
||||
string16(6 + kFormat100ArraySize) + // length
|
||||
"\x00\x00"; // language
|
||||
|
||||
for (var i = 0; i < kFormat100ArraySize; i++)
|
||||
format100 += String.fromCharCode(i);
|
||||
|
||||
var headerSize = (12 * 2 + (ranges.length * 4 * 2));
|
||||
var segCount = ranges.length + 1;
|
||||
var segCount2 = segCount * 2;
|
||||
@ -444,18 +462,13 @@ var Font = (function () {
|
||||
var searchEntry = Math.log(segCount) / Math.log(2);
|
||||
var rangeShift = 2 * segCount - searchRange;
|
||||
|
||||
var cmap = "\x00\x00" + // version
|
||||
"\x00\x01" + // numTables
|
||||
"\x00\x03" + // platformID
|
||||
"\x00\x01" + // encodingID
|
||||
"\x00\x00\x00\x0C" + // start of the table record
|
||||
"\x00\x04" + // format
|
||||
string16(headerSize) + // length
|
||||
"\x00\x00" + // languages
|
||||
string16(segCount2) +
|
||||
string16(searchRange) +
|
||||
string16(searchEntry) +
|
||||
string16(rangeShift);
|
||||
var format314 = "\x00\x04" + // format
|
||||
string16(headerSize) + // length
|
||||
"\x00\x00" + // language
|
||||
string16(segCount2) +
|
||||
string16(searchRange) +
|
||||
string16(searchEntry) +
|
||||
string16(rangeShift);
|
||||
|
||||
// Fill up the 4 parallel arrays describing the segments.
|
||||
var startCount = "";
|
||||
@ -481,13 +494,14 @@ var Font = (function () {
|
||||
}
|
||||
}
|
||||
|
||||
startCount += "\xFF\xFF";
|
||||
endCount += "\xFF\xFF";
|
||||
startCount += "\xFF\xFF";
|
||||
idDeltas += "\x00\x01";
|
||||
idRangeOffsets += "\x00\x00";
|
||||
format314 += endCount + "\x00\x00" + startCount +
|
||||
idDeltas + idRangeOffsets + glyphsIds;
|
||||
|
||||
return stringToArray(cmap + endCount + "\x00\x00" + startCount +
|
||||
idDeltas + idRangeOffsets + glyphsIds);
|
||||
return stringToArray(cmap + format100 + format314);
|
||||
};
|
||||
|
||||
function createOS2Table(properties) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* The Type2 reader code below is only used for debugging purpose since Type2
|
||||
* is only a CharString format and is never used directly as a Font file.
|
||||
@ -12,8 +10,6 @@
|
||||
* CharString or to understand the structure of the CFF format.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Build a charset by assigning the glyph name and the human readable form
|
||||
* of the glyph data.
|
||||
@ -388,7 +384,7 @@ function writeToFile(aBytes, aFilePath) {
|
||||
|
||||
var stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
||||
.createInstance(Ci.nsIFileOutputStream);
|
||||
stream.init(file, 0x04 | 0x08 | 0x20, 600, 0);
|
||||
stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
|
||||
|
||||
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
||||
.createInstance(Ci.nsIBinaryOutputStream);
|
||||
|
Loading…
x
Reference in New Issue
Block a user