Skip to content

Commit

Permalink
Enhanced SFNT properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
snb2013 committed Jul 18, 2013
1 parent 4c9b8d3 commit c39bf48
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/sfnt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 16,6 @@ var Font = function () {
this.lineGap = 90;
this.lowestRecPPEM = 8;
this.macStyle = 0;
this.minLeftSideBearing = 0;
this.minRightSideBearing = -1;
this.modifiedDate = new Date();
this.panose = {
familyType: 2, // Latin Text
Expand All @@ -33,21 31,19 @@ var Font = function () {
};
this.revision = 1;
this.sfntNames = [];
this.underlinePosition = 0;
this.underlineThickness = 0;
this.unitsPerEm = 1000;
this.weightClass = 400; // normal
this.width = 1000;
this.widthClass = 5; // Medium (normal)
this.xMaxExtent = 1064;
this.ySubscriptXOffset = 0;
this.ySuperscriptXOffset = 0;

//getters and setters

Object.defineProperty(this, 'descent', {
get: function () {
return this.int_descent || -151;
return this.int_descent || -150;
},
set: function (value) {
this.int_descent = parseInt(Math.round(-Math.abs(value)), 10);
Expand Down Expand Up @@ -217,6 213,24 @@ var Font = function () {
return maxExtent !== undefined ? maxExtent : this.width;
}
});

Object.defineProperty(this, 'lineGap', {
get: function () {
return parseInt(this.int_lineGap !== undefined ? this.lineGap : ((this.ascent - this.descent) * 0.09), 10);
},
set: function (value) {
this.int_lineGap = value;
}
});

Object.defineProperty(this, 'underlinePosition', {
get: function () {
return parseInt(this.int_underlinePosition !== undefined ? this.underlinePosition : ((this.ascent - this.descent) * 0.01), 10);
},
set: function (value) {
this.int_underlinePosition = value;
}
});
};


Expand Down

0 comments on commit c39bf48

Please sign in to comment.