Skip to content

Commit

Permalink
Merge pull request mozilla#2913 from yurydelendik/combine-os2valid
Browse files Browse the repository at this point in the history
Removes isOS2Valid; resets fsType
  • Loading branch information
brendandahl committed Mar 11, 2013
2 parents 9ee5a66 + ad3390c commit 1f9b28f
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/fonts.js
Expand Up @@ -2784,6 +2784,14 @@ var Font = (function FontClosure() {
if (firstChar > lastChar) {
return false;
}
stream.getBytes(6); // skipping sTypoAscender/Descender/LineGap
var usWinAscent = int16(stream.getBytes(2));
if (usWinAscent === 0) { // makes font unreadable by windows
return false;
}

// OS/2 appears to be valid, resetting some fields
os2.data[8] = os2.data[9] = 0; // IE rejects fonts if fsType != 0
return true;
}

Expand Down Expand Up @@ -3633,16 +3641,6 @@ var Font = (function FontClosure() {
return names;
}

function isOS2Valid(os2Table) {
var data = os2Table.data;
// usWinAscent == 0 makes font unreadable by windows
var usWinAscent = (data[74] << 8) | data[75];
if (usWinAscent === 0)
return false;

return true;
}

var TTOpsStackDeltas = [
0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5,
-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1,
Expand Down Expand Up @@ -3837,12 +3835,6 @@ var Font = (function FontClosure() {
// of missing tables
createOpenTypeHeader(header.version, ttf, numTables);

// Invalid OS/2 can break the font for the Windows
if (os2 && !isOS2Valid(os2)) {
tables.splice(tables.indexOf(os2), 1);
os2 = null;
}

// Ensure the hmtx table contains the advance width and
// sidebearings information for numGlyphs in the maxp table
font.pos = (font.start || 0) + maxp.offset;
Expand Down

0 comments on commit 1f9b28f

Please sign in to comment.