From 81380af3415db07e3c8981e5854453efa19af4fa Mon Sep 17 00:00:00 2001 From: Ade Novid Date: Fri, 6 Dec 2024 16:04:50 +0700 Subject: [PATCH] feat(core): expose `usePsPDF`, `loadFont`, and `createCanvas` --- src/components/pdf-text/utils/text-to-image.ts | 4 ++-- src/components/signature-draw/utils/smooth-line.ts | 2 +- src/core/index.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/pdf-text/utils/text-to-image.ts b/src/components/pdf-text/utils/text-to-image.ts index de592a6cac..72f48b2f71 100644 --- a/src/components/pdf-text/utils/text-to-image.ts +++ b/src/components/pdf-text/utils/text-to-image.ts @@ -160,7 +160,7 @@ export default async function generate (options: GenerateOptions, dpi = 1) { context.fillStyle = labelColor for (const line of labelLines) { - context.fillText(line, padding, y) + context.fillText(line, padding, y, maxWidth) y += (labelSize * lineHeight) } @@ -211,7 +211,7 @@ export default async function generate (options: GenerateOptions, dpi = 1) { context.fillStyle = color for (const line of lines) { - context.fillText(line, padding, y) + context.fillText(line, padding, y, maxWidth) y += (fontSize * lineHeight) } diff --git a/src/components/signature-draw/utils/smooth-line.ts b/src/components/signature-draw/utils/smooth-line.ts index 64db75a73e..b12ee0b600 100644 --- a/src/components/signature-draw/utils/smooth-line.ts +++ b/src/components/signature-draw/utils/smooth-line.ts @@ -77,5 +77,5 @@ export class SmoothLine { * @param length */ export function createLines (length: number): SmoothLine[] { - return Array.from({ length }).map((_, i) => new SmoothLine(i / (length * 1.25))) + return Array.from({ length }, (_, i) => new SmoothLine(i / (length * 1.25))) } diff --git a/src/core/index.ts b/src/core/index.ts index 96606798ec..4bf42460b3 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -185,3 +185,15 @@ export { export { useTableQuery, } from '../components/table-static' + +export { + usePspdf, +} from '../components/pspdfkit' + +export { + default as loadFont, +} from '../components/signature-text/utils/load-font' + +export { + createCanvas, +} from '../components/signature-draw/utils/canvas'