diff --git a/plugins/plugin-print/src/index.ts b/plugins/plugin-print/src/index.ts index 6355b171..07f64ee0 100644 --- a/plugins/plugin-print/src/index.ts +++ b/plugins/plugin-print/src/index.ts @@ -27,7 +27,7 @@ const PrintOptionsSchema = z.object({ maxWidth: z.number().optional(), /** the boundary height to draw in */ maxHeight: z.number().optional(), - /** a callback for when complete that ahs the end co-ordinates of the text */ + /** a callback for when complete that has the end co-ordinates of the text */ cb: z .function(z.tuple([z.object({ x: z.number(), y: z.number() })])) .optional(), @@ -35,6 +35,14 @@ const PrintOptionsSchema = z.object({ export type PrintOptions = z.infer; +/** + * Options for {@link print}. + */ +export type PrintOptionsWithFont = PrintOptions & { + /** the BMFont instance */ + font: BmFont; +}; + function xOffsetBasedOnAlignment( font: BmFont, line: string, @@ -133,16 +141,8 @@ export const methods = { * image.print({ font, x: 10, y: 10, text: "Hello world!" }); * ``` */ - print( - image: I, - { - font, - ...options - }: PrintOptions & { - /** the BMFont instance */ - font: BmFont; - } - ) { + print(image: I, options: PrintOptionsWithFont) { + const { font, ...printOptions } = options; let { // eslint-disable-next-line prefer-const x, @@ -154,7 +154,7 @@ export const methods = { maxHeight = Infinity, // eslint-disable-next-line prefer-const cb = () => {}, - } = PrintOptionsSchema.parse(options); + } = PrintOptionsSchema.parse(printOptions); let alignmentX: HorizontalAlign; let alignmentY: VerticalAlign;