MCPcopy
hub / github.com/chartjs/Chart.js / toFont

Function toFont

src/helpers/helpers.options.ts:115–141  ·  view source on GitHub ↗
(options: Partial<FontSpec>, fallback?: Partial<FontSpec>)

Source from the content-addressed store, hash-verified

113 */
114
115export function toFont(options: Partial<FontSpec>, fallback?: Partial<FontSpec>) {
116 options = options || {};
117 fallback = fallback || defaults.font as FontSpec;
118
119 let size = valueOrDefault(options.size, fallback.size);
120
121 if (typeof size === 'string') {
122 size = parseInt(size, 10);
123 }
124 let style = valueOrDefault(options.style, fallback.style);
125 if (style && !('' + style).match(FONT_STYLE)) {
126 console.warn('Invalid font style specified: "' + style + '"');
127 style = undefined;
128 }
129
130 const font = {
131 family: valueOrDefault(options.family, fallback.family),
132 lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),
133 size,
134 style,
135 weight: valueOrDefault(options.weight, fallback.weight),
136 string: ''
137 };
138
139 font.string = toFontString(font);
140 return font;
141}
142
143/**
144 * Evaluates the given `inputs` sequentially and returns the first defined value.

Callers 15

getTitleHeightFunction · 0.85
drawTitleMethod · 0.85
fitMethod · 0.85
_drawMethod · 0.85
drawTitleMethod · 0.85
_computeTitleHeightMethod · 0.85
getTooltipSizeFunction · 0.85
drawTitleMethod · 0.85
_drawColorBoxMethod · 0.85
drawBodyMethod · 0.85

Calls 3

valueOrDefaultFunction · 0.85
toLineHeightFunction · 0.85
toFontStringFunction · 0.85

Tested by

no test coverage detected