fix: correct sprite font vertical offset and use avg char width fallback

This commit is contained in:
openhands committed 2026-07-03 18:37:05 +02:00
1 parent 77ae4838c0
commit a1950e5b65
5 files changed
+16 -13

No files matched your search

+2 -2
View File
@@ -47,7 +47,7 @@ export default function LogoGenerator() {
getFontInfo(styleName)
.then((info) => {
if (cancelled) return;
const canvas = renderToCanvas(info.chars, info.h, info.sheet, safeText, 12);
const canvas = renderToCanvas(info.chars, info.h, info.top, info.sheet, safeText, info.avgW);
if (canvas && canvasRef.current) {
canvasRef.current.width = canvas.width;
canvasRef.current.height = canvas.height;
@@ -108,7 +108,7 @@ export default function LogoGenerator() {
for (const font of allFonts) {
try {
const info = await getFontInfo(font.styleName);
const canvas = renderToCanvas(info.chars, info.h, info.sheet, safeText, 12);
const canvas = renderToCanvas(info.chars, info.h, info.top, info.sheet, safeText, info.avgW);
if (!canvas) { fail++; continue; }
const blob = await new Promise<Blob | null>((r) => canvas.toBlob((b) => r(b), "image/png"));
if (blob) folder.file(`${font.styleName}.png`, blob);