mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
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
3 changed files with 38 additions and 15 deletions
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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue