Skip to content

Commit 68bc360

Browse files
committed
create font onlt if font size is provided - fix crash
1 parent cdd2df6 commit 68bc360

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function VictoryChartLabel({x, y, text, color, fontSize, fontWeight, lineHeight,
2929
const lineFontWeight = fontWeight?.[index];
3030
const lineLineHeight = lineHeight?.[index];
3131
const typeface = lineFontWeight === 'bold' ? boldTypeface : regularTypeface;
32-
const lineFont = typeface ? Skia.Font(typeface, lineFontSize) : null;
32+
const lineFont = typeface && lineFontSize ? Skia.Font(typeface, lineFontSize) : null;
3333
const fontMetrics = lineFont?.getMetrics();
3434
const lineWidth = lineFont?.getGlyphWidths(lineFont.getGlyphIDs(line)).reduce((totalWidth, width) => totalWidth + width, 0) ?? 0;
3535
const customLineHeight = lineLineHeight ? lineLineHeight * (lineFontSize ?? 0) : 0;

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartLegend.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function VictoryChartLegend({x, y, entries, gutter, symbolSpacer}: VictoryChartL
2727
const processedEntries = entries.reduce(
2828
(acc, {text, color, fontSize, fontWeight, symbolColor, symbolSize}) => {
2929
const typeface = fontWeight === 'bold' ? boldTypeface : regularTypeface;
30-
const font = typeface ? Skia.Font(typeface, fontSize) : null;
30+
const font = typeface && fontSize ? Skia.Font(typeface, fontSize) : null;
3131
const fontMetrics = font?.getMetrics();
3232
const lineHeight = fontMetrics ? fontMetrics.ascent + fontMetrics.descent + fontMetrics.leading : 0;
3333
const symbolX = acc.x;

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/parsers/victoryAxisParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function parseVictoryAxisNode(tnode: TNode, typeface: SkTypeface | null, rootPro
2323
const labelColor = style?.tickLabels?.fill !== undefined ? String(style.tickLabels.fill) : undefined;
2424
const labelOffset = style?.tickLabels?.padding !== undefined ? Number(style.tickLabels.padding) : undefined;
2525
const fontSize = style?.tickLabels?.fontSize !== undefined ? Number(style.tickLabels.fontSize) : undefined;
26-
const font = typeface ? Skia.Font(typeface, fontSize) : null;
26+
const font = typeface && fontSize ? Skia.Font(typeface, fontSize) : null;
2727

2828
if (isDependentAxis) {
2929
return isHorizontal

0 commit comments

Comments
 (0)