* @private
*/
export function _parseFont(options) {
- var size = valueOrDefault(options.fontSize, defaults.fontSize);
- var font = {
+ let size = valueOrDefault(options.fontSize, defaults.fontSize);
+
+ if (typeof size === 'string') {
+ size = parseInt(size, 10);
+ }
+
+ const font = {
family: valueOrDefault(options.fontFamily, defaults.fontFamily),
lineHeight: toLineHeight(valueOrDefault(options.lineHeight, defaults.lineHeight), size),
size: size,
weight: null
});
});
+ it ('should handle a string font size', function() {
+ expect(parseFont({
+ fontFamily: 'bla',
+ lineHeight: 8,
+ fontSize: '21',
+ fontStyle: 'zzz'
+ })).toEqual({
+ family: 'bla',
+ lineHeight: 8 * 21,
+ size: 21,
+ string: 'zzz 21px bla',
+ style: 'zzz',
+ weight: null
+ });
+ });
it('should return null as a font string if fontSize or fontFamily are missing', function() {
const fontFamily = Chart.defaults.fontFamily;
const fontSize = Chart.defaults.fontSize;