Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4850,15 +4850,22 @@ function jsPDF(options) {
* @param {string} postScriptName PDF specification full name for the font.
* @param {string} id PDF-document-instance-specific label assinged to the font.
* @param {string} fontStyle Style of the Font.
* @param {number || string} fontWeight Weight of the Font.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

number|string

* @param {Object} encoding Encoding_name-to-Font_metrics_object mapping.
* @function
* @instance
* @memberof jsPDF#
* @name addFont
* @returns {string} fontId
*/
API.addFont = function(postScriptName, fontName, fontStyle, encoding) {
encoding = encoding || "Identity-H";
API.addFont = function(postScriptName, fontName, fontStyle, fontWeight, encoding) {
encoding = encoding || "Identity-H"
if ((fontStyle == 'normal' && fontWeight === 'bold') || (fontStyle == 'bold' && fontWeight == 'normal')) {
throw new Error("Invalid Combination of fontweight and fontstyle");
}
if (fontWeight && fontStyle !== fontWeight) {
fontStyle = fontWeight == 400 ? 'normal' : fontWeight == 700 ? 'bold' : fontStyle + ' ' + fontWeight;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • make sure to also compare with 'normal' and 'bold' strings as fontWeight values.
  • Maybe add a comment that the == vs === is intentional

}
return addFont.call(this, postScriptName, fontName, fontStyle, encoding);
};

Expand Down