-
Notifications
You must be signed in to change notification settings - Fork 515
Fixed metadata that enables fonts to be recognised as a family (tested!) #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0428d1d
8f3861d
e324ce6
1f1383a
6c07107
a54d31d
5a320e5
067bbe3
0be81c0
6f8f855
9d5c174
0f23a24
e5ec656
db61eab
e4f8ee7
67ecfeb
81b2508
51e8b86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,8 @@ function createDefaultNamesInfo(options) { | |
* @property {Number} ascender | ||
* @property {Number} descender | ||
* @property {Number} createdTimestamp | ||
* @property {string=} weightClass | ||
* @property {Number} weightClass | ||
* @property {Number} italicAngle | ||
* @property {string=} widthClass | ||
* @property {string=} fsSelection | ||
*/ | ||
|
@@ -87,11 +88,45 @@ function Font(options) { | |
this.ascender = options.ascender; | ||
this.descender = options.descender; | ||
this.createdTimestamp = options.createdTimestamp; | ||
this.italicAngle = options.italicAngle || 0; | ||
this.weightClass = options.weightClass || 0; | ||
|
||
let selection = 0; | ||
if (options.fsSelection) { | ||
mattlag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
selection = options.fsSelection; | ||
} else { | ||
if (this.italicAngle < 0) { | ||
selection |= this.fsSelectionValues.ITALIC; | ||
} else if (this.italicAngle > 0) { | ||
selection |= this.fsSelectionValues.OBLIQUE; | ||
} | ||
if (this.weightClass >= 600) { | ||
selection |= this.fsSelectionValues.BOLD; | ||
} | ||
if (selection == 0) { | ||
selection = this.fsSelectionValues.REGULAR; | ||
} | ||
} | ||
|
||
if (!options.panose || !Array.isArray(options.panose)) { | ||
options.panose = [0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
} | ||
|
||
this.tables = Object.assign(options.tables, { | ||
os2: Object.assign({ | ||
usWeightClass: options.weightClass || this.usWeightClasses.MEDIUM, | ||
usWidthClass: options.widthClass || this.usWidthClasses.MEDIUM, | ||
fsSelection: options.fsSelection || this.fsSelectionValues.REGULAR, | ||
bFamilyType: options.panose[0] || 0, | ||
bSerifStyle: options.panose[1] || 0, | ||
bWeight: options.panose[2] || 0, | ||
bProportion: options.panose[3] || 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR introduces names for the individual Panose values. When one sees a property For example with the 4th Panose value
So I would not call it
Edit: Fix wrong name Addendum: The names chosen above are from Panose-1 which was rather simple. But when it has been expanded to be Panose-2 the values became multiple meaning depending on Family Kind. Just looked it up again in Haralambous: Fonts & Encodings, O'Reilly (2007) |
||
bContrast: options.panose[4] || 0, | ||
bStrokeVariation: options.panose[5] || 0, | ||
bArmStyle: options.panose[6] || 0, | ||
bLetterform: options.panose[7] || 0, | ||
bMidline: options.panose[8] || 0, | ||
bXHeight: options.panose[9] || 0, | ||
fsSelection: selection, | ||
}, options.tables.os2) | ||
}); | ||
} | ||
|
@@ -562,6 +597,7 @@ Font.prototype.download = function(fileName) { | |
fs.writeFileSync(fileName, buffer); | ||
} | ||
}; | ||
|
||
/** | ||
* @private | ||
*/ | ||
|
@@ -578,6 +614,19 @@ Font.prototype.fsSelectionValues = { | |
OBLIQUE: 0x200 //512 | ||
}; | ||
|
||
/** | ||
* @private | ||
*/ | ||
Font.prototype.macStyleValues = { | ||
BOLD: 0x001, //1 | ||
ITALIC: 0x002, //2 | ||
UNDERLINE: 0x004, //4 | ||
OUTLINED: 0x008, //8 | ||
SHADOW: 0x010, //16 | ||
CONDENSED: 0x020, //32 | ||
EXTENDED: 0x040, //64 | ||
}; | ||
|
||
/** | ||
* @private | ||
*/ | ||
|
Uh oh!
There was an error while loading. Please reload this page.