Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/text-rendering/CanvasFontHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const getFontFamilies = (): FontFamilyMap => {
*/
export const init = (
c: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
mc: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
mc?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
): void => {
if (initialized === true) {
return;
Expand All @@ -130,7 +130,7 @@ export const init = (
}

context = c;
measureContext = mc;
measureContext = mc ?? c;

// Register the default 'sans-serif' font face
const defaultMetrics: FontMetrics = {
Expand Down
9 changes: 7 additions & 2 deletions src/core/text-rendering/CanvasTextRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { assertTruthy } from '../../utils.js';
import type { Stage } from '../Stage.js';
import type { TextLineStruct, TextRenderInfo } from './TextRenderer.js';
import type {
FontHandler,
TextLineStruct,
TextRenderInfo,
} from './TextRenderer.js';
import * as CanvasFontHandler from './CanvasFontHandler.js';
import type { CoreTextNodeProps } from '../CoreTextNode.js';
import { hasZeroWidthSpace } from './Utils.js';
Expand All @@ -9,6 +13,7 @@ import { mapTextLayout } from './TextLayoutEngine.js';
const MAX_TEXTURE_DIMENSION = 4096;

const type = 'canvas' as const;
const font: FontHandler = CanvasFontHandler;

let canvas: HTMLCanvasElement | OffscreenCanvas | null = null;
let context:
Expand Down Expand Up @@ -238,7 +243,7 @@ const renderQuads = (): void => {
*/
const CanvasTextRenderer = {
type,
font: CanvasFontHandler,
font,
renderText,
addQuads,
renderQuads,
Expand Down
Loading