Fix glyph selection for CID fonts that don't actually have CID font files.
This commit is contained in:
parent
d1cea4a166
commit
e128f8bb47
46
src/fonts.js
46
src/fonts.js
@ -5712,9 +5712,9 @@ var CFFFont = (function CFFFontClosure() {
|
||||
this.properties = properties;
|
||||
|
||||
var parser = new CFFParser(file, properties);
|
||||
var cff = parser.parse();
|
||||
var compiler = new CFFCompiler(cff);
|
||||
this.readExtra(cff);
|
||||
this.cff = parser.parse();
|
||||
var compiler = new CFFCompiler(this.cff);
|
||||
this.readExtra();
|
||||
try {
|
||||
this.data = compiler.compile();
|
||||
} catch (e) {
|
||||
@ -5726,12 +5726,10 @@ var CFFFont = (function CFFFontClosure() {
|
||||
}
|
||||
|
||||
CFFFont.prototype = {
|
||||
readExtra: function CFFFont_readExtra(cff) {
|
||||
readExtra: function CFFFont_readExtra() {
|
||||
// charstrings contains info about glyphs (one element per glyph
|
||||
// containing mappings for {unicode, width})
|
||||
var charset = cff.charset.charset;
|
||||
var encoding = cff.encoding ? cff.encoding.encoding : null;
|
||||
var charstrings = this.getCharStrings(charset, encoding);
|
||||
var charstrings = this.getCharStrings();
|
||||
|
||||
// create the mapping between charstring and glyph id
|
||||
var glyphIds = [];
|
||||
@ -5740,21 +5738,39 @@ var CFFFont = (function CFFFontClosure() {
|
||||
|
||||
this.charstrings = charstrings;
|
||||
this.glyphIds = glyphIds;
|
||||
this.seacs = cff.seacs;
|
||||
this.seacs = this.cff.seacs;
|
||||
},
|
||||
getCharStrings: function CFFFont_getCharStrings(charsets, encoding) {
|
||||
getCharStrings: function CFFFont_getCharStrings() {
|
||||
var cff = this.cff;
|
||||
var charsets = cff.charset.charset;
|
||||
var encoding = cff.encoding ? cff.encoding.encoding : null;
|
||||
var charstrings = [];
|
||||
var unicodeUsed = [];
|
||||
var unassignedUnicodeItems = [];
|
||||
var inverseEncoding = [];
|
||||
// CID fonts don't have an encoding.
|
||||
if (encoding !== null)
|
||||
var gidStart = 0;
|
||||
// Even though the CFF font may not actually be a CID font is could have
|
||||
// CID information in the font descriptor.
|
||||
if (this.properties.cidSystemInfo) {
|
||||
// According to section 9.7.4.2 if the font is actually a CID font then
|
||||
// we should use the charset to map CIDs to GIDs. If it is not actually
|
||||
// a CID font then CIDs can be mapped directly to GIDs.
|
||||
if (this.cff.isCIDFont) {
|
||||
inverseEncoding = charsets;
|
||||
} else {
|
||||
for (var i = 0, ii = charsets.length; i < charsets.length; i++) {
|
||||
inverseEncoding.push(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var charcode in encoding)
|
||||
inverseEncoding[encoding[charcode]] = charcode | 0;
|
||||
else
|
||||
inverseEncoding = charsets;
|
||||
var i = charsets[0] == '.notdef' ? 1 : 0;
|
||||
for (var ii = charsets.length; i < ii; i++) {
|
||||
if (charsets[0] === '.notedef') {
|
||||
gidStart = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = gidStart, ii = charsets.length; i < ii; i++) {
|
||||
var glyph = charsets[i];
|
||||
|
||||
var code = inverseEncoding[i];
|
||||
|
BIN
test/pdfs/bug816075.pdf
Normal file
BIN
test/pdfs/bug816075.pdf
Normal file
Binary file not shown.
@ -1012,6 +1012,13 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "bug816075",
|
||||
"file": "pdfs/bug816075.pdf",
|
||||
"md5": "7ec87c115c1f9ec41234cc7002555e82",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"about": "A CIDFontType0 font with a CFF font that isn't actually CID."
|
||||
},
|
||||
{ "id": "noembed-identity-2",
|
||||
"file": "pdfs/noembed-identity-2.pdf",
|
||||
"md5": "13b7d9ab9579d45c10bc8d499d087f21",
|
||||
|
Loading…
Reference in New Issue
Block a user