sales-frontend-utils 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -226,13 +226,15 @@ interface ConvertTextToImgParams {
226
226
  fontColor?: string;
227
227
  /** 폰트 두께 (지정하지 않으면 기본값 bold) */
228
228
  fontWeight?: string;
229
+ /** 폰트 패밀리 (지정하지 않으면 기본값 ) */
230
+ fontFamily?: string;
229
231
  }
230
232
  /**
231
233
  * 텍스트를 이미지(Base64)로 변환하는 함수
232
234
  * @param params - 변환에 필요한 파라미터 객체
233
235
  * @returns Base64로 인코딩된 이미지 데이터 URL
234
236
  */
235
- declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight }: ConvertTextToImgParams) => string;
237
+ declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight, fontFamily }: ConvertTextToImgParams) => string;
236
238
  declare function drawImageResizeCentered(base64: string, size: {
237
239
  canvasWidth: number;
238
240
  canvasHeight: number;
package/dist/index.d.ts CHANGED
@@ -226,13 +226,15 @@ interface ConvertTextToImgParams {
226
226
  fontColor?: string;
227
227
  /** 폰트 두께 (지정하지 않으면 기본값 bold) */
228
228
  fontWeight?: string;
229
+ /** 폰트 패밀리 (지정하지 않으면 기본값 ) */
230
+ fontFamily?: string;
229
231
  }
230
232
  /**
231
233
  * 텍스트를 이미지(Base64)로 변환하는 함수
232
234
  * @param params - 변환에 필요한 파라미터 객체
233
235
  * @returns Base64로 인코딩된 이미지 데이터 URL
234
236
  */
235
- declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight }: ConvertTextToImgParams) => string;
237
+ declare const convertTextToImg: ({ targetStr, canvasWidth, canvasHeight, backgroundColor, fontColor, fontSize, fontWeight, fontFamily }: ConvertTextToImgParams) => string;
236
238
  declare function drawImageResizeCentered(base64: string, size: {
237
239
  canvasWidth: number;
238
240
  canvasHeight: number;
package/dist/index.js CHANGED
@@ -449,7 +449,8 @@ var convertTextToImg = ({
449
449
  backgroundColor,
450
450
  fontColor,
451
451
  fontSize,
452
- fontWeight
452
+ fontWeight,
453
+ fontFamily = `'Malgun Gothic', '\uB9D1\uC740 \uACE0\uB515', 'sans-serif', 'Arial'`
453
454
  }) => {
454
455
  const canvas = document.createElement("canvas");
455
456
  const ctx = canvas.getContext("2d");
@@ -465,8 +466,9 @@ var convertTextToImg = ({
465
466
  ctx.fillRect(0, 0, canvas.width, canvas.height);
466
467
  }
467
468
  ctx.fillStyle = fontColor ?? "black";
468
- ctx.font = `${fontSize ?? 75}px ${fontWeight ?? "bold"}`;
469
469
  ctx.textAlign = "center";
470
+ ctx.font = `${fontWeight ?? "bold"} ${fontSize ?? 75}px ${fontFamily}`;
471
+ console.log("font", `${fontWeight ?? "bold"} ${fontSize ?? 75}px ${fontFamily}`);
470
472
  ctx.textBaseline = "middle";
471
473
  ctx.fillText(targetStr, canvas.width / 2, canvas.height / 2);
472
474
  return canvas.toDataURL();