embroidery-qc-image 1.0.33 → 1.0.35
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/components/EmbroideryQCImage.d.ts.map +1 -1
- package/dist/index.esm.js +34 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAgLjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiiBD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA2HvD,CAAC;AA8nFF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAuBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAuBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -141,18 +141,30 @@ const loadFont = (fontName) => {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
return new Promise((resolve) => {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
const fontFormats = ['woff2', 'ttf', 'otf'];
|
|
145
|
+
let currentFormatIndex = 0;
|
|
146
|
+
const tryLoadFont = () => {
|
|
147
|
+
if (currentFormatIndex >= fontFormats.length) {
|
|
148
|
+
console.warn(`Could not load font ${fontName} from CDN (tried all formats)`);
|
|
149
|
+
resolve();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const format = fontFormats[currentFormatIndex];
|
|
153
|
+
const fontUrl = `${BASE_URLS.FONT}/${encodeURIComponent(fontName)}.${format}`;
|
|
154
|
+
const fontFace = new FontFace(fontName, `url(${fontUrl})`);
|
|
155
|
+
fontFace
|
|
156
|
+
.load()
|
|
157
|
+
.then((loadedFont) => {
|
|
158
|
+
document.fonts.add(loadedFont);
|
|
159
|
+
resolve();
|
|
160
|
+
})
|
|
161
|
+
.catch(() => {
|
|
162
|
+
// Try next format
|
|
163
|
+
currentFormatIndex++;
|
|
164
|
+
tryLoadFont();
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
tryLoadFont();
|
|
156
168
|
});
|
|
157
169
|
};
|
|
158
170
|
const getImageUrl = (type, value) => {
|
|
@@ -667,7 +679,7 @@ const renderStrokePatchesCanvas = (ctx, canvas, config, imageRefs) => {
|
|
|
667
679
|
// Calculate text size to fit top section
|
|
668
680
|
let previewFontSize = LAYOUT.HEADER_FONT_SIZE * 3; // Start with large size
|
|
669
681
|
const fontToUse = isFontMissing ? LAYOUT.FONT_FAMILY : position.font;
|
|
670
|
-
ctx.font = `${previewFontSize}px ${fontToUse}`;
|
|
682
|
+
ctx.font = `${previewFontSize}px "${fontToUse}"`;
|
|
671
683
|
const text = position.text || "";
|
|
672
684
|
const maxTextWidth = usableWidth * 0.9; // Use 75% of width for better padding
|
|
673
685
|
const maxTextHeight = actualTopSectionHeight; // Use 60% of height
|
|
@@ -675,13 +687,13 @@ const renderStrokePatchesCanvas = (ctx, canvas, config, imageRefs) => {
|
|
|
675
687
|
let textWidth = ctx.measureText(text).width;
|
|
676
688
|
while (textWidth > maxTextWidth && previewFontSize > 50) {
|
|
677
689
|
previewFontSize *= 0.95;
|
|
678
|
-
ctx.font = `${previewFontSize}px ${fontToUse}`;
|
|
690
|
+
ctx.font = `${previewFontSize}px "${fontToUse}"`;
|
|
679
691
|
textWidth = ctx.measureText(text).width;
|
|
680
692
|
}
|
|
681
693
|
// Ensure text height also fits
|
|
682
694
|
while (previewFontSize > maxTextHeight && previewFontSize > 50) {
|
|
683
695
|
previewFontSize *= 0.95;
|
|
684
|
-
ctx.font = `${previewFontSize}px ${fontToUse}`;
|
|
696
|
+
ctx.font = `${previewFontSize}px "${fontToUse}"`;
|
|
685
697
|
}
|
|
686
698
|
// Update textWidth after final scaling
|
|
687
699
|
textWidth = ctx.measureText(text).width;
|
|
@@ -761,7 +773,7 @@ const renderStrokePatchesCanvas = (ctx, canvas, config, imageRefs) => {
|
|
|
761
773
|
// Render font name với chính font đó
|
|
762
774
|
const prefixWidth = ctx.measureText(fontPrefix).width;
|
|
763
775
|
const fontName = position.font || LAYOUT.FONT_FAMILY;
|
|
764
|
-
ctx.font = `${infoFontSize}px ${fontName}`;
|
|
776
|
+
ctx.font = `${infoFontSize}px "${fontName}"`;
|
|
765
777
|
ctx.fillText(fontName, startX + prefixWidth, infoY);
|
|
766
778
|
}
|
|
767
779
|
infoY += infoLineHeight;
|
|
@@ -1051,7 +1063,7 @@ const renderTemplateCustomTextPatchesCanvas = (ctx, canvas, config, imageRefs) =
|
|
|
1051
1063
|
let high = previewFontSize;
|
|
1052
1064
|
while (high - low > 1) {
|
|
1053
1065
|
const mid = (low + high) / 2;
|
|
1054
|
-
ctx.font = `${mid}px ${fontToUse}`;
|
|
1066
|
+
ctx.font = `${mid}px "${fontToUse}"`;
|
|
1055
1067
|
// Kiểm tra width của tất cả các dòng
|
|
1056
1068
|
const maxLineWidth = Math.max(...textLines.map(line => ctx.measureText(line).width));
|
|
1057
1069
|
// Kiểm tra height với line height = 1.1 (giảm từ 1.2 để text to hơn)
|
|
@@ -1068,7 +1080,7 @@ const renderTemplateCustomTextPatchesCanvas = (ctx, canvas, config, imageRefs) =
|
|
|
1068
1080
|
}
|
|
1069
1081
|
}
|
|
1070
1082
|
previewFontSize = bestFontSize;
|
|
1071
|
-
ctx.font = `${previewFontSize}px ${fontToUse}`;
|
|
1083
|
+
ctx.font = `${previewFontSize}px "${fontToUse}"`;
|
|
1072
1084
|
// Center the text inside rectangle
|
|
1073
1085
|
const finalLineHeight = previewFontSize * 1.1;
|
|
1074
1086
|
const totalTextHeightFinal = textLines.length * finalLineHeight;
|
|
@@ -1126,7 +1138,7 @@ const renderTemplateCustomTextPatchesCanvas = (ctx, canvas, config, imageRefs) =
|
|
|
1126
1138
|
// Render font name với chính font đó
|
|
1127
1139
|
const prefixWidth = ctx.measureText(fontPrefix).width;
|
|
1128
1140
|
const fontName = position.font || LAYOUT.FONT_FAMILY;
|
|
1129
|
-
ctx.font = `${infoFontSize}px ${fontName}`;
|
|
1141
|
+
ctx.font = `${infoFontSize}px "${fontName}"`;
|
|
1130
1142
|
ctx.fillText(fontName, startX + prefixWidth, infoY);
|
|
1131
1143
|
}
|
|
1132
1144
|
infoY += infoLineHeight;
|
|
@@ -1736,7 +1748,7 @@ const renderUniformLabels = (ctx, uniformProps, x, y, maxWidth, scaleFactor, ima
|
|
|
1736
1748
|
let currentX = x + prefixWidth;
|
|
1737
1749
|
ctx.fillText(prefix, x, cursorY);
|
|
1738
1750
|
// Render tên font với font từ config
|
|
1739
|
-
ctx.font = `${fontSize}px ${values.font}`;
|
|
1751
|
+
ctx.font = `${fontSize}px "${values.font}"`;
|
|
1740
1752
|
const fontNameWidth = ctx.measureText(values.font).width;
|
|
1741
1753
|
ctx.fillText(values.font, currentX, cursorY);
|
|
1742
1754
|
currentX += fontNameWidth;
|
|
@@ -1961,7 +1973,7 @@ displayIndex, showLabels, scaleFactor, imageRefs, mockupBounds = null) => {
|
|
|
1961
1973
|
const measureFontTextWidth = (fontSize) => {
|
|
1962
1974
|
ctx.font = `${fontSize}px ${LAYOUT.FONT_FAMILY}`;
|
|
1963
1975
|
const prefixWidth = ctx.measureText(prefix).width;
|
|
1964
|
-
ctx.font = `${fontSize}px ${position.font}`;
|
|
1976
|
+
ctx.font = `${fontSize}px "${position.font}"`;
|
|
1965
1977
|
const fontNameWidth = ctx.measureText(fontName).width;
|
|
1966
1978
|
ctx.font = `${fontSize}px ${LAYOUT.FONT_FAMILY}`;
|
|
1967
1979
|
const suffixWidth = ctx.measureText(suffix).width;
|
|
@@ -2037,7 +2049,7 @@ displayIndex, showLabels, scaleFactor, imageRefs, mockupBounds = null) => {
|
|
|
2037
2049
|
const prefixWidth = ctx.measureText(prefix).width;
|
|
2038
2050
|
let currentX = x + prefixWidth;
|
|
2039
2051
|
ctx.fillText(prefix, x, currentY);
|
|
2040
|
-
ctx.font = `${effectiveFontSize}px ${position.font}`;
|
|
2052
|
+
ctx.font = `${effectiveFontSize}px "${position.font}"`;
|
|
2041
2053
|
const fontNameWidth = ctx.measureText(fontName).width;
|
|
2042
2054
|
const totalWidth = prefixWidth + fontNameWidth;
|
|
2043
2055
|
if (totalWidth > shrunkEffectiveMaxWidth) {
|