Comparing version
@@ -12,11 +12,7 @@ /** | ||
box1 = box(text[0], { | ||
font: options.font | ||
}); | ||
box1 = box(text[0], options); | ||
//The second box | ||
box2 = box(text[1], { | ||
font: options.font, | ||
offsetX: box1.width | ||
}); | ||
// The second box needs to be drawn a bit to the right. | ||
options.offsetX = box1.width; | ||
box2 = box(text[1], options); | ||
@@ -32,4 +28,5 @@ width = box1.width + box2.width; | ||
text1: box1.textPath, | ||
text2: box2.textPath | ||
text2: box2.textPath, | ||
color: options.color | ||
}); | ||
}; |
13
index.js
@@ -19,3 +19,12 @@ /** | ||
fontSize: '11' | ||
} | ||
}, | ||
color: { | ||
left: '#555', | ||
right: '#4c1', | ||
font: '#fff', | ||
shadow: '#010101' | ||
}, | ||
paddingX: 6, | ||
paddingY: 6, | ||
offsetX: 0 | ||
}; | ||
@@ -34,3 +43,3 @@ defaultOptions = _.merge(defaultOptions, options); | ||
defaultOptions.font.loadedFont = loadedFont; | ||
res = badge(defaultOptions.text, {font: defaultOptions.font}); | ||
res = badge(defaultOptions.text, defaultOptions); | ||
return callback(null, res); | ||
@@ -37,0 +46,0 @@ } |
@@ -5,2 +5,8 @@ /** | ||
/** | ||
* Helper function factory to determine the scaling factor of a font. | ||
* @param unitsPerEM This number comes from the font file itself. It specifies the conversion of the font-face units into EM. (ie: the resolution of the font) | ||
* @param pixelsPerEM This number is contextual, and is basically the font size. | ||
* @returns {unitToPixels} a pre-baked helper function that converts font units to pixels at a given font size. | ||
*/ | ||
function calculator(unitsPerEM, pixelsPerEM) { | ||
@@ -13,8 +19,15 @@ var scaleFactor = pixelsPerEM / unitsPerEM; | ||
module.exports = function (message, options) { | ||
/** | ||
* Given a font face, and all the desired parameters for this badge fragment, determine how tall and wide it should be, | ||
* as well as the paths for drawing the text. | ||
* @param message The text to render on this badge fragment | ||
* @param options Padding, Offset, Font and attributes. | ||
* @returns {{width: *, height: *, textPath: (XML|string|void)}} The bounding box for this fragment, with the rendered text centered vertically and horizontally | ||
*/ | ||
module.exports = function getBoundingBox(message, options) { | ||
var font = options.font.loadedFont, | ||
offsetX = options.offsetX || 0, // It's all horizontal, so no need for offsetY | ||
paddingX = options.paddingX || 6, | ||
paddingY = options.paddingY || 6, | ||
fontSize = options.font.fontSize || 11, | ||
offsetX = options.offsetX, // It's all horizontal, so no need for offsetY | ||
paddingX = options.paddingX, | ||
paddingY = options.paddingY, | ||
fontSize = options.font.fontSize, | ||
heightInUnits, widthInUnits, | ||
@@ -21,0 +34,0 @@ heightInPixels, widthInPixels, |
{ | ||
"name": "openbadge", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Create SVG badges for your github projects", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified ...yet...\" && exit 1" | ||
}, | ||
"author": "@lennymarkus", | ||
"license": "ISC", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"lodash": "^3.10.1", | ||
"opentype.js": "^0.6.0" | ||
} | ||
}, | ||
"devDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/lmarkus/openBadge.git" | ||
}, | ||
"keywords": [ | ||
"shield.io", | ||
"fury.io", | ||
"badge", | ||
"github", | ||
"shield", | ||
"svg" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/lmarkus/openBadge/issues" | ||
}, | ||
"homepage": "https://github.com/lmarkus/openBadge#readme" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2386796
8.85%23
15%0
-100%155
13.97%1
-50%1
-50%1
-50%104
Infinity%1
-50%