Ensure that TrueType font tables have uint32
checksums
According to "The table directory" under https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html#Directory, TrueType font tables should have `uint32` checksums. This is something that I noticed, and was initially confused about, while debugging a TrueType issue. As far as I can tell, the current (`int32`) checksums we use doesn't cause any issues in practice. However, I do think that this should be addressed to agree with the specification, and to reduce possible confusion when reading the font code.
This commit is contained in:
parent
21ed8ff71d
commit
d78fae0181
@ -403,9 +403,8 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {
|
|||||||
// checksum
|
// checksum
|
||||||
var checksum = 0;
|
var checksum = 0;
|
||||||
for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
|
for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
|
||||||
var quad = (file[j] << 24) + (file[j + 1] << 16) +
|
var quad = readUint32(file, j);
|
||||||
(file[j + 2] << 8) + file[j + 3];
|
checksum = (checksum + quad) >>> 0;
|
||||||
checksum = (checksum + quad) | 0;
|
|
||||||
}
|
}
|
||||||
writeInt32(file, offset + 4, checksum);
|
writeInt32(file, offset + 4, checksum);
|
||||||
|
|
||||||
@ -1246,7 +1245,7 @@ var Font = (function FontClosure() {
|
|||||||
function readTableEntry(file) {
|
function readTableEntry(file) {
|
||||||
var tag = bytesToString(file.getBytes(4));
|
var tag = bytesToString(file.getBytes(4));
|
||||||
|
|
||||||
var checksum = file.getInt32();
|
var checksum = file.getInt32() >>> 0;
|
||||||
var offset = file.getInt32() >>> 0;
|
var offset = file.getInt32() >>> 0;
|
||||||
var length = file.getInt32() >>> 0;
|
var length = file.getInt32() >>> 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user