Merge pull request #3187 from brendandahl/cid-glyph-selection
Fix glyph selection for CID fonts that don't actually have CID font files.
This commit is contained in:
commit
ea6333028a
46
src/fonts.js
46
src/fonts.js
@ -5712,9 +5712,9 @@ var CFFFont = (function CFFFontClosure() {
|
|||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|
||||||
var parser = new CFFParser(file, properties);
|
var parser = new CFFParser(file, properties);
|
||||||
var cff = parser.parse();
|
this.cff = parser.parse();
|
||||||
var compiler = new CFFCompiler(cff);
|
var compiler = new CFFCompiler(this.cff);
|
||||||
this.readExtra(cff);
|
this.readExtra();
|
||||||
try {
|
try {
|
||||||
this.data = compiler.compile();
|
this.data = compiler.compile();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -5726,12 +5726,10 @@ var CFFFont = (function CFFFontClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CFFFont.prototype = {
|
CFFFont.prototype = {
|
||||||
readExtra: function CFFFont_readExtra(cff) {
|
readExtra: function CFFFont_readExtra() {
|
||||||
// charstrings contains info about glyphs (one element per glyph
|
// charstrings contains info about glyphs (one element per glyph
|
||||||
// containing mappings for {unicode, width})
|
// containing mappings for {unicode, width})
|
||||||
var charset = cff.charset.charset;
|
var charstrings = this.getCharStrings();
|
||||||
var encoding = cff.encoding ? cff.encoding.encoding : null;
|
|
||||||
var charstrings = this.getCharStrings(charset, encoding);
|
|
||||||
|
|
||||||
// create the mapping between charstring and glyph id
|
// create the mapping between charstring and glyph id
|
||||||
var glyphIds = [];
|
var glyphIds = [];
|
||||||
@ -5740,21 +5738,39 @@ var CFFFont = (function CFFFontClosure() {
|
|||||||
|
|
||||||
this.charstrings = charstrings;
|
this.charstrings = charstrings;
|
||||||
this.glyphIds = glyphIds;
|
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 charstrings = [];
|
||||||
var unicodeUsed = [];
|
var unicodeUsed = [];
|
||||||
var unassignedUnicodeItems = [];
|
var unassignedUnicodeItems = [];
|
||||||
var inverseEncoding = [];
|
var inverseEncoding = [];
|
||||||
// CID fonts don't have an encoding.
|
var gidStart = 0;
|
||||||
if (encoding !== null)
|
// 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)
|
for (var charcode in encoding)
|
||||||
inverseEncoding[encoding[charcode]] = charcode | 0;
|
inverseEncoding[encoding[charcode]] = charcode | 0;
|
||||||
else
|
if (charsets[0] === '.notedef') {
|
||||||
inverseEncoding = charsets;
|
gidStart = 1;
|
||||||
var i = charsets[0] == '.notdef' ? 1 : 0;
|
}
|
||||||
for (var ii = charsets.length; i < ii; i++) {
|
}
|
||||||
|
|
||||||
|
for (var i = gidStart, ii = charsets.length; i < ii; i++) {
|
||||||
var glyph = charsets[i];
|
var glyph = charsets[i];
|
||||||
|
|
||||||
var code = inverseEncoding[i];
|
var code = inverseEncoding[i];
|
||||||
|
BIN
test/pdfs/bug816075.pdf
Normal file
BIN
test/pdfs/bug816075.pdf
Normal file
Binary file not shown.
@ -1019,6 +1019,13 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"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",
|
{ "id": "noembed-identity-2",
|
||||||
"file": "pdfs/noembed-identity-2.pdf",
|
"file": "pdfs/noembed-identity-2.pdf",
|
||||||
"md5": "13b7d9ab9579d45c10bc8d499d087f21",
|
"md5": "13b7d9ab9579d45c10bc8d499d087f21",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user