Re-creates invalid post table
This commit is contained in:
parent
2335c6c23e
commit
fbe3d71663
26
src/fonts.js
26
src/fonts.js
@ -3170,7 +3170,7 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readGlyphNameMap(post, properties) {
|
function readPostScriptTable(post, properties) {
|
||||||
var start = (font.start ? font.start : 0) + post.offset;
|
var start = (font.start ? font.start : 0) + post.offset;
|
||||||
font.pos = start;
|
font.pos = start;
|
||||||
|
|
||||||
@ -3180,6 +3180,7 @@ var Font = (function FontClosure() {
|
|||||||
font.getBytes(28);
|
font.getBytes(28);
|
||||||
|
|
||||||
var glyphNames;
|
var glyphNames;
|
||||||
|
var valid = true;
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 0x00010000:
|
case 0x00010000:
|
||||||
glyphNames = MacStandardGlyphOrdering;
|
glyphNames = MacStandardGlyphOrdering;
|
||||||
@ -3187,8 +3188,17 @@ var Font = (function FontClosure() {
|
|||||||
case 0x00020000:
|
case 0x00020000:
|
||||||
var numGlyphs = int16(font.getBytes(2));
|
var numGlyphs = int16(font.getBytes(2));
|
||||||
var glyphNameIndexes = [];
|
var glyphNameIndexes = [];
|
||||||
for (var i = 0; i < numGlyphs; ++i)
|
for (var i = 0; i < numGlyphs; ++i) {
|
||||||
glyphNameIndexes.push(int16(font.getBytes(2)));
|
var index = int16(font.getBytes(2));
|
||||||
|
if (index >= 32768) {
|
||||||
|
valid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
glyphNameIndexes.push(index);
|
||||||
|
}
|
||||||
|
if (!valid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
var customNames = [];
|
var customNames = [];
|
||||||
while (font.pos < end) {
|
while (font.pos < end) {
|
||||||
var stringLength = font.getByte();
|
var stringLength = font.getByte();
|
||||||
@ -3211,9 +3221,11 @@ var Font = (function FontClosure() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
warn('Unknown/unsupported post table version ' + version);
|
warn('Unknown/unsupported post table version ' + version);
|
||||||
|
valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
properties.glyphNames = glyphNames;
|
properties.glyphNames = glyphNames;
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isOS2Valid(os2Table) {
|
function isOS2Valid(os2Table) {
|
||||||
@ -3321,7 +3333,11 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
// The 'post' table has glyphs names.
|
// The 'post' table has glyphs names.
|
||||||
if (post) {
|
if (post) {
|
||||||
readGlyphNameMap(post, properties);
|
var valid = readPostScriptTable(post, properties);
|
||||||
|
if (!valid) {
|
||||||
|
tables.splice(tables.indexOf(post), 1);
|
||||||
|
post = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var glyphs, ids;
|
var glyphs, ids;
|
||||||
@ -3598,7 +3614,7 @@ var Font = (function FontClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite the 'post' table if needed
|
// Rewrite the 'post' table if needed
|
||||||
if (requiredTables.indexOf('post') != -1) {
|
if (!post) {
|
||||||
tables.push({
|
tables.push({
|
||||||
tag: 'post',
|
tag: 'post',
|
||||||
data: stringToArray(createPostTable(properties))
|
data: stringToArray(createPostTable(properties))
|
||||||
|
37
test/font/font_post_spec.js
Normal file
37
test/font/font_post_spec.js
Normal file
File diff suppressed because one or more lines are too long
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
<script type="text/javascript" src="font_core_spec.js"></script>
|
<script type="text/javascript" src="font_core_spec.js"></script>
|
||||||
|
<script type="text/javascript" src="font_post_spec.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
'use strict';
|
'use strict';
|
||||||
|
Loading…
Reference in New Issue
Block a user