Skip to content

Commit

Permalink
Register font globally on initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Sep 5, 2024
1 parent 1f9c62b commit 2cdf87d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/backend/compare/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { medianUnsorted } from '../../shared/stats.js';
import { robustPath } from '../util.js';
import { siteAesthetics } from '../../shared/aesthetics.js';
import { Chart, ChartConfiguration, registerables } from 'chart.js';
import { registerFont } from 'canvas';

const fullyTransparent = 'rgba(0, 0, 0, 0)';

Expand All @@ -28,6 +29,14 @@ const perEntryHeight = 34;
/** Register all standard plugins. This is for convenience. */
function initChartJS(): void {
Chart.register(...registerables);
registerFont(robustPath('../dist/roboto-hinted/Roboto-Regular.ttf'), {
family: 'Roboto',
weight: '400'
});
registerFont(robustPath('../dist/roboto-hinted/Roboto-Bold.ttf'), {
family: 'Roboto',
weight: '700'
});
}
initChartJS();

Expand Down Expand Up @@ -220,15 +229,6 @@ export function createCanvas(settings: CanvasSettings): ChartJSNodeCanvas {
}

const canvas = new ChartJSNodeCanvas(canvasOptions);

canvas.registerFont(robustPath('../dist/roboto-hinted/Roboto-Regular.ttf'), {
family: 'Roboto',
weight: '400'
});
canvas.registerFont(robustPath('../dist/roboto-hinted/Roboto-Bold.ttf'), {
family: 'Roboto',
weight: '700'
});
return canvas;
}

Expand Down

0 comments on commit 2cdf87d

Please sign in to comment.