Browse Source

Make `Type1Font` more class-like, by adding closure

*Note:* Ignoring whitespace should simplify reviewing a great deal.
Jonas Jenwald 9 years ago
parent
commit
c40df8a393
  1. 13
      src/core/fonts.js

13
src/core/fonts.js

@ -3637,8 +3637,9 @@ var CFFStandardStrings = [
]; ];
// Type1Font is also a CIDFontType0. // Type1Font is also a CIDFontType0.
var Type1Font = function Type1Font(name, file, properties) { var Type1Font = (function Type1FontClosure() {
// Some bad generators embed pfb file as is, we have to strip 6-byte headers. function Type1Font(name, file, properties) {
// Some bad generators embed pfb file as is, we have to strip 6-byte header.
// Also, length1 and length2 might be off by 6 bytes as well. // Also, length1 and length2 might be off by 6 bytes as well.
// http://www.math.ubc.ca/~cass/piscript/type1.pdf // http://www.math.ubc.ca/~cass/piscript/type1.pdf
var PFB_HEADER_SIZE = 6; var PFB_HEADER_SIZE = 6;
@ -3679,7 +3680,7 @@ var Type1Font = function Type1Font(name, file, properties) {
this.data = this.wrap(name, type2Charstrings, this.charstrings, this.data = this.wrap(name, type2Charstrings, this.charstrings,
subrs, properties); subrs, properties);
this.seacs = this.getSeacs(data.charstrings); this.seacs = this.getSeacs(data.charstrings);
}; }
Type1Font.prototype = { Type1Font.prototype = {
get numGlyphs() { get numGlyphs() {
@ -3762,7 +3763,8 @@ Type1Font.prototype = {
return type2Subrs; return type2Subrs;
}, },
wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) { wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs,
properties) {
var cff = new CFF(); var cff = new CFF();
cff.header = new CFFHeader(1, 0, 4, 4); cff.header = new CFFHeader(1, 0, 4, 4);
@ -3863,6 +3865,9 @@ Type1Font.prototype = {
} }
}; };
return Type1Font;
})();
var CFFFont = (function CFFFontClosure() { var CFFFont = (function CFFFontClosure() {
function CFFFont(file, properties) { function CFFFont(file, properties) {
this.properties = properties; this.properties = properties;

Loading…
Cancel
Save